Skip to content

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

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

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.
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

2 participants