馃敶 Required Information
Describe the Bug:
AnthropicLlm converts each Part in the conversation into an Anthropic content block. A part that carries only an empty text string (Part(text='')) matches none of the branches in _part_to_message_block (because if part.text: is false for '') and falls through to the final raise NotImplementedError("Not supported yet: ..."), which fails the whole model call with a misleading error.
ADK produces such parts itself: code_executors/code_execution_utils.py writes Part(text='') into the content when a code execution returns no output. The LiteLLM path (lite_llm.py) simply skips empty text parts, so the same conversation works via LiteLlm but fails via the native AnthropicLlm adapter.
Steps to Reproduce:
pip install google-adk anthropic
- Run the snippet under Minimal Reproduction Code
Expected Behavior:
Empty text parts are skipped (Anthropic rejects empty text blocks anyway), consistent with how the adapter already handles unsupported media parts in assistant turns (warn and skip) and with the LiteLLM path.
Observed Behavior:
File ".../google/adk/models/anthropic_llm.py", line 578, in _content_to_message_param
message_block.append(_part_to_message_block(part, sanitizer))
File ".../google/adk/models/anthropic_llm.py", line 557, in _part_to_message_block
raise NotImplementedError(f"Not supported yet: {part}")
NotImplementedError: Not supported yet: media_resolution=None code_execution_result=None executable_code=None file_data=None function_call=None function_response=None inline_data=None text='' thought=None thought_signature=None ...
Environment Details:
- ADK Library Version (pip show google-adk): 2.8.0
- Desktop OS: macOS (arm64)
- Python Version (python -V): 3.14.7
Model Information:
- Are you using LiteLLM: No (native
AnthropicLlm; the LiteLLM path is not affected)
- Which model is being used: N/A (reproduces in message conversion, no API call needed)
馃煛 Optional Information
Regression:
Unknown.
Logs:
See Observed Behavior above.
Screenshots / Video:
N/A
Additional Context:
PR incoming shortly (skip parts that carry nothing but empty text in _content_to_message_param, plus regression tests). Reported with AI assistance; reproduced and reviewed by me.
Minimal Reproduction Code:
from google.genai import types
from google.adk.models.anthropic_llm import content_to_message_param
content = types.Content(
role="user",
parts=[types.Part(text="run it"), types.Part(text="")],
)
print(content_to_message_param(content))
How often has this issue occurred?:
馃敶 Required Information
Describe the Bug:
AnthropicLlmconverts eachPartin the conversation into an Anthropic content block. A part that carries only an empty text string (Part(text='')) matches none of the branches in_part_to_message_block(becauseif part.text:is false for'') and falls through to the finalraise NotImplementedError("Not supported yet: ..."), which fails the whole model call with a misleading error.ADK produces such parts itself:
code_executors/code_execution_utils.pywritesPart(text='')into the content when a code execution returns no output. The LiteLLM path (lite_llm.py) simply skips empty text parts, so the same conversation works viaLiteLlmbut fails via the nativeAnthropicLlmadapter.Steps to Reproduce:
pip install google-adk anthropicExpected Behavior:
Empty text parts are skipped (Anthropic rejects empty text blocks anyway), consistent with how the adapter already handles unsupported media parts in assistant turns (warn and skip) and with the LiteLLM path.
Observed Behavior:
Environment Details:
Model Information:
AnthropicLlm; the LiteLLM path is not affected)馃煛 Optional Information
Regression:
Unknown.
Logs:
See Observed Behavior above.
Screenshots / Video:
N/A
Additional Context:
PR incoming shortly (skip parts that carry nothing but empty text in
_content_to_message_param, plus regression tests). Reported with AI assistance; reproduced and reviewed by me.Minimal Reproduction Code:
How often has this issue occurred?: