agents package
Reviewed against commit 8a2cb42ad on 2026-10-23.
Reference: package page (78 modules, 27,430 lines) · subpackages volks (50 modules) and swarm (3 modules) · key modules: volk_registry, runtime, task_executor, kernel_handler, tool_registry, volks/base. How the package fits the whole system is in the overview; the team of volks is described on the volks page.
The story
orchestrata_ultimate.agents is the Multi-Agent Runtime for Orchestrata — the place where the abstract idea of "a team of AI agents building software" becomes running code. The rest of the system produces intents, routes messages, and enforces policy; this package is what those intents ultimately land on. It exists to solve two problems at once: managing a fleet of agent processes safely (spawning, pooling, coordinating, and terminating "Volk" instances under constitutional constraints), and giving each agent an actual brain (an LLM-backed persona with tools, memory, and a role in the delivery pipeline). Per the package docstring, it provides Volk lifecycle management, task execution, pool management, multi-Volk coordination, and integration with the Intent Broker, Postman, CXP, and the DI container.
The runtime half reads like classic infrastructure. types.py defines the shared vocabulary (TaskDefinition, TaskResult, VolkInstance, pool configs and status enums); VolkRuntime spawns and terminates instances with every decision checked through MultiagentPrologBridge, the Python facade over the multiagent.pl governance rules; VolkPool keeps per-alias instance pools with auto-scaling and load-aware selection; and TaskExecutor ties it all together — governed task assignment, instance acquisition, execution tracking, and result collection, with state persisted in Redis. Above that, VolkCoordinator implements multi-volk patterns (leader election, consensus, fan-out, pipeline), while hierarchy.py, communication.py, escalation.py, and lifecycle.py enforce the parent-child agent tree, CXP-based inter-agent messaging within its boundaries, and escalation of failures upward with context preserved.
A task typically enters through one of three doors. The IntentTaskAdapter converts Intent Broker intents into TaskDefinitions and hands back dispatch results. The VolkPostmanAdapter dequeues CXP packets delivered by Postman, converts them to tasks, and acknowledges delivery after execution. And for the out-of-process deployment, runtime_main.py boots the agent-runtime CXP server whose per-packet handler — built by build_kernel_packet_handler() in kernel_handler.py — stands up a kernel PipelineRunner over all the volks so live CXP traffic drives the volk engine directly. (Until 2026-08 this server ran on grpcio; grpcio was retired on 2026-08-07 and the cxpt direct transport replaced it, though the port environment keys still carry the GRPC name.) Whichever door is used, work flows through the same governed executor-and-pool machinery.
The brain half lives in volks/. BaseAgent (a Pydantic model) is the base class of every volk: identity, validation, serialization, memory recall via memory_context.py, a shared team persona from persona.py, and the LLM call paths — including _call_llm_with_tools(), which drives the function-calling loop against the schemas and sandboxed executors in tool_registry.py. On top of it sit the concrete agents that form the delivery pipeline: Concierge (U:Cx) → Analyst (U:BA) → PM → UX → Architect (U:Ar) → CodeDirector (U:Cd, delegating to Junior volks over CXP and optionally fanning out via the swarm/ subpackage) → QA (U:Qa) → Compliance (U:Cp, deterministic RTM checking with no LLM) → Documentor (U:Do), with Senior Dev (U:SD) as an oscillation-recovery specialist. Neighboring packages appear exactly where you would expect: cxp supplies the packet format everywhere agents talk to each other, postman and kernel deliver and orchestrate that traffic, llm/providers back the brains, drivers back code generation, knowledge_graph stores design context, and core supplies config, tracing, and the Redis/Prolog plumbing.
Key responsibilities
- Volk lifecycle — spawn, terminate, force-terminate, and health-track live agent instances (
VolkRuntime), every transition gated by a Prolog governance check and persisted to Redis. - Pooling & auto-scaling — per-alias instance pools with min/max limits, idle timeouts, and load-aware
acquire/release/scale_to(VolkPool). - Governed task execution — assign tasks to agents only when the
multiagent.plrules permit, run them, and collectTaskResults (TaskExecutor). - Multi-volk coordination — leader election, consensus, fan-out, and pipeline patterns composed on top of the executor (
VolkCoordinator). - Logic-programming governance — a single Python facade over the
multiagent.plrule set answering every who-may-do-what question (MultiagentPrologBridge). - Agent brains — a Pydantic
BaseAgentgiving every volk identity, memory recall, a shared team persona, CXP messaging, and an LLM function-calling loop wired totool_registry.py. - The delivery team — eleven concrete volks (Concierge → Analyst → PM → UX → Architect → CodeDirector → QA → Compliance → Documentor, plus Junior and Senior Dev) that turn a user request into reviewed, documented, traced code.
- Parallel code generation —
SwarmCoordinatorfans N files across N concurrent codegen tasks in isolated workspaces and merges the results. - Entry adapters & live service — intent, Postman, and CXP adapters plus the out-of-process
agent-runtimeCXP handler feed work into the same governed machinery.
Class diagram
Runtime core
The infrastructure spine. VolkRuntime owns the live instances; VolkPool scales them per alias; TaskExecutor is the seam where a TaskDefinition meets an agent; VolkCoordinator composes many executions into coordination patterns; and every one of them routes its authorization questions through MultiagentPrologBridge, the facade over multiagent.pl (render-verified):
Runtime data model
The shared vocabulary from types.py that every module above speaks — the task lifecycle (TaskDefinition/TaskResult), the live-instance record (VolkInstance), pool config/status, the consensus result, and the two lifecycle enums (render-verified):
The volk brain and team
BaseAgent is the Pydantic trunk every concrete volk inherits — carrying identity, status, artifacts, the Postman/KG handles, and the CXP process/send/emit_event surface. The eleven concrete volks form Orchestrata's delivery pipeline; CodeDirectorVolk additionally delegates to JuniorVolk over CXP and fans out through SwarmCoordinator (render-verified):
Full inheritance overview
Inheritance across the whole package — every volk descends from the Pydantic BaseAgent, the QA volk is assembled from capability mixins, and the exception tree roots at VolkRuntimeError (render-verified, do not edit):
Module dependency diagram
Internal module imports within orchestrata_ultimate.agents (generated from the AST, render-verified):
Module inventory
| Module | Purpose |
|---|---|
agents/__init__.py |
Package entry — Multi-Agent Runtime for Orchestrata. |
agents/communication.py |
Inter-agent communication via the CXP protocol; enforces hierarchy boundaries and escalation rules (AgentCommunication, CommunicationError). |
agents/constants.py |
Runtime configuration defaults, overridable via PoolConfig / TaskDefinition / DI. |
agents/constraints.py |
Constitutional constraint validation — scope boundaries and resource limits for agent operations. |
agents/coordinator.py |
Multi-Volk coordination patterns: leader election, consensus, fan-out, pipeline (VolkCoordinator, AgentCoordinator). |
agents/cxp_adapter.py |
CXPVolkAdapter — base class for volks that process incoming CXP packets via process_cxp(). |
agents/escalation.py |
Escalation of issues up the agent hierarchy with context preservation and resolution tracking (AgentEscalation, EscalationResult). |
agents/exceptions.py |
Runtime exception hierarchy rooted at VolkRuntimeError. |
agents/hierarchy.py |
Parent-child agent relationships with depth limits, tree validation, Redis persistence (AgentHierarchy, HierarchyNode). |
agents/intent_adapter.py |
IntentTaskAdapter — converts IntentBroker Intents into TaskDefinitions and returns DispatchResults. |
agents/interfaces.py |
Runtime-checkable protocols for lifecycle, task execution, pools, and coordination. |
agents/kernel_handler.py |
Builds the CXP packet handler for the out-of-process kernel (agent-runtime service); boots a PipelineRunner over all the volks (build_kernel_packet_handler). |
agents/volk_registry.py |
VolkRegistry (an IComponent; AgentRegistry is an alias subclass) — the kernel's registry of volks: definitions (VolkDefinition), capabilities, registration tokens, health and heartbeat. Used by runtime, the kernel dispatcher/router/CLI, the orchestrator pipeline runner and the harness. |
agents/lifecycle.py |
Formal spawn/terminate/failure lifecycle with constitutional checks (AgentLifecycle, LifecycleState, LifespanType). |
agents/pool.py |
Per-alias Volk instance pools with min/max limits, auto-scaling, idle timeouts, load-aware selection (VolkPool, AgentPool). |
agents/postman_adapter.py |
VolkPostmanAdapter — dequeues CXP packets from Postman, converts to tasks, executes via TaskExecutor, acknowledges delivery. |
agents/prolog_bridge.py |
MultiagentPrologBridge — Python access to multiagent.pl rules for lifecycle governance, task assignment, coordination, health, recovery. |
agents/prompt_builder.py |
Structured repair-cycle prompts for junior coding volks after QA review (Spec 005). |
agents/runtime.py |
VolkRuntime (IComponent, ComponentType.VOLK_RUNTIME) — spawns/terminates/tracks Volk instances with Prolog governance and Redis state. |
agents/runtime_main.py |
Agent Runtime server entry point (CXP protocol over the cxpt direct transport; orchestrata-agent-runtime container; port from CXP_GRPC_PORT / CXP_GRPC_ENDPOINT). |
agents/spec_writer.py |
Standalone spec-document generator (specs/NNN-name/spec.md + requirements checklists); zero orchestrata imports. |
agents/task_executor.py |
TaskExecutor — task assignment via Prolog governance, instance acquisition via VolkPool, execution tracking, result collection. |
agents/tool_registry.py |
OpenAI/DeepSeek function-calling tool schemas + thread-safe sandboxed executor, wired via BaseAgent._call_llm_with_tools(); includes Mermaid validation and governed web tools. |
agents/types.py |
Core runtime data structures: TaskDefinition, TaskResult, VolkInstance, PoolConfig, PoolStatus, ConsensusResult, status enums. |
agents/uml_generator.py |
Mermaid class/module/sequence diagram generation from structured design data; standalone. |
agents/swarm/__init__.py |
Exports SwarmCoordinator, ShardResult. |
agents/swarm/coordinator.py |
SwarmCoordinator — fans out N source files across N concurrent asyncio codegen tasks in isolated temp workspaces, atomically merges results. |
agents/swarm/types.py |
Swarm data types (ShardResult). |
agents/volks/__init__.py |
Volks subpackage (empty init). |
agents/volks/base.py |
BaseAgent(BaseModel) — Pydantic base class for all volks: validation, serialization, identity, LLM/tool call paths. |
agents/volks/memory_context.py |
Run-scoped memory-context provider registry — binds a SPEC-010 memory engine per run by thread_id for volk recall. |
agents/volks/persona.py |
Shared volk team-identity + communication-fabric preamble prepended to role prompts. |
agents/volks/analyst/agent.py |
AnalystAgent (U:BA) — generates user stories/requirements via LLM, stores in KG, escalates to U:PM. |
agents/volks/analyst/parsers.py |
Regex parsers for Analyst LLM output sections (PROJECT_TYPE, USER_STORIES, REQUIREMENTS, …). |
agents/volks/analyst/prompts.py |
Analyst system prompts / structured output template (SPEC-019). |
agents/volks/architect/volk.py |
ArchitectVolk (U:Ar) — deepseek-reasoner-driven design and specs. |
agents/volks/architect/architect_context.py |
Context-building mixin: knowledge-graph (orchkg) queries + filesystem fallback for design prompts. |
agents/volks/architect/architect_project.py |
Project-ops mixin: filesystem setup, design doc writing, response parsing, git commits. |
agents/volks/architect/architect_prompts.py |
Architect prompt templates and configuration constants. |
agents/volks/codedirector/volk.py |
CodeDirectorVolk (U:Cd) — coder volk with junior delegation via CXP. |
agents/volks/codedirector/implementation.py |
Implementation helpers — skeleton, swarm, and serial generation paths. |
agents/volks/codedirector/prompts.py |
CodeDirector system prompt + constants (tool usage for file creation, search, shell). |
agents/volks/codedirector/review.py |
Self-review loop and fix-cycle helpers. |
agents/volks/codedirector/review_checks.py |
Deterministic AST/regex code-review checks replacing 13 LLM checklist items. |
agents/volks/codedirector/scaffold/generator.py |
Generates project skeleton from parsed design output (generate_skeleton). |
agents/volks/codedirector/scaffold/parser.py |
Parses architect design output into structured specs. |
agents/volks/codedirector/scaffold/types.py |
Scaffold data structures (ClassSpec, …). |
agents/volks/compliance/volk.py |
ComplianceVolk (U:Cp) — deterministic (no LLM) design-vs-code checking and RTM generation from @traces. |
agents/volks/compliance/_pipeline.py |
Standalone KG pipeline helpers for ComplianceVolk. |
agents/volks/concierge/volk.py |
ConciergeVolk (U:Cx) — user-facing entry volk with real LLM brain. |
agents/volks/documentor/volk.py |
DocumentorVolk (U:Do) — reads code/docs and produces or updates documentation files. |
agents/volks/documentor/prompts.py |
Documentor system prompt. |
agents/volks/junior/volk.py |
JuniorVolk (J:Junior) — design review with blocking questions (max 3 cycles), then driver-backed code generation and dependency validation. |
agents/volks/pm/volk.py |
PMVolk (U:PM) — scope validation and effort estimation. |
agents/volks/_edit_review.py |
Deterministic checks for review_edit payloads (extract_edit_fields, parse_fragment, vacuous-assert, bare-except, relative-import and direct-driver-construction detectors); imported by the architect and CodeDirector volks. |
agents/volks/pm/budget.py |
PM budget enforcement and iteration metrics (PMConfig, BudgetTracker, BudgetEvent; SPEC-012 US-003..005): LLM-call, time and fix-cycle limits with one-shot warnings. |
agents/volks/pm/goal_registry.py |
Goal Registry — portfolio goal lifecycle (create/activate/progress/complete/block/defer/cancel). |
agents/volks/pm/goal_report.py |
Goal Completion Report generator — markdown reports vs. success criteria. |
agents/volks/qa/volk.py |
QaVolk (U:Qa) — LLM-driven test generation and code review. |
agents/volks/qa/_autofix.py |
Source autofix routines (redis/imports/formatting) mixin. |
agents/volks/qa/_context.py |
Failure analysis and escalating-context construction mixin. |
agents/volks/qa/_dep_install.py |
Virtualenv / dependency-install / import-validation helpers mixin. |
agents/volks/qa/_testgen.py |
Test extraction, mock-validation, and pytest execution mixin. |
agents/volks/qa/_host.py |
Typing-only host contract Protocol tying the QA mixins together. |
agents/volks/senior_dev/agent.py |
SeniorDevAgent (U:SD) — oscillation recovery: reads recent iteration conversations, identifies root cause, rewrites the Concierge prompt with constraints. |
agents/volks/ux/volk.py |
UXVolk (U:Ux) — UI design artifacts. |
Per-volk __init__.py files |
Package inits / re-exports for analyst, architect, codedirector (+scaffold), compliance, concierge, documentor, junior, pm, qa, senior_dev, ux. |
The runtime core — types.py, runtime.py, pool.py, task_executor.py
Everything else in the package speaks the vocabulary defined in types.py: TaskDefinition and TaskResult describe the task lifecycle, VolkInstance tracks a live agent, and PoolConfig/PoolStatus/ConsensusResult plus the TaskStatus/InstanceStatus/CoordinationPattern enums round out the model. VolkRuntime in runtime.py is the component that actually spawns and terminates instances — each spawn passes a Prolog governance check and lands its state in Redis. VolkPool sits on top, maintaining per-alias pools with min/max limits, auto-scaling, idle timeouts, and load-aware selection, so callers never touch raw instances. TaskExecutor is the seam where a task meets an agent: it asks the Prolog bridge whether the assignment is permitted, acquires an instance from the pool, tracks execution, and collects the result — converting the TaskDefinition into a CXPPacket along the way. AgentRuntime and AgentPool survive as compatibility aliases.
Coordination and governance — coordinator.py and prolog_bridge.py
When one volk is not enough, VolkCoordinator composes many of them on top of TaskExecutor, implementing the multi-volk patterns — leader election, consensus, fan-out, and pipeline. None of these decisions are made in Python alone: MultiagentPrologBridge exposes the multiagent.pl rule set (lifecycle governance, task assignment, coordination patterns, health monitoring, recovery) so the runtime's who-may-do-what questions are answered by the same logic-programming governance layer the rest of Orchestrata uses. The dependency diagram makes this visible — runtime, pool, task_executor, coordinator, hierarchy, communication, escalation, and constraints all import prolog_bridge.
The agent brain — volks/base.py and tool_registry.py
BaseAgent is the Pydantic base class every volk inherits, and it carries the shared machinery: identity and validation, serialization, the team-persona preamble from persona.py, run-scoped memory recall via memory_context.py, and the LLM call paths. The most interesting of those is _call_llm_with_tools(), which runs the function-calling loop: tool_registry.py supplies the OpenAI/DeepSeek tool schemas and a thread-safe executor mapping tool names to sandboxed Python functions — file operations, Mermaid validation, governed web research, and cloud design-pattern lookups. Because both the schemas and the execution live here, adding a capability to every volk means editing one module, not eleven.
The volk team — volks/
The concrete agents form Orchestrata's delivery pipeline: Concierge (U:Cx) receives the user, Analyst (U:BA) turns intent into user stories and requirements, PM (U:PM) validates scope and estimates effort (and owns the goal registry and completion reports), UX (U:Ux) produces UI design artifacts, Architect (U:Ar) writes the design with KG-backed context, CodeDirector (U:Cd) turns design into code — delegating to Junior volks over CXP and choosing among skeleton, serial, and swarm generation paths — QA (U:Qa) generates and runs tests with autofix and dependency-install mixins, Compliance (U:Cp) does deterministic design-vs-code checking and RTM generation from @traces with no LLM at all, and Documentor (U:Do) writes the docs. Senior Dev (U:SD) is the escape hatch: when the pipeline oscillates, it reads recent iteration conversations, identifies the root cause, and rewrites the Concierge prompt with constraints. The class diagram shows the shape clearly — one BaseAgent trunk, with QaVolk assembled from four capability mixins and ArchitectVolk from its context and project mixins.
Parallel code generation — swarm/coordinator.py
SwarmCoordinator is CodeDirector's throughput lever: it fans N source files out across N concurrent asyncio tasks, each running an async codegen driver in an isolated temporary workspace, then atomically merges the results back into the project. Per-file outcomes come back as ShardResults, so a single failed shard degrades gracefully instead of poisoning the batch.
The live CXP service — kernel_handler.py and runtime_main.py
For the out-of-process deployment, runtime_main.py is the entry point of the agent-runtime service speaking the CXP protocol (the cxpt direct transport since 2026-08-07; the section was headed "gRPC" while grpcio was in use). Its per-packet handler is constructed by build_kernel_packet_handler() in kernel_handler.py, which boots a kernel PipelineRunner wired with all the volks — so a CXP packet arriving over the wire flows straight into the same volk engine that the in-process pipeline uses.
Class map (generated)
Generated from the live source AST by scripts/gen-module-class-diagrams.py — do not hand-edit. Abstract classes have a green border; members listed are those defined on the class itself (inherited members excluded). Solid empty-triangle arrows = in-package inheritance; dashed arrows into dashed boxes = external/stdlib/cross-package bases; filled diamond = composition (constructed in __init__); open diamond = aggregation (annotated/injected reference); diamond edge labels name the owning attribute.