Repository navigation
Conversation
A tool call's `input` is model-produced JSON and need not be an object: a
custom tool's schema can be an array. `_execute` ran every input through
`dict()`, so a list was silently reinterpreted as a mapping (e.g.
`["SF"]` became `{"S": "F"}`) and the tool ran with corrupted arguments;
an input that is not a list of pairs raised out of the dispatch loop and
aborted the whole session run.
Pass an object input through as a copy and any other JSON as-is, so the
tool call reports the rejection as an error result like the Messages
runner does.
This branch has not been deployed
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.
What
SessionToolRunnercoerced every tool-call input withdict(ev.input). A tool call'sinputis model-produced JSON and need not be an object — a custom tool's schema can be an array. A list was silently reinterpreted as a mapping (["SF"]became{"S": "F"}), so the tool ran with corrupted arguments, and any input that is not a list of pairs raised out of the dispatch loop and aborted the whole session run.The runner now passes an object input through as a copy and passes any other JSON through unchanged, so the tool call reports the rejection as an ordinary error result, matching the Messages runner's behavior.
Why
Tool inputs come from the model, not from trusted typed code. Silently reinterpreting them changes what the tool receives, and a raised
TypeError/ValueErrorends the session instead of being reported back to the model as an error result the model can react to.How
_beta_session_runner.py:input_ = dict(ev.input) if is_dict(ev.input) else ev.input._tool_dispatch.py:run_runnable_toolnow acceptsobject, since the input is forwarded as-is.TypeError, which the runner already converts into an error result.Tests
Added
tests/lib/tools/test_session_runner.py::test_a_tool_call_whose_input_is_not_an_object_posts_an_error_and_the_runner_continues: a stream carries an array input followed by a valid object input; the first posts an error result and the second still succeeds, proving the dispatch loop keeps running.pytest tests/lib/tools/test_session_runner.py→ 73 passed.dict(["SF"])→{"S": "F"}) / aborted dispatch.Found while auditing the session runner against the Messages runner.