Skip to content

fix(apigee): coerce non-object tool-call JSON args to empty dict - #7763

Closed
mangeshraut712 wants to merge 18 commits into
google:mainfrom
mangeshraut712:tip/apigee-non-object-tool-args
Closed

mangeshraut712 wants to merge 18 commits into
google:mainfrom
mangeshraut712:tip/apigee-non-object-tool-args

Conversation

@mangeshraut712

Copy link
Copy Markdown
Contributor

Summary

Chat Completions arguments that are valid JSON but not an object ([1,2], "x", 5, null) crashed the non-streamed path via dict(args) and became non-dict FunctionCall.args on the streamed path. Both paths now coerce through _coerce_tool_call_args.

Fixes #7740

Test plan

  • pytest tests/unittests/models/test_apigee_llm.py::test_chat_completions_non_object_tool_args_are_coerced_consistently

Chat Completions arguments that are valid JSON but not an object
(array/string/number/null) crashed the non-streamed path via dict()
and leaked non-dict FunctionCall.args on the streamed path. Both paths
now coerce consistently.

Fixes google#7740
@GWeale
GWeale self-requested a review November 24, 2026 01:06
@GWeale GWeale self-assigned this Nov 24, 2026
@GWeale

GWeale commented Nov 24, 2026

Copy link
Copy Markdown
Collaborator

ApigeeLlm now drops tool calls with non-object arguments and reports MALFORMED_FUNCTION_CALL so retry policies can recover instead of passing {} to the tool, fixed for #7740 on main in 7b07e7d. it's not in a release yet. thanks @mangeshraut712 for sending this in, closing as superseded, and please open a new issue if you still hit this on main.

@GWeale GWeale closed this Nov 24, 2026
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.

ApigeeLlm: tool call arguments that are valid JSON but not an object crash the non-streamed path and pass through as args when streamed

3 participants