How r1khilt/claymore works
Purpose and System Shape
Claymore is a closed-loop scientific-research platform: it ingests lab context, builds attributed scientific memory, identifies and plans investigations, performs computational or robotic work, and incorporates results into future decisions. The backend is Python/FastAPI; the optional operator UI is React/TypeScript with 2D/3D lab and graph views.
Runtime Entry Points
The HTTP application and runtime composition live in src/claymore/api/app.py and src/claymore/api/runtime.py. API route groups expose agent interaction, questions, connector administration, actions, local operations, and Telegram/WhatsApp channels under src/claymore/api/routes/. An MCP integration surface is separately hosted by src/claymore/mcp_server/server.py. The browser client starts at web/src/main.tsx and routes UI state through web/src/App.tsx.
Ingestion and Knowledge Construction
The ingestion pipeline gathers external lab artifacts, normalizes them, and turns them into episodes suitable for memory storage: src/claymore/ingest/pipeline.py, src/claymore/ingest/normalize.py, and src/claymore/ingest/episodes.py. Composio is the connector boundary for sources such as Slack, GitHub, Gmail, and Notion, managed through src/claymore/ingest/composio/manager.py and src/claymore/ingest/composio/hub.py. Source state supports incremental/repeatable ingestion.
Scientific Memory and Retrieval
Memory is modeled as a scientific graph with ontology, identity resolution, reconciliation, and retrieval layers in src/claymore/memory/graph.py, src/claymore/memory/ontology.py, and src/claymore/memory/retrieval.py. Graphiti and FalkorDB are the material graph-memory services. Reconciliation (src/claymore/memory/reconcile.py) is a key boundary between noisy external events and canonical, attributed lab knowledge.
Agent Orchestration and Planning
The agent loop coordinates conversation context, LLM calls, routing, tools, temporal reasoning, hardware awareness, and scene/protocol design: src/claymore/agent/agent_loop.py, src/claymore/agent/router.py, and src/claymore/agent/scene_designer.py. It uses the Claude API and Claude Agent SDK through src/claymore/agent/llm.py and src/claymore/agent/sdk_loop.py. Agent-facing API flows enter through src/claymore/api/routes/agent.py and src/claymore/api/routes/ask.py.
Research Execution and Feedback Loop
Execution dispatches work to computational analysis, ML, datasets, workflow coordination, Claude Science, and laboratory automation: src/claymore/execute/science_agent.py, src/claymore/execute/claude_science.py, and src/claymore/execute/workflows.py. Physical execution integrates Opentrons (and, per project scope, PyLabRobot) via src/claymore/execute/opentrons.py; hardware context is represented in src/claymore/agent/hardware.py. Results are expected to re-enter ingestion/memory, closing the discover → plan → execute → learn loop.
Human Control, Safety, and External Channels
Potentially consequential operations cross an approval/writeback boundary in src/claymore/actions/approvals.py, src/claymore/actions/writeback.py, and src/claymore/execute/approvals.py, with audit support in src/claymore/audit.py. Authentication/security are backend concerns in src/claymore/auth/models.py and src/claymore/api/security.py. Telegram, WhatsApp, and SMS adapters provide alternate interaction/notification paths through src/claymore/messaging/telegram.py, src/claymore/messaging/whatsapp.py, and src/claymore/messaging/twilio_sms.py.
Operator Interface and Deployment
The web UI presents ask/agent turns, approvals, sources, projects, memory, and proactive work; its primary integration boundary is web/src/lib/api.ts. Scientific-workflow visualization is concentrated in web/src/components/bench/ProtocolWorkspace.tsx and Three.js components under web/src/components/bench/three/; graph visualization is in web/src/components/projects/KnowledgeGraph3D.tsx. Local multi-service deployment is defined in docker-compose.yml; environment configuration begins with .env.example.
Main entry points: agent_loop.py Agent loop · pipeline.py Ingestion pipeline · graph.py Scientific memory graph · science_agent.py Research execution
Components 20
Interfaces
- Operator UI
web/src/App.tsx - Web API client
web/src/lib/api.ts - HTTP application · Composes the backend runtime and route groups.
src/claymore/api/app.py - Agent & ask routes
src/claymore/api/routes/agent.py - MCP server
src/claymore/mcp_server/server.py - Messaging channels
src/claymore/messaging/telegram.py
Knowledge Loop
- Ingestion pipeline · Collects source artifacts and supports incremental ingestion.
src/claymore/ingest/pipeline.py - Normalize to episodes
src/claymore/ingest/episodes.py - Composio connectors · Connects Slack, GitHub, Gmail, Notion, and similar sources.
src/claymore/ingest/composio/manager.py - Reconciliation · Converts noisy events into attributed canonical knowledge.
src/claymore/memory/reconcile.py - Scientific memory graph · Ontology, identity, provenance, and retrieval layer.
src/claymore/memory/graph.py - Graphiti & FalkorDB
Agent Planning
- Agent loop · Coordinates context, tools, temporal reasoning, and investigation work.
src/claymore/agent/agent_loop.py - Agent router
src/claymore/agent/router.py - Scene & protocol design
src/claymore/agent/scene_designer.py - Claude APIs & SDK
src/claymore/agent/llm.py
Execution & Control
- Research execution · Dispatches analysis, ML, datasets, workflows, and science agents.
src/claymore/execute/science_agent.py - Lab automation · Opentrons and project-scope PyLabRobot execution.
src/claymore/execute/opentrons.py - Approval & writeback · Gates consequential operations and external writes.
src/claymore/actions/approvals.py - Audit trail
src/claymore/audit.py
Connections 21
- Operator UI → Web API client: uses
- Web API client → HTTP application: HTTP
- Messaging channels → HTTP application: alternate interaction
- MCP server → Agent loop: tool interaction
- HTTP application → Agent & ask routes: mounts
- Agent & ask routes → Agent loop: requests
- Composio connectors → Ingestion pipeline: source artifacts
- Ingestion pipeline → Normalize to episodes: raw context
- Normalize to episodes → Reconciliation: episodes
- Reconciliation → Scientific memory graph: canonical knowledge
- Scientific memory graph → Graphiti & FalkorDB: persists and queries
- Scientific memory graph → Agent loop: retrieval context
- Agent loop → Agent router: routes work
- Agent loop → Claude APIs & SDK: LLM calls
- Agent loop → Scene & protocol design: plans investigations
- Scene & protocol design → Research execution: protocols and tasks
- Research execution → Approval & writeback: consequential actions
- Approval & writeback → Lab automation: approved protocols
- Approval & writeback → Audit trail: decision record
- Research execution → Ingestion pipeline: results feedback · Execution results re-enter the knowledge loop.
- Lab automation → Ingestion pipeline: experimental results