How swappy-ops/baton works
Baton has two connected runtime surfaces: a FastAPI observability server for intent, session state, traces, and live telemetry; and an optional agent workflow package for routing tasks, retrieval, specialist execution, and distilled memory. The server workflow is shown from user input through persistence and broadcasts. The agent graph's stages and retrieval/memory interactions are supported by source excerpts; some adjacent runtime capabilities are documented but their callers are not shown, so no speculative links are added.
Main entry points: main.py FastAPI App · nodes.py Agent Nodes · event_bus.py Event Bus · manager.py WebSocket Hub
Components 25
Observatory Server
- FastAPI App
baton_server/main.py - REST API
baton_server/api/__init__.py - WebSocket Hub
baton_server/websocket/manager.py - Session Memory
baton_server/services/session_memory.py - Trace Database
baton_server/db/manager.py
Events & Telemetry
- Telemetry Engine
baton_server/orchestration/engine.py - Event Bus
baton_server/services/event_bus.py - Attention Scoring
baton_server/services/attention_engine.py - Event Schemas
baton_server/schemas/events.py
Agent Workflow
- Workflow Graph
baton/graphs/router_graph.py - Agent Nodes
baton/agents/nodes.py - Memory Distillation
baton/agents/distillation_node.py
Retrieval & Memory
- Retrieval Pipeline
baton/retrieval/pipeline.py - Structural Index
baton/retrieval/structural_index.py - Memory Manager
baton/memory/manager.py - Memory Governance
baton/memory/governance.py
Task Runtime
- Context Budget
baton/runtime/context_budget.py - Task Contracts
baton/runtime/task_contract.py - Stability Manager
baton/runtime/stability.py - Terminology Sync
baton/runtime/dos_sync.py - Runtime Workflows
baton/runtime/workflows.py
Other components
- User
- Observatory UI
- Ollama LLM
- ChromaDB
Connections 27
- User → FastAPI App: submits intent
baton_server/main.py - FastAPI App → Session Memory: saves state
baton_server/main.py - FastAPI App → WebSocket Hub: broadcasts events
baton_server/main.py - FastAPI App → Trace Database: logs traces
baton_server/main.py - FastAPI App → REST API: mounts routes
baton_server/main.py - REST API → Session Memory: reads state
baton_server/api/__init__.py - REST API → WebSocket Hub: reads connections
baton_server/api/__init__.py - FastAPI App → Telemetry Engine: starts streams
baton_server/main.py - Telemetry Engine → Event Bus: publishes events
baton_server/orchestration/engine.py - Telemetry Engine → Event Schemas: constructs events
baton_server/orchestration/engine.py - Event Bus → Attention Scoring: scores events
baton_server/services/event_bus.py - Event Bus → Event Schemas: handles events
baton_server/services/event_bus.py - Event Bus → WebSocket Hub: broadcasts events
baton_server/services/event_bus.py - WebSocket Hub → Observatory UI: streams updates
README.md - Observatory UI → User: shows telemetry
README.md - Workflow Graph → Agent Nodes: dispatches stages
baton/graphs/router_graph.py - Agent Nodes → Task Contracts: selects contract
baton/agents/nodes.py - Agent Nodes → Context Budget: sets retrieval budget
baton/agents/nodes.py - Agent Nodes → Stability Manager: checks limits
baton/agents/nodes.py - Agent Nodes → Retrieval Pipeline: queries context
baton/agents/nodes.py - Agent Nodes → Ollama LLM: invokes model
baton/agents/nodes.py - Workflow Graph → Memory Distillation: dispatches stage
baton/graphs/router_graph.py - Memory Distillation → Memory Manager: stores distilled memory
baton/agents/distillation_node.py - Memory Manager → Terminology Sync: normalizes terminology
baton/memory/manager.py - Memory Manager → Retrieval Pipeline: indexes memory
baton/memory/manager.py - Retrieval Pipeline → ChromaDB: queries and writes
baton/retrieval/pipeline.py - Structural Index → Retrieval Pipeline: supports indexing
baton/retrieval/structural_index.py