[BUG] Task Tool Fails to Spawn Agents in AWS GovCloud
Preflight Checklist
- [x] I have searched existing issues and this hasn't been reported yet
- [x] This is a single bug report (please file separate reports for different bugs)
- [x] I am using the latest version of Claude Code
What's Wrong?
Environment
- Claude Code Version: 2.1.29
- Node Version: v24.13.0
- Platform: macOS 26.2 (Build 25C56)
- AWS Region: us-gov-west-1
- AWS Profile: bedrock (GovCloud)
Summary
The Task tool cannot spawn specialized agents (code-reviewer, Explore, Plan, etc.) in AWS GovCloud environments. The tool incorrectly resolves model identifiers by stripping the GovCloud-specific prefix, causing API authentication failures.
Root Cause
The Task tool extracts the model ID from the ARN but incorrectly normalizes us-gov.anthropic to us.anthropic, which is invalid for GovCloud regions.
Expected Model ID: us-gov.anthropic.claude-sonnet-4-5-20250929-v1:0
Actual Model ID Sent: us.anthropic.claude-sonnet-4-5-20250929-v1:0
Configuration Tested
~/.claude/settings.json
{
"model": "arn:aws-us-gov:bedrock:us-gov-west-1:414305825600:inference-profile/us-gov.anthropic.claude-sonnet-4-5-20250929-v1:0",
"alwaysThinkingEnabled": true
}
Environment Variables (.zshrc)
export CLAUDE_CODE_USE_BEDROCK=1
export AWS_PROFILE=bedrock
export AWS_REGION=us-gov-west-1
export AWS_DEFAULT_REGION=us-gov-west-1
export ANTHROPIC_MODEL='arn:aws-us-gov:bedrock:us-gov-west-1:414305825600:inference-profile/us-gov.anthropic.claude-sonnet-4-5-20250929-v1:0'
Agent Configuration (~/.claude/agents/code-reviewer.md)
Tested with:
- Full ARN
- Model ID with
us-gov.prefix - Shorthand (
sonnet,haiku) - No model spec (inherit from parent)
All configurations fail with the same error.
Attempted Workarounds (All Failed)
Test 1: Full ARN in agent config
model: arn:aws-us-gov:bedrock:us-gov-west-1:414305825600:inference-profile/us-gov.anthropic.claude-sonnet-4-5-20250929-v1:0
Result: ❌ Still sends us.anthropic...
Test 2: Model ID with us-gov prefix
model: us-gov.anthropic.claude-sonnet-4-5-20250929-v1:0
Result: ❌ Still sends us.anthropic...
Test 3: Shorthand model names
model: sonnet
model: haiku
Result: ❌ Resolves to commercial AWS IDs
Test 4: No model specified (inherit)
# No model field
Result: ❌ Still sends us.anthropic...
Impact
- Severity: HIGH
- Users Affected: All AWS GovCloud users
- Workaround: None available
- Functionality Lost: Cannot spawn any specialized agents (code-reviewer, Explore, Plan, etc.)
- Main Claude Code Session: Works fine (only Task tool is affected)
Proposed Fix
Location
The Task tool's model resolution logic (likely in the Claude Code agent spawning code)
Current Logic (incorrect)
// Pseudo-code
const modelId = arn.split('/').pop(); // Gets "us-gov.anthropic.claude-..."
const normalizedId = modelId.replace(/^us-gov\./, 'us.');
Corrected Logic
// Pseudo-code
const modelId = arn.split('/').pop(); // Gets "us-gov.anthropic.claude-..."
// Don't normalize - use as-is for GovCloud
return modelId;
Alternative Fix
Respect the AWS_REGION environment variable:
if (process.env.AWS_REGION?.startsWith('us-gov-')) {
// Use us-gov. prefix
} else {
// Use us. prefix
}
Additional Context
- Main Claude Code session works perfectly with GovCloud ARN
- Only the Task tool (agent spawning) has this issue
- Manual code reviews were used as workaround
- Issue is blocking agent-based workflows in government environments
- This affects all federal agencies and contractors using Claude Code in GovCloud
Files for Reference
I can provide:
- Complete bug report with detailed analysis
- Configuration files used
- Error logs from multiple test attempts
- Examples of working main session vs failing agent spawning
---
Would you like me to provide any additional information?
What Should Happen?
The Task tool should spawn specialized agents (code-reviewer, Explore, Plan, etc.) in AWS GovCloud environments. The tool should correctly resolves model identifiers by not stripping the GovCloud-specific prefix, which is causing API authentication failures.
Error Messages/Logs
API Error (us.anthropic.claude-sonnet-4-5-20250929-v1:0): 400 The provided model identifier is invalid.
Steps to Reproduce
- Configure Claude Code for AWS GovCloud with full ARN in settings.json
- Attempt to invoke any agent using the Task tool:
``javascript``
Task(subagent_type="code-reviewer", prompt="Review code")
- Observe error:
The provided model identifier is invalid
Claude Model
Sonnet (default)
Is this a regression?
I don't know
Last Working Version
_No response_
Claude Code Version
2.1.29
Platform
AWS Bedrock
Operating System
macOS
Terminal/Shell
IntelliJ IDEA terminal
Additional Information
_No response_
This issue has 5 comments on GitHub. Read the full discussion on GitHub ↗