pycsamt.agents.coordinator#
pycsamt.agents.coordinator#
AgentCoordinator orchestrates multi-agent workflows:
Registers agents by name.
Executes ordered workflow steps with dependency tracking.
Checkpoints each step to disk so workflows can be resumed after failure.
Provides a
dry_run/previewmode that estimates cost and prints the execution plan without running any agents.Aggregates per-step costs into a workflow-level total.
Classes
|
Orchestrate a sequence of pycsamt agents as a named workflow. |
|
One step in an |
- class pycsamt.agents.coordinator.AgentCoordinator(workflow_name='pycsamt_workflow', *, checkpoint_dir=None, verbose=True)[source]#
Bases:
objectOrchestrate a sequence of pycsamt agents as a named workflow.
- Parameters:
Examples
Build and run a QC workflow:
from pycsamt.agents import AgentCoordinator, MTLoaderAgent, DataQCAgent coord = AgentCoordinator("mt_qc") coord.add_step("load", MTLoaderAgent(...)) coord.add_step("qc", DataQCAgent(...), input_fn=lambda r: {"sites": r["load"]["sites"]}) result = coord.execute({"path": "/data/EDIs"}) print(result.summary)
Dry-run preview:
result = coord.preview({"path": "/data/EDIs"}) print(result["plan"])
- add_step(name, agent, *, input_fn=None, description='', required=True)[source]#
Append a workflow step. Returns
selffor chaining.- Parameters:
- Returns:
selffor method chaining.- Return type:
- preview(config)[source]#
Return an execution plan and estimated cost without running anything.
- Parameters:
config (dict) – The workflow configuration that would be passed to
execute().- Returns:
data["plan"]contains the formatted plan string.data["steps"]is a list of step metadata dicts.- Return type:
- class pycsamt.agents.coordinator.WorkflowStep(name, agent, *, input_fn=None, description='', required=True)[source]#
Bases:
objectOne step in an
AgentCoordinatorworkflow.- Parameters:
name (str) – Unique identifier used for checkpointing and logging.
agent (BaseAgent) – The agent instance that runs this step.
input_fn (callable or None) –
input_fn(prev_results)→ dict fed toagent.execute(). WhenNonethe coordinator passes the raw workflow config.description (str) – Human-readable description shown in the dry-run preview.
required (bool) – When
Falsea failure skips the step rather than aborting.