pycsamt.agents.pipeline_agent#
pycsamt.agents.pipeline_agent#
PipelineAgent — LLM-assisted MT processing pipeline selection and
interpretation.
Bridges pycsamt.pipeline with the agent framework:
Accepts a natural-language
"request"key → LLM recommends preset/stepsBuilds and runs the
PipelineLLM interprets the
PipelineResultas a narrative
Available presets: "basic_qc", "noise_reduction", "full_processing",
"tensor_analysis", "dimensionality_filter", "publication_ready".
Classes
|
LLM-assisted MT processing pipeline selection and interpretation. |
- class pycsamt.agents.pipeline_agent.PipelineAgent(*, api_key=None, model=None, llm_provider='claude', preset='basic_qc', param_overrides=None)[source]#
Bases:
BaseAgentLLM-assisted MT processing pipeline selection and interpretation.
Two modes of operation:
Guided mode — pass
"request"in input_data. The LLM recommends a preset and any parameter overrides, then the pipeline is built and run automatically.Direct mode — pass
"preset"(name string) or"steps"(list of step codes) in input_data. No pre-run LLM call is made; the pipeline is built directly from those instructions.In both modes the post-run LLM call interprets the
PipelineResultas a narrative.- Parameters:
api_key (str) – Standard LLM configuration inherited from
BaseAgent.model (str) – Standard LLM configuration inherited from
BaseAgent.llm_provider (str) – Standard LLM configuration inherited from
BaseAgent.preset (str, optional) – Default preset name used when input_data contains neither
"preset"nor"steps"nor"request". Defaults to"basic_qc"(safe first-pass).param_overrides (dict, optional) – Default parameter overrides applied on top of any preset or step list. Format:
{step_code: {param: value}}.keys (Output data)
----------
path (sites /) – Raw MT/AMT sites to process.
request (str, optional) – Natural-language description of dataset and goals. Triggers a pre-run LLM call that recommends preset + parameter overrides.
preset – Named preset — overrides constructor default.
steps (list of str, optional) – Explicit ordered list of step codes. Ignored when
"preset"is set.param_overrides – Per-step parameter overrides — merged on top of constructor defaults.
output_dir (str or None, optional) – Root directory for pipeline output files (EDI, plots, YAML config).
keys
----------------
agents (sites_out Processed Sites — ready for downstream)
:param
pipeline_resultPipelineResultobject: :parampreset_usedName of the preset that was run (or"custom"): :paramsteps_runList of step code strings that were executed: :paramn_sites_inNumber of input stations: :paramn_sites_outNumber of stations after processing: :paramn_errorsNumber of steps that raised an error: :paramrecommendationDict returned by LLM pre-run call (orNone):Examples
Guided mode:
agent = PipelineAgent() result = agent.execute({ "sites": sites, "request": "50 Hz grid noise, possible static shift, Occam2D target", "output_dir": "willy_pipeline/", }) processed = result["sites_out"] print(result.llm_interpretation)
Direct mode:
agent = PipelineAgent(preset="full_processing") result = agent.execute({ "sites": sites, "param_overrides": {"NR001": {"mains_hz": 60}}, })
Chain with
Occam2DAgentviaAgentCoordinator:from pycsamt.agents import AgentCoordinator, PipelineAgent, Occam2DAgent coord = AgentCoordinator("willy_full") coord.add_step("pipeline", PipelineAgent(preset="full_processing"), input_fn=lambda r: {"sites": r["load"].data["sites"]}) coord.add_step("invert", Occam2DAgent(), input_fn=lambda r: {"sites": r["pipeline"].data["sites_out"]})
- SYSTEM_PROMPT: str = 'You are an expert MT data processing specialist reviewing pipeline execution results.\nGiven a processing summary, write 3–4 sentences that:\n1. Describe the overall data quality change (stations retained, step errors if any).\n2. Highlight which steps were most impactful or took the most time.\n3. Comment on whether the stated processing objectives appear to have been met.\n4. Recommend a concrete follow-up action (further correction, QC plot review,\n or readiness for inversion).\nReply in plain English. No bullet points or markdown.\n'#
Override in subclasses to give the LLM its domain expertise.
- execute(input_data)[source]#
Run this agent on input_data and return an
AgentResult.Subclasses must implement this method. The contract:
Reset
self._last_cost = 0.0at the top.Record wall-clock time with
t0 = time.time().Return
AgentResult(elapsed_seconds=time.time()-t0, cost_estimate_usd=self._last_cost, ...).
- Parameters:
- Return type: