Expand description
§Coordination — programmatic agent fleet management
§Responsibility
Provide a complete agent coordination layer: define tasks in TOML, spawn agent processes, let them claim work atomically via filesystem locks, and monitor fleet health — all without manual terminal pane management.
§Architecture
tasks.toml ──► TaskQueue (file-locked claiming)
│
├──► AgentWorker 0 ──► claude process
├──► AgentWorker 1 ──► claude process
├──► AgentWorker N ──► claude process
│
AgentMonitor (health checks, status)§Modules
task— Task struct, TaskStatus, priority orderingconfig— CoordinationConfig with defaults and validationqueue— TaskQueue with file-locked concurrent claimingworker— AgentWorker: spawn claude process, capture outputspawner— AgentSpawner: spawn N agents, manage fleet lifecyclemonitor— AgentMonitor: health checks, fleet status snapshots
§Guarantees
- Atomic claiming: no task is ever executed twice (filesystem locks)
- Crash recovery: stale locks from dead agents are reclaimable
- Priority ordering: highest-priority tasks are claimed first
- Observable: fleet status available at any time via monitor snapshots
- Zero panics: all operations return
Result, never panic
§NOT Responsible For
- LLM inference (see:
workermodule at crate root) - Pipeline stages (see:
stagesmodule) - Web API (see:
web_apimodule)
§Example
use tokio_prompt_orchestrator::coordination::{
config::CoordinationConfig,
queue::TaskQueue,
spawner::{AgentSpawner, await_fleet},
};
use std::sync::Arc;
let config = Arc::new(CoordinationConfig::default());
let queue = Arc::new(TaskQueue::new(config.clone()).await?);
let spawner = AgentSpawner::new(config);
let handles = spawner.spawn_fleet(queue).await?;
let stats = await_fleet(handles).await;
for s in &stats {
println!("{}: {} completed, {} failed", s.agent_id, s.tasks_completed, s.tasks_failed);
}Modules§
- config
- CoordinationConfig — agent fleet configuration
- monitor
- AgentMonitor - fleet health monitoring
- queue
- TaskQueue — file-locked concurrent task claiming
- spawner
- AgentSpawner — fleet spawning and coordination
- task
- Task — coordination work unit
- worker
- AgentWorker — single agent process manager
Enums§
- Coordination
Error - Errors specific to the agent coordination layer.