Expand description
Multi-agent coordination for Common Agent Runtime.
Provides six coordination patterns:
| Pattern | Description |
|---|---|
| Swarm | N agents on the same problem (parallel, sequential, or debate) |
| Pipeline | Linear chain — each agent’s output feeds the next |
| Supervisor | One agent reviews workers, iterates until approval |
| Delegator | Main agent spawns specialists mid-run via a tool |
| MapReduce | Fan-out to N mappers, reduce into a single result |
| Vote | N agents answer independently, majority wins |
§How agents communicate
Agents communicate through three mechanisms:
-
Shared state — all agents in a coordination group share the same
Arc<StateStore>andArc<EventLog>viaSharedInfra. Agents can read each other’s state writes. -
Task enrichment — orchestrators pass prior agents’ outputs into the next agent’s task prompt (e.g., sequential swarm, supervisor feedback).
-
Mailbox — async channel-based messaging for real-time inter-agent communication during execution.
§The AgentRunner trait
Since the runtime doesn’t own the model, the caller implements AgentRunner
to drive the model loop. car-multi orchestrates when and how agents run;
the caller decides what each agent does.
ⓘ
use car_multi::{AgentRunner, AgentSpec, AgentOutput, Mailbox, MultiError};
use car_engine::Runtime;
struct MyRunner { /* OpenAI client, etc. */ }
#[async_trait::async_trait]
impl AgentRunner for MyRunner {
async fn run(
&self,
spec: &AgentSpec,
task: &str,
runtime: &Runtime,
mailbox: &Mailbox,
) -> Result<AgentOutput, MultiError> {
// 1. Call your LLM with spec.system_prompt + task
// 2. Parse response into ActionProposal
// 3. runtime.execute(&proposal).await
// 4. Return AgentOutput
todo!()
}
}Re-exports§
pub use error::MultiError;pub use mailbox::Mailbox;pub use runner::AgentRunner;pub use types::AgentOutput;pub use types::AgentSpec;pub use types::Message;pub use types::MessageKind;pub use patterns::delegator::Delegator;pub use patterns::delegator::DelegatorResult;pub use patterns::map_reduce::MapReduce;pub use patterns::map_reduce::MapReduceResult;pub use patterns::pipeline::Pipeline;pub use patterns::pipeline::PipelineResult;pub use patterns::supervisor::Supervisor;pub use patterns::supervisor::SupervisorResult;pub use patterns::swarm::Swarm;pub use patterns::swarm::SwarmMode;pub use patterns::swarm::SwarmResult;pub use patterns::fleet::Fleet;pub use patterns::fleet::FleetResult;pub use patterns::vote::Vote;pub use patterns::vote::VoteResult;
Modules§
- error
- Error types for multi-agent coordination.
- mailbox
- Async channel-based mailbox for inter-agent messaging.
- patterns
- Coordination patterns for multi-agent systems.
- runner
- AgentRunner trait — the caller’s model loop abstraction.
- shared
- Shared infrastructure — creates Runtimes that share state, log, and policies.
- types
- Core types for multi-agent coordination.