Skip to content

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

Closed
giulio-leone wants to merge 2 commits intogoogle:mainfrom
giulio-leone:fix/anthropic-function-response-fallback
Closed

fix: serialize non-standard FunctionResponse dicts in AnthropicLlm#4997
giulio-leone wants to merge 2 commits intogoogle:mainfrom
giulio-leone:fix/anthropic-function-response-fallback

Conversation

@giulio-leone
Copy link
Copy Markdown

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

⚠️ This reopens #4807 which was accidentally closed due to fork deletion.

@adk-bot adk-bot added the models [Component] Issues related to model support label Mar 25, 2026
@rohityan rohityan self-assigned this Mar 26, 2026
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).
Move the non-standard FunctionResponse assertions back into the regression test that exercises the fallback serialization path, and keep the PDF document test focused on document serialization only.

Validated with pyink --check, the full anthropic_llm test file, and a runtime proof script covering both the fallback tool_result path and the PDF document path.
@giulio-leone giulio-leone force-pushed the fix/anthropic-function-response-fallback branch from bc87808 to 5ad3427 Compare March 30, 2026 21:35
@rohityan
Copy link
Copy Markdown
Collaborator

Hi @giulio-leone, Thank you for your contribution! We appreciate you taking the time to submit this pull request.
Closing this since the fix has already been merged in c26d359

@rohityan rohityan closed this Mar 31, 2026
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

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