Skip to content

fix(openai): only unwrap bare {"result"} tool responses - #7847

Closed
ninglinLiu wants to merge 14 commits into
google:mainfrom
ninglinLiu:fix/7836-openai-responses-result-unwrap
Closed

ninglinLiu wants to merge 14 commits into
google:mainfrom
ninglinLiu:fix/7836-openai-responses-result-unwrap

Conversation

@ninglinLiu

Copy link
Copy Markdown
Contributor

Description

Fixes #7836

OpenAIResponsesLlm._serialize_json_value unwrapped any mapping that contained a non-None "result" key and sent only that value as function_call_output. ADK wraps a non-dict tool return as exactly {"result": value}, but a tool's own dict can also include a result key next to other fields (e.g. {"result": "found 2 contracts", "contracts": [...], "next_page_token": "abc"}), which was silently reduced to just the string.

Match AnthropicLlm (fixed in #7073): unwrap only when keys() == {"result"}.

Test plan

  • Unit tests for bare-wrapper unwrap and multi-key preservation
  • CI

This PR was prepared with AI assistance and reviewed/tested by the author.

OpenAIResponsesLlm._serialize_json_value unwrapped any mapping that
contained a non-None "result" key, dropping sibling fields. Match
AnthropicLlm: unwrap only when the keys are exactly {"result"}.

Fixes google#7836

This PR was prepared with AI assistance and reviewed/tested by the author.
@GWeale
GWeale self-requested a review November 4, 2026 18:40
@GWeale GWeale self-assigned this Nov 4, 2026
@GWeale

GWeale commented Nov 4, 2026

Copy link
Copy Markdown
Collaborator

thanks for putting together the fix and the tests, @ninglinLiu. #7837 landed the same change in 9c45214, so a tool output is only unwrapped when its keys are exactly {"result"}, and your two tests pass on main. since it's already on main (though not in a release yet), i'll go ahead and close this one. please open a new issue if you still run into this.

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

OpenAIResponsesLlm drops the keys beside "result" in a tool's dict return

3 participants