AWS Bedrock Claude Adaptive Thinking
Configure Claude 4.6 adaptive thinking with effort levels on AWS Bedrock.
Cookbook example demonstrating adaptive thinking with output_config on AWS Bedrock.
The source's dated Sonnet 4.6 ID is not the published Bedrock model ID. Before running, replace it with us.anthropic.claude-sonnet-4-6 and use a supported source region. See the AWS Sonnet 4.6 model card.
"""
AWS Bedrock Claude Adaptive Thinking
====================================
Cookbook example demonstrating adaptive thinking with output_config on AWS Bedrock.
For Claude 4.6 Bedrock models, use adaptive thinking with the effort parameter
to control thinking depth. Valid effort values:
- "low": Most efficient, significant token savings
- "medium": Balanced approach with moderate savings
- "high": Default, high capability for complex reasoning
- "max": Absolute maximum capability (Opus 4.6 only)
Prerequisites:
- Set AWS credentials via environment variables or boto3 session
- Ensure you have access to Claude 4.6 models in your AWS region
"""
from agno.agent import Agent
from agno.models.aws import Claude
# ---------------------------------------------------------------------------
# Create Agent with Adaptive Thinking
# ---------------------------------------------------------------------------
agent = Agent(
model=Claude(
id="anthropic.claude-sonnet-4-6-20250514-v1:0",
max_tokens=4096,
thinking={"type": "adaptive"},
output_config={"effort": "high"},
),
markdown=True,
)
# ---------------------------------------------------------------------------
# Run Agent
# ---------------------------------------------------------------------------
if __name__ == "__main__":
# Complex reasoning task that benefits from extended thinking
agent.print_response(
"Explain the key differences between recursion and iteration, "
"and when you would choose one over the other in software development."
)
# With streaming
agent.print_response(
"What are the trade-offs between microservices and monolithic architectures?",
stream=True,
)Run the Example
Set up your virtual environment
uv venv --python 3.12
source .venv/bin/activateInstall dependencies
uv pip install -U agno "anthropic[bedrock]" aioboto3 boto3Configure AWS access
Select a source region that supports the model or inference profile in the example. A geographic profile such as us. routes across the source and destination regions listed for that profile; a global. profile can route globally. Verify the model's regional availability and your IAM permission to invoke it. For Anthropic models, complete the account's first-use model access requirements.
export AWS_REGION="us-east-1"
export AWS_ACCESS_KEY_ID="your_aws_access_key_id"
export AWS_SECRET_ACCESS_KEY="your_aws_secret_access_key"
# Required when using temporary credentials:
# export AWS_SESSION_TOKEN="your_aws_session_token"Use credentials and any session token from the same session. Change AWS_REGION if you choose another supported source region. These examples use AWS credentials; agno.models.aws.Claude does not accept an Anthropic API key or a Bedrock API key in place of them.
Run the example
Save the code above as adaptive_thinking.py. Replace anthropic.claude-sonnet-4-6-20250514-v1:0 with us.anthropic.claude-sonnet-4-6, then run:
python adaptive_thinking.pyFull source: cookbook/90_models/aws/claude/adaptive_thinking.py