Build AI methods with your coding agent, then run them anywhere: as an MCP for chatbots, as a webapp for people, or via API for your software.
Silently drop extraneous 'inputs' field from sequence steps and parallel branches
Louis Choquel942b8de2f017
diff --git a/pipelex/builder/operations/pipe_ops.py b/pipelex/builder/operations/pipe_ops.pyindex 8c3497658..d307cab97 100644--- a/pipelex/builder/operations/pipe_ops.py+++ b/pipelex/builder/operations/pipe_ops.py@@ -27,6 +27,13 @@ from pipelex.builder.pipe.pipe_spec_map import pipe_type_to_spec_class_PIPE_CODE_ALIASES = ("pipe", "the_pipe_code", "code", "name", "pipe_name", "pipe_ref")+def _normalize_sub_pipe_dict(data: dict[str, Any]) -> None:+ """Normalize a step/branch dict: resolve pipe_code aliases and drop extraneous fields."""+ _normalize_pipe_code_aliases(data)+ # Agents sometimes add "inputs" to individual steps; silently drop it.+ data.pop("inputs", None)++def _normalize_pipe_code_aliases(data: dict[str, Any]) -> None:"""Convert any alias of ``pipe_code`` to the canonical field name, in-place."""for alias in _PIPE_CODE_ALIASES:@@ -67,13 +74,13 @@ def parse_pipe_spec(pipe_type: str, spec_data: dict[str, Any]) -> PipeSpec:# Accept common aliases for "pipe_code" at the top level_normalize_pipe_code_aliases(spec_data)- # Handle steps/branches conversion — apply the same alias normalization- # Deep-copy nested dicts to avoid mutating caller's nested structures+ # Handle steps/branches conversion — normalize aliases and drop unknown fields.+ # Deep-copy nested dicts to avoid mutating caller's nested structures.if "steps" in spec_data:converted_steps = []for step in spec_data["steps"]:step = dict(step)- _normalize_pipe_code_aliases(step)+ _normalize_sub_pipe_dict(step)converted_steps.append(step)spec_data["steps"] = converted_steps@@ -81,7 +88,7 @@ def parse_pipe_spec(pipe_type: str, spec_data: dict[str, Any]) -> PipeSpec:converted_branches = []for branch in spec_data["branches"]:branch = dict(branch)- _normalize_pipe_code_aliases(branch)+ _normalize_sub_pipe_dict(branch)converted_branches.append(branch)spec_data["branches"] = converted_branchesdiff --git a/tests/unit/pipelex/builder/operations/test_parse_pipe_spec.py b/tests/unit/pipelex/builder/operations/test_parse_pipe_spec.pyindex f88b5cf14..57509be3d 100644--- a/tests/unit/pipelex/builder/operations/test_parse_pipe_spec.py+++ b/tests/unit/pipelex/builder/operations/test_parse_pipe_spec.py@@ -172,6 +172,41 @@ class TestParsePipeSpec:assert result.branches[0].pipe_code == "branch_a"assert result.branches[1].pipe_code == "branch_b"+ # -- extraneous "inputs" in steps/branches silently dropped -----------++ def test_sequence_steps_extraneous_inputs_dropped(self) -> None:+ """Agents sometimes add 'inputs' to individual steps; these should be silently ignored."""+ spec: dict[str, Any] = {+ "pipe_code": "interview_prep",+ "description": "Analyze CV-job match",+ "inputs": {"cv": "Document", "job_offer": "Document"},+ "output": "Text",+ "steps": [+ {"pipe": "extract_cv", "inputs": {"cv": "cv"}, "result": "cv_pages"},+ {"pipe": "extract_job_offer", "inputs": {"job_offer": "job_offer"}, "result": "job_offer_pages"},+ {"pipe": "analyze_match", "result": "match_analysis"},+ ],+ }+ result = parse_pipe_spec("PipeSequence", spec)+ assert isinstance(result, PipeSequenceSpec)+ assert result.steps[0].pipe_code == "extract_cv"+ assert result.steps[1].pipe_code == "extract_job_offer"++ def test_parallel_branches_extraneous_inputs_dropped(self) -> None:+ spec: dict[str, Any] = {+ "pipe_code": "my_par",+ "description": "Parallel branches",+ "inputs": {"doc": "Document"},+ "output": "Text",+ "add_each_output": True,+ "branches": [+ {"pipe": "branch_a", "inputs": {"doc": "doc"}, "result": "result_a"},+ ],+ }+ result = parse_pipe_spec("PipeParallel", spec)+ assert isinstance(result, PipeParallelSpec)+ assert result.branches[0].pipe_code == "branch_a"+# -- PipeCondition expression alias -----------------------------------_BASE_CONDITION: ClassVar[dict[str, Any]] = {