You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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"}
importasynciofrompydanticimportBaseModelfromagentsimportAgent, ModelSettings, Runner, function_tool, set_tracing_disabledfromagents.extensions.models.litellm_modelimportLitellmModelfromopenai.types.sharedimportReasoningset_tracing_disabled(disabled=True)
@function_tooldefget_weather(city: str) ->str:
"""Get the current weather for a city."""returnf"The weather in {city} is sunny, 22°C"asyncdefreproduce_bug():
bedrock_model=LitellmModel(
model="bedrock/us.anthropic.claude-sonnet-4-20250514-v1:0",
)
# This combination failsagent_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 BadRequestErrorresult=awaitRunner.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_settingsinstructions="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.
Message Restructuring: Potentially restructure how messages are formatted for Bedrock when reasoning is enabled to comply with the required format
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.
The text was updated successfully, but these errors were encountered:
Bug Report: Reasoning Mode Incompatible with Tools on Bedrock Claude via LiteLLM
Please read this first
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 aBadRequestError
from Bedrock about incorrect message structure.Error Message:
Debug information
bedrock/us.anthropic.claude-sonnet-4-20250514-v1:0
Repro steps
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
Option 2: Use tools without reasoning
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.
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.
The text was updated successfully, but these errors were encountered: