fix(models): preserve string content in anthropic tool results#5373
fix(models): preserve string content in anthropic tool results#5373lawrence3699 wants to merge 2 commits intogoogle:mainfrom
Conversation
|
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. |
|
Response from ADK Triaging Agent Hello @lawrence3699, thank you for your contribution! It looks like the Contributor License Agreement (CLA) has not been signed. Please sign the CLA to proceed with the review process. You can find more information in the "cla/google" check at the bottom of the pull request. Thanks! |
|
Hi @lawrence3699 , 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! |
Please ensure you have read the contribution guide before creating a pull request.
Link to Issue or Description of Change
1. Link to an existing issue (if applicable):
Problem:
part_to_message_block()currently assumes everyfunction_response.response["content"]value is a list-like content payload.LoadSkillResourceToolreturns a plain string incontent, so Claude tool results get flattened character-by-character with newlines inserted.On current
main, this deterministic repro returns the wrong content:Solution:
Keep the existing list handling for Anthropic content blocks, but branch on the runtime type of
response["content"]:""): pass it through as a scalar stringThat preserves
LoadSkillResourceToolstring payloads without changing the existingcontentlist contract.Testing Plan
Unit Tests:
Passed
pytestresults:pytest tests/unittests/models/test_anthropic_llm.py -q43 passed, 1 warning in 1.38spytest tests/unittests/tools/test_skill_toolset.py -k 'load_resource_run_async' -q10 passed, 71 deselected, 2 warnings in 1.27sManual End-to-End (E2E) Tests:
Minimal local repro after the patch:
Console output:
Checklist
Additional context
I also checked upstream overlap before opening this PR:
#5364already has open PR#5366, so I did not touch that nearby schema bug.#5358or another in-flightpart_to_message_block()string-content fix.