Skip to content

[Bedrock] Subagents default to US region instead of inheriting EU region causing API Error #307

@kingkrausel

Description

@kingkrausel

Reproduce:

import asyncio
import tempfile
from claude_agent_sdk import AgentDefinition, ClaudeAgentOptions, ClaudeSDKClient
from .config import settings

async def run() -> None:

    simple_test_agent = AgentDefinition(
        description="Simple test agent. Ask it to greet you.",
        prompt=f"""You are a simple test agent. Just greet the caller.""",
        tools=[],
        model="sonnet",
    )

    env = {
            "CLAUDE_CODE_USE_BEDROCK": "1",
            "AWS_REGION": "eu-central-1",
            "AWS_ACCESS_KEY_ID": settings.AWS_ACCESS_KEY_ID,
            "AWS_SECRET_ACCESS_KEY": settings.AWS_SECRET_ACCESS_KEY.get_secret_value(),
        }

    

    with tempfile.TemporaryDirectory() as _temp_dir:
        options = ClaudeAgentOptions(
            agents={"simple-test-agent": simple_test_agent},
            model="eu.anthropic.claude-sonnet-4-5-20250929-v1:0" ,
            system_prompt="You are a simple test agent running on AWS Bedrock in the eu.",
            cwd=_temp_dir,
            env=env,
            allowed_tools=["Read", "Edit", "Write", "Grep", "Glob"],
            permission_mode="acceptEdits",
        )
        async with ClaudeSDKClient(options) as client:
            await client.query("Just ask the simple test agent to greet you.")
            async for message in client.receive_response():
                print(message)

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

Error:

'API Error (us.anthropic.claude-sonnet-4-5-20250929-v1:0): 400 The provided model identifier is invalid.'

Complete output:

SystemMessage(subtype='init', data={'type': 'system', 'subtype': 'init', 'cwd': '/private/var/folders/_6/kdmc0m2x52l34v/T/tmp8yygaq0h', 'session_id': 'b22d2788-d6e8-468b-a936-e7414f1a351b', 'tools': ['Task', 'Bash', 'Glob', 'Grep', 'ExitPlanMode', 'Read', 'Edit', 'Write', 'NotebookEdit', 'WebFetch', 'TodoWrite', 'BashOutput', 'KillShell', 'Skill', 'SlashCommand'], 'mcp_servers': [], 'model': 'eu.anthropic.claude-sonnet-4-5-20250929-v1:0', 'permissionMode': 'acceptEdits', 'slash_commands': ['compact', 'context', 'cost', 'init', 'pr-comments', 'release-notes', 'todos', 'review', 'security-review'], 'apiKeySource': '/login managed key', 'claude_code_version': '2.0.32', 'output_style': 'default', 'agents': ['general-purpose', 'statusline-setup', 'Explore', 'Plan', 'simple-test-agent'], 'skills': [], 'plugins': [], 'uuid': '6c454d19-1c79-44d7-bbbf-33e4078aae4a'})
AssistantMessage(content=[TextBlock(text="I'll launch the simple test agent and ask it to greet me.")], model='claude-sonnet-4-5-20250929', parent_tool_use_id=None)
AssistantMessage(content=[ToolUseBlock(id='toolu_bdrk_01MHYaAGHMTdMQqtS9vXF6Q9', name='Task', input={'subagent_type': 'simple-test-agent', 'description': 'Request greeting from test agent', 'prompt': 'Please greet me!'})], model='claude-sonnet-4-5-20250929', parent_tool_use_id=None)
UserMessage(content=[TextBlock(text='Please greet me!')], parent_tool_use_id='toolu_bdrk_01MHYaAGHMTdMQqtS9vXF6Q9')
UserMessage(content=[ToolResultBlock(tool_use_id='toolu_bdrk_01MHYaAGHMTdMQqtS9vXF6Q9', content=[{'type': 'text', 'text': 'API Error (us.anthropic.claude-sonnet-4-5-20250929-v1:0): 400 The provided model identifier is invalid.'}], is_error=None)], parent_tool_use_id=None)
AssistantMessage(content=[TextBlock(text="It looks like there's a model configuration issue with the simple test agent. The agent is trying to use a model identifier that's not available in the current environment (AWS Bedrock EU region).\n\nThis appears to be a technical limitation - the simple test agent may be configured with a model that's not available in the eu region of AWS Bedrock where this instance is running.")], model='claude-sonnet-4-5-20250929', parent_tool_use_id=None)
ResultMessage(subtype='success', duration_ms=8748, duration_api_ms=8459, is_error=False, num_turns=2, session_id='b22d2788-d6e8-468b-a936-e7414f1a351b', total_cost_usd=0.002955, usage={'input_tokens': 10, 'cache_creation_input_tokens': 12591, 'cache_read_input_tokens': 12430, 'output_tokens': 197, 'server_tool_use': {'web_search_requests': 0, 'web_fetch_requests': 0}, 'service_tier': 'standard', 'cache_creation': {'ephemeral_1h_input_tokens': 0, 'ephemeral_5m_input_tokens': 0}}, result="It looks like there's a model configuration issue with the simple test agent. The agent is trying to use a model identifier that's not available in the current environment (AWS Bedrock EU region).\n\nThis appears to be a technical limitation - the simple test agent may be configured with a model that's not available in the eu region of AWS Bedrock where this instance is running.")

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions