How ashishu23/orchestra-ai works
1. System shape
Orchestra AI is a three-service distributed system: an Orchestrator coordinates reasoning, a Knowledge-Vault MCP service handles document retrieval, and an Executive-Sandbox MCP service handles isolated Python execution. A separate Qdrant vector database stores the indexed corpus. The core architectural boundary is that the LLM-driven orchestrator never talks to Qdrant or user code directly; it only calls typed MCP tools over HTTP.
2. Orchestrator as control plane
The orchestrator/ service is the central API and workflow engine. It exposes POST /research, GET /health, and GET /metrics via FastAPI, and internally runs a LangGraph state machine. The graph is built around a shared OrchestraState and moves through planner, executor, critic, correction, and synthesizer phases.
3. Agent responsibilities
The orchestrator’s agents are cleanly separated: planner.py turns a user query into a bounded JSON step plan, executor.py dispatches each step to an MCP tool, and critic.py evaluates whether results are grounded enough to pass. The graph can route from critic to correction and retry, which creates a self-correcting loop rather than a one-shot RAG pipeline.
4. Tool access boundary via MCP
All external capabilities are accessed through the orchestrator/mcp/ clients. client.py is the generic JSON-RPC 2.0 transport, while vault_client.py and sandbox_client.py are typed wrappers for the two MCP servers. This means the orchestration layer sees structured tool schemas, not direct service internals.
5. Knowledge-Vault as retrieval subsystem
The knowledge-vault/ service is a FastMCP server that wraps Qdrant-based retrieval. It provides semantic search, keyword search, hybrid search, and ingestion tools. Its internal rag/ package forms a pipeline from raw document text or PDFs to chunks, embeddings, Qdrant upserts, and query-time rank fusion.
6. Retrieval data flow
Ingestion flows from ingestion/ingest_cli.py or the vault MCP ingestion tools into chunker.py, then embedder.py, then qdrant_store.py. At query time, the vault can return dense vector results, sparse keyword results, or a hybrid mix fused with Reciprocal Rank Fusion in rrf.py. This is the repository’s main retrieval plane.
7. Executive-Sandbox as execution subsystem
The executive-sandbox/ service is the isolated computation plane for verifying numerical or programmatic claims. It exposes a single MCP tool, execute_python, which runs code through sandbox/runner.py. Execution happens in a fresh child process with resource limits and restricted builtins, so the orchestrator can validate calculations without embedding arbitrary execution in its own process.
8. Data stores and persistence
Qdrant is the only durable application data store in the architecture. It is deployed as a StatefulSet with persistent storage, and it holds the research_docs collection with both dense and sparse representations. The other services are stateless beyond request-scoped state and local process isolation.
9. Security and isolation boundaries
Security is enforced at several layers: MCP schemas constrain what the orchestrator can ask for, the sandbox container runs non-root with dropped capabilities, and Kubernetes NetworkPolicy blocks all sandbox egress. That combination prevents direct DB access from the LLM path and prevents sandboxed code from reaching the network or other internal services.
10. Deployment topology
The repository supports both local and Kubernetes deployment. docker-compose.yml wires the four runtime services together for local development, while helm/orchestra/ defines the production/minikube deployment: namespace, secrets, services, deployments, Qdrant StatefulSet, and network policies. The deployment is designed as isolated microservices rather than a monolith.
11. Operational concerns
The orchestrator exposes Prometheus metrics for request volume, self-corrections, and verified chunks, making retrieval quality and retry behavior visible. The sandbox also has an HPA in Kubernetes, reflecting that execution workload can scale independently from orchestration and retrieval.
12. Testing and code organization
Each subsystem has targeted tests: graph behavior and MCP client behavior in orchestrator/tests, retrieval and chunking behavior in knowledge-vault/tests, and subprocess safety/timeout behavior in executive-sandbox/tests. This mirrors the architecture: workflow logic, retrieval logic, and execution isolation are validated separately.
Main entry points: orchestra Helm Chart · knowledge-vault/main.py Knowledge Vault · docker-compose.yml Local Compose · executive-sandbox/main.py Executive Sandbox
Components 18
Control Plane
LLM orchestration, planning, and MCP client boundary.
- Orchestrator API · Exposes research, health, and metrics endpoints.
orchestrator/main.py - Agent Graph · Coordinates planner, executor, critic, correction, and synthesis phases.
orchestrator/agents/graph.py - Orchestra State · State object passed through the orchestration loop.
orchestrator/agents/state.py - Planner · Turns a query into a bounded step plan.
orchestrator/agents/planner.py - Executor · Calls typed MCP tools to execute each step.
orchestrator/agents/executor.py - Critic · Checks grounding and decides whether to correct or continue.
orchestrator/agents/critic.py - MCP Client · Generic JSON-RPC 2.0 client used by typed wrappers.
orchestrator/mcp/client.py - Vault Client · Wrapper for retrieval and ingestion tools.
orchestrator/mcp/vault_client.py - Sandbox Client · Wrapper for isolated code execution tools.
orchestrator/mcp/sandbox_client.py
Retrieval Plane
Document ingestion, indexing, and hybrid search.
- Knowledge Vault · Retrieval service exposing search and ingestion tools.
knowledge-vault/main.py - RAG Pipeline · Chunks, embeds, stores, and ranks documents for search.
knowledge-vault/rag - Ingest CLI · Loads raw documents into the retrieval pipeline.
ingestion/ingest_cli.py
Execution Plane
Isolated Python execution for verification and computation.
- Executive Sandbox · Isolated execution service exposing python execution.
executive-sandbox/main.py - Sandbox Runner · Runs code in a fresh child process with limits.
executive-sandbox/sandbox/runner.py
Platform
Local and Kubernetes deployment, storage, and security boundaries.
- Qdrant Store · Durable dense and sparse corpus storage.
helm/orchestra/templates/qdrant/statefulset.yaml - Local Compose · Wires the runtime services together for local development.
docker-compose.yml - Helm Chart · Defines services, deployments, stateful storage, and policies.
helm/orchestra - Network Policy · Restricts sandbox egress and internal traffic boundaries.
helm/orchestra/templates/network-policy
Connections 26
- Orchestrator API → Agent Graph: runs · Request handling hands off to the workflow graph.
- Agent Graph → Orchestra State: mutates · Graph nodes read and update shared orchestration state.
- Agent Graph → Planner: starts with · Initial phase creates a bounded plan.
- Planner → Executor: hands off · Plan items are executed step by step.
- Executor → Critic: submits results · Execution outputs are evaluated for grounding.
- Critic → Planner: corrects · Failed verification can route back for correction.
- Executor → MCP Client: uses · Tool calls go through the generic JSON-RPC transport.
- MCP Client → Vault Client: wraps · Typed wrapper for retrieval capabilities.
- MCP Client → Sandbox Client: wraps · Typed wrapper for execution capabilities.
- Vault Client → Knowledge Vault: calls · Orchestrator reaches retrieval tools over HTTP.
- Sandbox Client → Executive Sandbox: calls · Orchestrator reaches execution tools over HTTP.
- Knowledge Vault → RAG Pipeline: uses · Search and ingestion delegate to the retrieval pipeline.
- Ingest CLI → RAG Pipeline: feeds · CLI ingestion enters the chunk/embed/index flow.
- RAG Pipeline → Qdrant Store: indexes into · Chunks and embeddings are upserted into Qdrant.
- Knowledge Vault → Qdrant Store: queries · Semantic, keyword, and hybrid search hit the corpus store.
- Executive Sandbox → Sandbox Runner: executes via · Tool handler delegates to the isolated runner.
- Sandbox Runner → Network Policy: constrained by · Runner operates under egress restrictions and isolation.
- Local Compose → Orchestrator API: includes · Local development composition includes the orchestrator.
- Local Compose → Knowledge Vault: includes · Local development composition includes retrieval service.
- Local Compose → Executive Sandbox: includes · Local development composition includes execution service.
- Local Compose → Qdrant Store: includes · Local development composition includes the vector store.
- Helm Chart → Orchestrator API: deploys · Kubernetes manifests deploy the orchestrator service.
- Helm Chart → Knowledge Vault: deploys · Kubernetes manifests deploy the knowledge-vault service.
- Helm Chart → Executive Sandbox: deploys · Kubernetes manifests deploy the sandbox service.
- Helm Chart → Qdrant Store: deploys · Kubernetes manifests deploy persistent Qdrant storage.
- Helm Chart → Network Policy: defines · Cluster manifests include traffic restriction policies.