Skip to content

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.

fix/Binding-step-kajson-round-trip · L-261006-079e24 (#1359)

Louis Choquelf73c1ec93ef3
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 4bfa50ae4..16a014d78 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -15,6 +15,7 @@
- **A model setting its model refuses is refused when the method loads (Breaking)**: a `PipeLLM` or `PipeStructure` whose model setting the model it resolves to cannot take, such as a reasoning setting on a model declaring `thinking_mode = "none"`, a reasoning budget on an OpenAI or Mistral model, a thinking budget its `max_tokens` cannot hold, or a structured output on a Bedrock native model, is refused by `pipelex validate`, `POST /v1/validate` and a run's load as an item of the new `PipeValidationErrorType` value `llm_setting_refused_by_model` on its `model` or `model_to_structure` field, where it validated as runnable and failed at its first call. The check is the new `check_request` classmethod of the LLM workers, which `LLMWorkerAbstract` now runs before every provider call and which an LLM backend registers for validation through the new optional `check_llm_request` of `PluginRegistrar.add_inference_backend`; a backend registering none, an external plugin's included, is held to the rule every worker shares, that a model declaring `thinking_mode = "none"` takes no reasoning setting. The item names the model by its deck handle and is shown even under strict error disclosure, so an external plugin's refusal is shown as written only when the plugin raises it as caller-facing copy with `as_caller_fault()`, and by its title otherwise.
- **A structured output on Google without a system prompt no longer fails**: a structured call on the `google` backend whose prompt has no system text failed with `TypeError` "generate_content() got an unexpected keyword argument 'system'", and is now sent with no system instruction.
- **A model listing `temperature_unsupported` gets no temperature on any SDK**: a model whose backend file lists the `temperature_unsupported` constraint is now called without a temperature on the OpenAI Responses, Google, Mistral and Bedrock-native SDKs too, where those sent one anyway and only the Anthropic and OpenAI chat-completions SDKs honoured the constraint. The model spec answers it as the new `accepts_temperature` property, and a Bedrock client's `chat` now takes `temperature=None` to send none.
+- **A binding step survives a kajson round trip**: `BindingStepBlueprint` is encoded under `from`, the key it validates, where kajson wrote its field name `from_path`, which decoding refused as an extra field. A library crate holding a sequence with a binding step can now cross a process boundary, so a run of such a method no longer fails to start on a Temporal worker with "Could not instantiate pydantic BaseModel … BindingStepBlueprint".
## [v0.76.0] - 2026-10-06
diff --git a/pipelex/pipe_controllers/binding/binding_step_blueprint.py b/pipelex/pipe_controllers/binding/binding_step_blueprint.py
index 1fb0e64aa..f447b33d6 100644
--- a/pipelex/pipe_controllers/binding/binding_step_blueprint.py
+++ b/pipelex/pipe_controllers/binding/binding_step_blueprint.py
@@ -115,6 +115,15 @@ class BindingStepBlueprint(BaseModel):
dumped: dict[str, Any] = handler(self)
return {(BINDING_FROM_KEY if key == "from_path" else key): value for key, value in dumped.items()}
+ def __json_encode__(self) -> dict[str, Any]: # ruff: ignore[bad-dunder-method-name] — kajson encoder hook, name fixed by kajson's protocol
+ """Kajson encoding hook: write the path under `from`, as every other dump does.
+
+ kajson encodes a model through its `__dict__`, under its field names, and never calls the serializer above,
+ so the library crate a run carries across a process boundary would hold `from_path`, which the decoder's
+ validation refuses as an extra field. A Temporal worker then cannot decode the run it was handed.
+ """
+ return self.model_dump()
+
@property
def root_name(self) -> str:
return self.from_path.split(".", maxsplit=1)[0]
diff --git a/tests/unit/pipelex/pipe_controllers/binding/test_binding_step_kajson.py b/tests/unit/pipelex/pipe_controllers/binding/test_binding_step_kajson.py
new file mode 100644
index 000000000..6a9766617
--- /dev/null
+++ b/tests/unit/pipelex/pipe_controllers/binding/test_binding_step_kajson.py
@@ -0,0 +1,51 @@
+import json
+
+from kajson import kajson
+
+from pipelex.pipe_controllers.binding.binding_step_blueprint import BINDING_FROM_KEY, BindingStepBlueprint
+from pipelex.pipe_controllers.sequence.pipe_sequence_blueprint import PipeSequenceBlueprint
+from pipelex.pipe_controllers.sub_pipe_blueprint import SubPipeBlueprint
+
+
+class TestBindingStepKajsonRoundtrip:
+ """A binding step crosses a process boundary inside the library crate a run carries, which kajson encodes.
+
+ kajson encodes a model through its ``__dict__``, under its field names, so the path would travel as
+ ``from_path``, which the blueprint refuses on the way back in. These tests pin the encoding to ``from``.
+ """
+
+ def test_binding_step_blueprint_roundtrips(self) -> None:
+ original = BindingStepBlueprint.model_validate({BINDING_FROM_KEY: "invoice.total", "result": "total_amount"})
+
+ serialized = kajson.dumps(original) # pyright: ignore[reportUnknownMemberType]
+ deserialized = kajson.loads(serialized) # pyright: ignore[reportUnknownMemberType]
+
+ assert isinstance(deserialized, BindingStepBlueprint)
+ assert deserialized == original
+
+ def test_binding_step_blueprint_is_encoded_under_from(self) -> None:
+ original = BindingStepBlueprint.model_validate({BINDING_FROM_KEY: "invoice.total", "result": "total_amount"})
+
+ encoded = json.loads(kajson.dumps(original)) # pyright: ignore[reportUnknownMemberType]
+
+ assert encoded[BINDING_FROM_KEY] == "invoice.total"
+ assert "from_path" not in encoded
+
+ def test_sequence_blueprint_with_a_binding_step_roundtrips(self) -> None:
+ original = PipeSequenceBlueprint(
+ description="Acknowledges an invoice by its total",
+ inputs={"invoice": "Invoice"},
+ output="Text",
+ steps=[
+ BindingStepBlueprint.model_validate({BINDING_FROM_KEY: "invoice.total", "result": "total_amount"}),
+ SubPipeBlueprint(pipe="write_receipt", result="receipt"),
+ ],
+ )
+
+ serialized = kajson.dumps(original) # pyright: ignore[reportUnknownMemberType]
+ deserialized = kajson.loads(serialized) # pyright: ignore[reportUnknownMemberType]
+
+ assert isinstance(deserialized, PipeSequenceBlueprint)
+ assert deserialized == original
+ assert isinstance(deserialized.steps[0], BindingStepBlueprint)
+ assert deserialized.steps[0].from_path == "invoice.total"