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.
Support output_type as alias for output in Pipe definition
Louis Choquela2f242908c2b
diff --git a/pipelex/builder/operations/pipe_ops.py b/pipelex/builder/operations/pipe_ops.pyindex cc3c3104f..200045689 100644--- a/pipelex/builder/operations/pipe_ops.py+++ b/pipelex/builder/operations/pipe_ops.py@@ -28,8 +28,8 @@ from pipelex.builder.pipe.pipe_spec_map import pipe_type_to_spec_class# Aliases that agents may use instead of "pipe_code". First found is promoted when canonical key is absent; extras are dropped._PIPE_CODE_ALIASES = ("pipe", "the_pipe_code", "code", "name", "pipe_name", "pipe_ref")-# Alias that agents may use instead of "output".-_OUTPUT_ALIAS = "output_concept"+# Aliases that agents may use instead of "output". First found is promoted when canonical key is absent; extras are dropped.+_OUTPUT_ALIASES = ("output_concept", "output_type")def _normalize_sub_pipe_dict(data: dict[str, Any]) -> None:@@ -110,17 +110,23 @@ def parse_pipe_spec(pipe_type: str, spec_data: dict[str, Any]) -> PipeSpec:else:spec_data.pop("expression")- # Accept "output_concept" as an alias for "output".- # When both "output" and the alias coexist, try the alias value first (agents often put+ # Accept output aliases (e.g. "output_concept", "output_type") for "output".+ # When both "output" and an alias coexist, try the alias value first (agents often put# the correct concept name in the alias), falling back to the original "output" value.output_fallback: Any | None = None- if _OUTPUT_ALIAS in spec_data:- alias_value = spec_data.pop(_OUTPUT_ALIAS)+ for output_alias in _OUTPUT_ALIASES:+ if output_alias not in spec_data:+ continue+ alias_value = spec_data.pop(output_alias)if "output" not in spec_data:spec_data["output"] = alias_valueelse:output_fallback = spec_data["output"]spec_data["output"] = alias_value+ # First alias wins — drop any remaining aliases without using them.+ for remaining_alias in _OUTPUT_ALIASES:+ spec_data.pop(remaining_alias, None)+ break# Accept output as dict → extract the concept string# Agents sometimes structure the output like inputs (as a dict).diff --git a/tests/unit/pipelex/builder/operations/test_parse_pipe_spec.py b/tests/unit/pipelex/builder/operations/test_parse_pipe_spec.pyindex 279fe9bd4..07cc61a11 100644--- a/tests/unit/pipelex/builder/operations/test_parse_pipe_spec.py+++ b/tests/unit/pipelex/builder/operations/test_parse_pipe_spec.py@@ -88,6 +88,31 @@ class TestParsePipeSpec:result = parse_pipe_spec("PipeLLM", {**_BASE_LLM, "output": {"type": "Article", "extra": "ignored"}})assert result.output == "Article"+ # -- output field aliases -----------------------------------------------++ @pytest.mark.parametrize("alias", ["output_concept", "output_type"])+ def test_output_alias_accepted(self, alias: str) -> None:+ """Each output alias resolves to the correct output value."""+ spec = {key: val for key, val in _BASE_LLM.items() if key != "output"}+ spec[alias] = "Article"+ result = parse_pipe_spec("PipeLLM", spec)+ assert result.output == "Article"++ @pytest.mark.parametrize("alias", ["output_concept", "output_type"])+ def test_output_alias_tried_first_when_canonical_present(self, alias: str) -> None:+ """When both output and an alias exist, alias value is tried first."""+ spec = {**_BASE_LLM, alias: "AliasValue"}+ result = parse_pipe_spec("PipeLLM", spec)+ assert result.output == "AliasValue"++ def test_first_output_alias_wins(self) -> None:+ """When multiple output aliases present without canonical, first in tuple order wins."""+ spec = {key: val for key, val in _BASE_LLM.items() if key != "output"}+ spec["output_type"] = "SecondAlias"+ spec["output_concept"] = "FirstAlias"+ result = parse_pipe_spec("PipeLLM", spec)+ assert result.output == "FirstAlias"+# -- steps/branches 'pipe' → 'pipe_code' alias -----------------------def test_sequence_steps_canonical_pipe_code(self) -> None: