2.26.5.38. pycsamt.agents.master#

One-line front door to the pyCSAMT agent stack.

AgentMaster is the programmatic master router: one object, one run() call from a plain-language request to the right specialist agent. run() first classifies the request with IntentRouter — the same classifier the desktop app uses — and dispatches question requests to PackageQAAgent, code requests to CodeGenerationAgent, metrics requests to MetricsAgent, and workflow/plot requests to WorkflowOrchestratorAgent. So the friendly entry point advertised across the docs works verbatim:

from pycsamt.agents import AgentMaster

master = AgentMaster(provider="anthropic")
report = master.run(
    "Load data/edi/, flag stations with RMS > 2, build an Occam2D "
    "input for profile L22, launch inversion, and produce a PDF report."
)

Everything heavier (the orchestrator, LLM clients) is imported lazily on first use, so from pycsamt.agents import AgentMaster stays cheap and free of circular imports.

Classes

AgentMaster([provider, api_key, model, ...])

Plain-language entry point to the agent workflows.

class pycsamt.agents.master.AgentMaster(provider='claude', *, api_key=None, model=None, default_workflow='qc')[source]

Bases: PyCSAMTObject

Plain-language entry point to the agent workflows.

Parameters:
  • provider (str, default "claude") – LLM provider. Friendly aliases are accepted: "anthropic""claude" and "google""gemini". Without an API key the agents fall back to the rule-based (regex/keyword) path, so AgentMaster() works offline.

  • api_key (str, optional) – Provider API key. When omitted, the provider’s environment variable is used if set; otherwise the rule-based fallback runs at zero cost.

  • model (str, optional) – Provider model override (defaults per provider).

  • default_workflow (str, default "qc") – Workflow used when a request cannot be classified.

Examples

Plan first (no files touched), then execute:

>>> from pycsamt.agents import AgentMaster
>>> master = AgentMaster(provider="anthropic")
>>> plan = master.plan(
...     "QC the EDI files and prepare a short report",
...     data_path="data/edi/",
... )
>>> plan["workflow_type"]
'qc'
>>> report = master.run(
...     "Load data/edi/, flag stations with RMS > 2, build an Occam2D "
...     "input for profile L22, launch inversion, and produce a PDF "
...     "report."
... )

See also

pycsamt.agents.WorkflowOrchestratorAgent

The dispatcher this façade drives; use it directly for structured workflow configurations.

property orchestrator: WorkflowOrchestratorAgent[source]

The lazily-built orchestrator behind this façade.

run(request, *, data_path=None, output_dir=None, dry_run=False, **extra)[source]

Route request to the right specialist agent and run it.

request is first classified by IntentRouter — a question is answered by PackageQAAgent, a code request generates a script via CodeGenerationAgent, a metrics request is computed by MetricsAgent, and a workflow / plot request runs the full pipeline through WorkflowOrchestratorAgent. A meta (capability) or clarify (ambiguous) request returns immediately with no data path required.

Parameters:
  • request (str) – Plain-language description of what to do. Paths mentioned in the text are extracted when possible; pass data_path / output_dir explicitly for scripts and CI.

  • data_path (str, optional) – Survey input (EDI/AVG/J directory or file).

  • output_dir (str, optional) – Where products (figures, inputs, reports) are written.

  • dry_run (bool, default False) – For workflow / plot requests only: preview the selected chain without reading or writing. Ignored for questions, code, metrics, meta, and clarify requests, which never touch disk regardless.

  • **extra – Additional orchestrator payload fields, passed through for workflow / plot requests only.

Returns:

Status, per-step outputs, reasoning, and cost tracking.

Return type:

AgentResult

plan(request, **kwargs)[source]

Shortcut for run() with dry_run=True.

Parameters:
  • request (str)

  • kwargs (Any)

Return type:

AgentResult