Skip to content

fix: serialize non-standard FunctionResponse dicts in AnthropicLlm#4807

Open
giulio-leone wants to merge 1 commit intogoogle:mainfrom
giulio-leone:fix/anthropic-function-response-fallback
Open

fix: serialize non-standard FunctionResponse dicts in AnthropicLlm#4807
giulio-leone wants to merge 1 commit intogoogle:mainfrom
giulio-leone:fix/anthropic-function-response-fallback

Conversation

@giulio-leone
Copy link

Summary

Fixes #4779

part_to_message_block() only handled function_response dicts containing "content" or "result" keys. Any other dict structure (e.g. SkillToolset returning {"skill_name": ..., "instructions": ...}) fell through to an empty string, causing Claude to never see the tool output.

Changes

  • anthropic_llm.py: Added json.dumps() fallback after the existing "content" / "result" checks, so non-standard response dicts are serialized to JSON text instead of being silently dropped.
  • test_anthropic_llm.py: Added regression test verifying that a SkillToolset-style response dict is round-tripped correctly through part_to_message_block().

Testing

  • All 18 test_anthropic_llm.py tests pass (including the new one)
  • Full unit test suite: 4623 passed, 0 regressions

@gemini-code-assist
Copy link
Contributor

Warning

You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again!

@google-cla
Copy link

google-cla bot commented Mar 13, 2026

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@adk-bot adk-bot added the models [Component] Issues related to model support label Mar 13, 2026
@rohityan
Copy link
Collaborator

Hi @giulio-leone , Thank you for your contribution! It appears you haven't yet signed the Contributor License Agreement (CLA). Please visit https://cla.developers.google.com/ to complete the signing process. Once the CLA is signed, we'll be able to proceed with the review of your PR. Thank you!

@rohityan rohityan self-assigned this Mar 13, 2026
@rohityan rohityan added the request clarification [Status] The maintainer need clarification or more information from the author label Mar 13, 2026
@giulio-leone giulio-leone force-pushed the fix/anthropic-function-response-fallback branch from db815f8 to 936a699 Compare March 14, 2026 19:29
@giulio-leone
Copy link
Author

Rebased onto latest main to resolve merge conflicts.

The upstream branch introduced improved json.dumps() serialization for standard result values (dict/list). I kept that improvement and preserved the fallback path for non-standard response dicts (e.g. SkillToolset returns) that was the purpose of this PR.

Both the upstream PDF document tests and this PR's non-standard response test are included.

@giulio-leone giulio-leone force-pushed the fix/anthropic-function-response-fallback branch from 936a699 to 31301a3 Compare March 14, 2026 20:08
@giulio-leone
Copy link
Author

@rohityan Thanks for the heads-up! I'll get the Google CLA signed. Will follow up once it's done.

@giulio-leone
Copy link
Author

I have signed the Google CLA. Could you please re-run the CLA check? Thank you!

@giulio-leone giulio-leone force-pushed the fix/anthropic-function-response-fallback branch from 31301a3 to 8adbe49 Compare March 15, 2026 15:56
Rebased onto latest main, resolved conflicts with upstream json.dumps improvement.
Keeps both upstream's json.dumps serialization for standard results AND the
fallback path for non-standard response dicts (e.g. SkillToolset).
@giulio-leone giulio-leone force-pushed the fix/anthropic-function-response-fallback branch from 8adbe49 to a931305 Compare March 15, 2026 16:03
@giulio-leone
Copy link
Author

Hi @rohityan — the CLA is now signed and passing ✅ (it was a Co-authored-by trailer issue that has been resolved). Ready for review!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

models [Component] Issues related to model support request clarification [Status] The maintainer need clarification or more information from the author

Projects

None yet

Development

Successfully merging this pull request may close these issues.

AnthropicLlm.part_to_message_block() drops non-standard FunctionResponse dicts (breaks SkillToolset with Claude)`

3 participants