fix(core): raise ValueError when explicit tool_outputs length mismatches tool_calls in tool_example_to_messages - #39142
Merged
ccurme (ccurme) merged 3 commits intoAug 11, 2026
Conversation
…calls in tool_example_to_messages
This comment has been minimized.
This comment has been minimized.
ccurme (ccurme)
approved these changes
Aug 11, 2026
Merging this PR will not alter performance
Comparing Footnotes
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #39138
When
tool_outputsis explicitly provided with a different length thantool_calls, the currentzip(..., strict=False)silently produces a malformed message history — tool calls missing a pairedToolMessage, or extra outputs quietly discarded. Added a length check that raises a descriptiveValueErrorbefore thezip. Behavior whentool_outputs=None(auto-generate placeholders) is unchanged.Release note
tool_example_to_messagesnow raisesValueErrorwith a clear message when an explicitly-suppliedtool_outputslist length does not match the number oftool_calls. Previously the mismatch was silently swallowed.Verified by running the two new regression tests locally — both directions (fewer and extra outputs) raise as expected, and the original
test_tool_outputsstill passes.