Bedrock: subagent model alias ignores ANTHROPIC_DEFAULT_SONNET_MODEL, forces invalid eu.<model> profile
What happens
On Amazon Bedrock, the main loop correctly runs Sonnet 5 via ANTHROPIC_DEFAULT_SONNET_MODEL pointing at a global.anthropic.claude-sonnet-5 inference profile. But spawning a subagent with model: sonnet (either in an agent definition's frontmatter or via the Agent/Task tool's model parameter) does not use that env var. Instead it constructs eu.anthropic.claude-sonnet-5, which the regional endpoint rejects:
API Error: 400 The provided model identifier is invalid..
Try /model to switch to eu.anthropic.claude-sonnet-4-6.
The subagent dies immediately (0 tokens, ~0.5s), so any agent with model: sonnet is effectively unusable — even though the identical model runs fine in the main loop.
Expected
Subagent sonnet/opus/haiku alias resolution should honor the same ANTHROPIC_DEFAULT_*_MODEL env vars (and the inference-profile region prefix) that the main loop uses — or at least not synthesize a region-prefixed profile ID (eu.<model>) that does not exist in the account/region.
Steps to reproduce
- Run Claude Code with
CLAUDE_CODE_USE_BEDROCK=1in a region where theglobal.inference profile for Sonnet 5 is available buteu.anthropic.claude-sonnet-5is not. - Set the main-loop Sonnet model via
ANTHROPIC_DEFAULT_SONNET_MODEL=<...>/global.anthropic.claude-sonnet-5. Main loop works. - Define a subagent with
model: sonnetin its frontmatter (or passmodel: "sonnet"to the Agent/Task tool). - Spawn it → immediate
400 The provided model identifier is invalidagainsteu.anthropic.claude-sonnet-5.
Workaround
Put the full inference-profile ARN in the agent's model: frontmatter instead of the sonnet alias, e.g.:
model: arn:aws:bedrock:<region>:<account>:inference-profile/global.anthropic.claude-sonnet-5
Environment
- Claude Code with
CLAUDE_CODE_USE_BEDROCK=1 - Region where the
global.profile is available but theeu.<model>variant is not - Main-loop model configured via
ANTHROPIC_DEFAULT_SONNET_MODEL