Repository navigation
FIX: Reject non-object tool arguments before calling custom functions in OpenAIResponseTarget - #3519
Open
Lanre Shittu (Shizoqua) wants to merge 1 commit into
Conversation
… in OpenAIResponseTarget
Richard Lundeen (richlundeen)
approved these changes
Oct 25, 2026
Richard Lundeen (richlundeen)
left a comment
Contributor
There was a problem hiding this comment.
Looks good. Custom functions now use the same JSON-object argument check and error result as registered tools. Unknown function handling stays unchanged.
Reviewed with GitHub Copilot.
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.
Description
Fixes #3516.
_execute_call_section_asynconly checked that parsed tool arguments were a JSON object for registeredTools. Functions incustom_functionswere called with whateverjson.loadsreturned, so"null","[1, 2]"or"\"text\""reached them asNone, a list or a string, and a function readingargs["x"]crashed the whole send.The object check now runs before either kind of function is called. Custom functions get the same handling as tools: a
malformed_argumentsoutput the model can recover from, or aValueErrorwhenfail_on_missing_function=True. Unregistered names still returnfunction_not_found.Tests and Documentation
Added tests in
tests/unit/prompt_target/target/test_openai_response_target.py:null, a list and a string are returned asmalformed_argumentswithinvoked=False, and the custom function is never awaited.fail_on_missing_function=True, the same input raisesValueErrorand the custom function is never awaited.No docs or notebooks changed, so JupyText was not needed.