Skip to content

refactor(ai): chat_structured is the one structured-output path - #2452

Merged
dan-petty merged 3 commits into
mainfrom
refactor/1003-structured-output-path
Oct 28, 2026
Merged

dan-petty merged 3 commits into
mainfrom
refactor/1003-structured-output-path

Conversation

@dan-petty

Copy link
Copy Markdown
Owner

Only chat_structured validates a model reply against a schema in production: roadmap intake, refine and research call it. It sends the schema, repairs the JSON, validates it and retries with a schema reflection. The two other paths that #1003 names had no production caller: no module gives a PydanticAgent an output type, an output schema or an output validator, and no production MultiAgentPipeline sets an output schema. The review builds no agent since the evidence-first redesign (#1137). This change makes chat_structured the one structured-output path by deleting the other two, and it builds no new module, because the owner's direction moves structured output to pydantic-ai (#1001, #1419, #1005).

  • PydanticAgent loses output_type, output_schema, output_json_schema, output_validator, the schema block of its system prompt and its output validation stage. ai/agents/runner.py loses the helpers that validated and reflected. AgentRetries keeps only tools, and AgentSpec and AgentInfo lose output_schema.
  • fix_llm_response loses its schema argument and its validation helpers, and FormattedLLMResponse loses the fields that only they set. ai/output/ is deleted.
  • MultiAgentPipeline loses output_schema, _parse_pipeline_output, final_data, parsed_data and its type parameter.
  • chat_structured uses build_schema_reflection_message from ai/schema_reflection.py, and its own copy is deleted. The message text does not change.
  • tests/invariants/test_source_tree.py fails when a module other than ai/client/structured.py and ai/schema_reflection.py builds a schema reflection. The swallowed-failure ceilings fall by 9.
  • No command, option or output changes. The change deletes 479 lines of source.

Closes #1003

Change: openspec/changes/archive/2026-10-28-1003-structured-output-path/

@dan-petty

dan-petty commented Oct 28, 2026 •

Copy link
Copy Markdown
Owner Author

Test evidence:

  • uv run devops ci fail-to-pass --base origin/main: 1 failed on base. tests/invariants/test_source_tree.py::test_one_path_validates_a_structured_reply_and_reflects_its_errors failed, because ai/agents/runner.py and ai/response_repair.py built schema reflections. 123 other tests in the 9 changed test files passed on base.
  • The 116 test targets that uv run devops test run --changed selects, run with pytest: 2,494 passed and 8 failed. The 8 were the pipeline tests that named the deleted type parameter. After the fix, tests/test_agent.py and tests/test_pipeline_context_budget.py pass (16 passed).
  • tests/test_swallowed_failures_ratchet.py, tests/test_architectural_invariants.py and tests/invariants/: pass.
  • uv run mypy over the 10 changed source files: no issues. Ruff and the commit hooks pass.
  • The first CI run failed the changed-line coverage gate: 4 of 21 changed lines were not covered (80%, the floor is 90%). They were the integer retries branches of PydanticAgent and the empty-pipeline returns of run_parallel and run_parallel_async, which the change rewrote. The commit test(ai): cover the integer retry budget and the empty pipeline that the change rewrote covers them through the public interface, and all 16 checks pass on the new head.
  • The re-scope and the decisions on the open questions are in the comment of 2026-10-28 on refactor(ai): one structured-output path for validate, repair, reflect and retry #1003.

Pending a person: review the diff in tuicr (tuicr -r origin/main..HEAD).

Only `chat_structured` validates a model reply against a schema in
production (roadmap intake, refine and research). The agent loop's
schema arm and the pipeline's second parse had no production caller:
no module gives a `PydanticAgent` an output type, output schema or
output validator, and no production pipeline sets an output schema.

- Delete the agent loop's schema arm: `output_type`, `output_schema`,
  `output_json_schema`, `output_validator`, the runner helpers that
  validated and reflected, `AgentRetries.output`, and the
  `output_schema` fields of `AgentSpec` and `AgentInfo`.
- Delete the schema arm of `fix_llm_response` and `ai/output/`.
- Delete `MultiAgentPipeline.output_schema`, `_parse_pipeline_output`,
  `final_data`, `parsed_data` and the pipeline's type parameter.
- `chat_structured` uses `build_schema_reflection_message`, and its
  own copy goes. The message text does not change.
- A new invariant test fails when another module builds a schema
  reflection.
- The swallowed-failure ceilings fall by 9.
@dan-petty
dan-petty force-pushed the refactor/1003-structured-output-path branch from 096273a to f051d38 Compare October 28, 2026 17:08
@dan-petty
dan-petty marked this pull request as ready for review October 28, 2026 17:16
@dan-petty
dan-petty merged commit 3509732 into main Oct 28, 2026
16 checks passed
@dan-petty
dan-petty deleted the refactor/1003-structured-output-path branch October 28, 2026 17:17
dan-petty pushed a commit that referenced this pull request Oct 28, 2026
🤖 I have created a release *beep* *boop*
---


##
[0.10.0](v0.9.0...v0.10.0)
(2026-10-28)


### Features

* **review:** devops review intake hands the findings of a session on
merged code to roadmap intake
([#2455](#2455))
([a5c7b82](a5c7b82))
* **security:** devops k8s audit runs Popeye in the tool sandbox with a
kube-api network profile that only reads the API server
([#2467](#2467))
([e02c3fb](e02c3fb))
* **security:** the App's installation tokens carry only the permissions
the roadmap jobs use
([#2482](#2482))
([9599ef2](9599ef2)),
closes [#2473](#2473)


### Bug Fixes

* **config:** a config file that is not valid YAML stops the load with
an error that quotes none of its text
([#2468](#2468))
([91fe5dc](91fe5dc))
* **config:** config set reports an unknown key as unknown, not as a key
that needs a value
([#2465](#2465))
([8b650a6](8b650a6))
* **devcontainer:** run the checkout's devops in devcontainer terminals
([#2460](#2460))
([abd2d41](abd2d41))
* **k8s:** loki runs from the grafana-community chart on loki 3.7.9, out
of reach of CVE-2026-21729
([#2470](#2470))
([96c50c9](96c50c9))
* **security:** a credential keyword at the end of a line no longer
masks the first word of the next line
([#2461](#2461))
([b754a73](b754a73))
* **security:** a credential value is masked also when the next line
starts with a parenthesis
([#2477](#2477))
([ece25ca](ece25ca)),
closes [#2471](#2471)
* **security:** pin kubeconform and replace Checkov with Trivy's
misconfiguration scan
([#2464](#2464))
([960e357](960e357))
* **security:** refuse GCONV_PATH, SHELLOPTS, BASHOPTS and PS4 from a
caller, and archive the merged security changes
([#2453](#2453))
([1f9231d](1f9231d))


### Code Refactoring

* **ai:** chat_structured is the one structured-output path
([#2452](#2452))
([3509732](3509732))
* **github:** pr check-readiness reads one merge-readiness verdict from
github/ ([#2456](#2456))
([16442c4](16442c4))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

Co-authored-by: dan-petty-release[bot] <346998822+dan-petty-release[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

refactor(ai): one structured-output path for validate, repair, reflect and retry

1 participant