Skip to content

Fix schema being dropped on tool-call rounds in chains - #1825

Open
feiiiiii5 wants to merge 1 commit into
simonw:mainfrom
feiiiiii5:fix/chain-schema-tool-rounds
Open

feiiiiii5 wants to merge 1 commit into
simonw:mainfrom
feiiiiii5:fix/chain-schema-tool-rounds

Conversation

@feiiiiii5

Copy link
Copy Markdown
Contributor

Fixes the schema being applied only to the first request in a chain that uses tools. After a tool runs, the follow-up prompt is rebuilt without schema, so the final answer is no longer constrained and that response is logged without a schema_id.

ChainResponse, AsyncChainResponse and the resumed-chain path rebuild the prompt for the tool-result turn but only carried system, system_fragments and options. They now carry schema too.

Test: pytest tests/test_tools.py::test_chain_carries_schema_through_tool_rounds tests/test_tools.py::test_async_chain_carries_schema_through_tool_rounds tests/test_pause_resume.py::test_resumed_chain_keeps_the_schema fails on aebaca2 with assert [schema, None] == [schema, schema] and passes on this branch. Also ran pytest tests/test_tools.py tests/test_pause_resume.py (74 passed), plus black --check and ruff check on the touched files.

Details - `llm/models.py:2911` (`_resume_prompt`), `:2998` (sync chain loop) and `:3142` (async chain loop) rebuild the prompt and now pass `prompt.schema`. - `llm/default_plugins/openai_models.py` builds `response_format` / `text.format` from `prompt.schema`, so this applies to every provider that relies on the prompt. - No live API call was made; the tests use the mock model and assert the schema each round receives.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 26, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ⚠️ Failed 2026-10-26T06:44:32.439433Z
We couldn’t complete this review. Comment @codex review to try again.
f49eb2f PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

This branch has not been deployed

No deployments
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.

1 participant