Repository navigation
Conversation
The single-object fallback in _single_json_tool_call matched the call with
\{[^}]*"name"[^}]*"arguments"[^}]*\}. [^}]* stops at the first "}", which
closes "arguments" when it is an object, so json.loads failed and the tool
call was dropped.
Use the regex only to find where the object starts and let
json.JSONDecoder.raw_decode find where it ends. Malformed JSON still raises,
so the existing warning in _logged_single_json_tool_call is unchanged.
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.
Fixes #1068
_single_json_tool_callmatched the tool call with\{[^}]*"name"[^}]*"arguments"[^}]*\}.[^}]*stops at the first}, which closesargumentswhen it is an object, so the match was cut short,json.loadsfailed and the call was dropped.The regex now only finds where the object starts, and
json.JSONDecoder.raw_decodeparses from there to its real end, so object arguments (nested braces, braces inside strings) come through whole. Malformed JSON still raises, so the existing warning in_logged_single_json_tool_callis unchanged.Tests: parametrized cases for
_parse_system_prompt_tool_responsecovering the issue's inputs, nested arguments with a}in a string, and an object withoutarguments. The object-argument cases fail onmainand pass with this change. Format, lint, typecheck and cpd checks pass.