Skip to content

Unable to call tools when extended thinking enabled in Claude #3289

@lambda72453

Description

@lambda72453

** Please make sure you read the contribution guide and file the issues in the right place. **
Contribution guide.

Describe the bug
Im getting the following error when using claude sonnet on aws bedrock through litellm when thinking is enabled and a tool is called.

{"message":"The model returned the following errors: messages.3.content.0.type: Expected thinking or redacted_thinking, but found tool_use. When thinking is enabled, a final assistant message must start with a thinking block (preceeding the lastmost set of tool_use and tool_result blocks). We recommend you include thinking blocks from previous turns. To avoid this requirement, disable thinking. Please consult our documentation at https://docs.claude.com/en/docs/build-with-claude/extended-thinking"}

To Reproduce
Enable thinking with litellm. Add claude model (im using AWS bedrock). Add a tool and call it.

Example:
`def get_weather(city: str) -> dict:
"""Retrieves the current weather report for a specified city.

Args:
    city (str): The name of the city for which to retrieve the weather report.

Returns:
    dict: status and result or error msg.
"""
if city.lower() == "new york":
    return {
        "status": "success",
        "report": (
            "The weather in New York is sunny with a temperature of 25 degrees"
            " Celsius (77 degrees Fahrenheit)."
        ),
    }
else:
    return {
        "status": "error",
        "error_message": f"Weather information for '{city}' is not available.",
    }

root_agent = LlmAgent(
model=LiteLlm(model="bedrock/us.anthropic.claude-sonnet-4-5",
temperature=1,
thinking={"type": "enabled", "budget_tokens": 10000}),
#model="gemini-2.5-flash",
name='root_agent',
description='A helpful assistant for user questions.',
instruction='Answer user questions to the best of your knowledge',
tools=[get_weather]
)`

Expected behavior
A clear and concise description of what you expected to happen.

It should be abled to call tools without error when thinking is enabled.

Screenshots
If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

  • OS: mac
  • Python version(python -V): python 3:13
  • ADK version(pip show google-adk): 1.17.0

Model Information:

  • Are you using LiteLLM: Yes
  • Which model is being used(e.g. gemini-2.5-pro)
    Claude Sonnet 4.5 in Bedrock

Additional context
Tool calling does work when thinking is not enabled.

Metadata

Metadata

Labels

models[Component] Issues related to model support

Type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions