Skip to content

Bug Report: Reasoning Mode Incompatible with Tools on Bedrock Claude via LiteLLM model class #810

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
AlejandroGarciaAWN opened this issue Jun 4, 2025 · 0 comments
Labels
bug Something isn't working

Comments

@AlejandroGarciaAWN
Copy link

Bug Report: Reasoning Mode Incompatible with Tools on Bedrock Claude via LiteLLM

Please read this first

  • Have you read the docs?Agents SDK docs
  • Have you searched for related issues? ✅ This appears to be an undocumented limitation

Describe the bug

When using the OpenAI Agents SDK with LiteLLM to access Claude models on AWS Bedrock, enabling reasoning mode (ModelSettings(reasoning=Reasoning(effort="low"))) is incompatible with using tools. The combination results in a BadRequestError from Bedrock about incorrect message structure.

Error Message:

litellm.exceptions.BadRequestError: BedrockException - {"message":"The model returned the following errors: messages.1.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.anthropic.com/en/docs/build-with-claude/extended-thinking"}

Debug information

  • Agents SDK version: (latest)
  • Python version: Python 3.11.12
  • LiteLLM version: Latest
  • Model: bedrock/us.anthropic.claude-sonnet-4-20250514-v1:0

Repro steps

import asyncio
from pydantic import BaseModel
from agents import Agent, ModelSettings, Runner, function_tool, set_tracing_disabled
from agents.extensions.models.litellm_model import LitellmModel
from openai.types.shared import Reasoning

set_tracing_disabled(disabled=True)

@function_tool
def get_weather(city: str) -> str:
    """Get the current weather for a city."""
    return f"The weather in {city} is sunny, 22°C"

async def reproduce_bug():
    bedrock_model = LitellmModel(
        model="bedrock/us.anthropic.claude-sonnet-4-20250514-v1:0",
    )

    # This combination fails
    agent_with_reasoning_and_tools = Agent(
        name="Weather Agent",
        model=bedrock_model,
        model_settings=ModelSettings(
            reasoning=Reasoning(effort="low")  # ❌ Reasoning enabled
        ),
        instructions="You are a weather assistant.",
        tools=[get_weather],  # ❌ Tools also enabled
    )

    # This will throw BadRequestError
    result = await Runner.run(
        agent_with_reasoning_and_tools, 
        "What's the weather like in Tokyo?"
    )
    print(result.final_output)

if __name__ == "__main__":
    asyncio.run(reproduce_bug())

Expected behavior

The agent should be able to use both reasoning mode and tools simultaneously, or at minimum, provide a clear error message in the SDK documentation explaining this limitation.

Workarounds

Option 1: Use reasoning without tools

agent_reasoning_only = Agent(
    name="Weather Agent",
    model=bedrock_model,
    model_settings=ModelSettings(reasoning=Reasoning(effort="low")),
    instructions="Provide weather info using your reasoning capabilities.",
    # tools=[],  # No tools
)

Option 2: Use tools without reasoning

agent_tools_only = Agent(
    name="Weather Agent", 
    model=bedrock_model,
    # No reasoning in model_settings
    instructions="You are a weather assistant.",
    tools=[get_weather],
)

Root Cause

This appears to be a Bedrock-specific limitation where Claude's thinking mode requires specific message structure that conflicts with how the OpenAI Agents SDK structures tool calls. According to Anthropic's documentation, when thinking is enabled, assistant messages must start with thinking blocks before any tool usage blocks.

  1. Message Restructuring: Potentially restructure how messages are formatted for Bedrock when reasoning is enabled to comply with the required format
  2. Provider Detection: Detect when using Bedrock + reasoning and automatically disable one or the other with a warning

Impact

This affects users trying to build sophisticated agents that need both reasoning capabilities and tool access when using Claude models via Bedrock, forcing them to choose between the two features.

@AlejandroGarciaAWN AlejandroGarciaAWN added the bug Something isn't working label Jun 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant