[2.1.39] Agent spawning fails with Opus on Bedrock (billing header error)
Bug Report: Agent Spawning Fails with Opus on Bedrock
Environment
- Claude Code Version: 2.1.39
- Platform: macOS (Darwin 24.6.0)
- API: AWS Bedrock (
CLAUDE_CODE_USE_BEDROCK=1) - Region: us-west-2
- Date: 2026-02-12
Configuration
{
"env": {
"AWS_PROFILE": "camcode",
"AWS_REGION": "us-west-2",
"CLAUDE_CODE_USE_BEDROCK": "1",
"ANTHROPIC_MODEL": "us.anthropic.claude-sonnet-4-5-20250929-v1:0",
"ANTHROPIC_DEFAULT_HAIKU_MODEL": "us.anthropic.claude-haiku-4-5-20251001-v1:0"
}
}
Issue Summary
When spawning custom agents via the Task tool on Bedrock, Opus model fails with a billing header error, while Sonnet and Haiku work correctly. This prevents users from utilizing Opus for custom agents.
Test Results
| Model | Agent Type | Result | Error |
|--------|---------------------|----------|------------------------------------------|
| Sonnet | happy-penguin-agent | ✅ Works | None |
| Sonnet | dancing-robot-agent | ✅ Works | None |
| Haiku | happy-penguin-agent | ✅ Works | None |
| Haiku | dancing-robot-agent | ✅ Works | None |
| Opus | happy-penguin-agent | ❌ Fails | "x-anthropic-billing-header is reserved" |
| Opus | dancing-robot-agent | ❌ Fails | "x-anthropic-billing-header is reserved" |
Detailed Error Message
API Error: 400 x-anthropic-billing-header is a reserved keyword and may not be used in the system prompt.
Reproduction Steps
- Configure Claude Code with Bedrock (
CLAUDE_CODE_USE_BEDROCK=1) - Create any custom agent or use built-in agents
- Attempt to spawn agent with Opus model:
````
Task(
subagent_type="<any-agent>",
description="Test task",
prompt="Simple test prompt",
model="opus"
)
- Observe billing header error
- Repeat with Sonnet or Haiku models and observe success
Analysis
The error "x-anthropic-billing-header is a reserved keyword" suggests that Claude Code's attribution header is being included in or interfering with the system prompt sent to Bedrock. Debug logs show:
attribution header x-anthropic-billing-header: cc_version=2.1.39.c39; cc_entrypoint=cli; cch=00000;
Bedrock's API validation rejects system prompts containing reserved keywords like "x-anthropic-billing-header". This appears to be a system-level issue with how Claude Code handles agent invocations when using Bedrock with Opus models specifically.
Key Observation: Sonnet and Haiku models work correctly with the same agent spawning mechanism, suggesting this is an Opus-specific issue in how the billing header is processed or where it's being placed in the request.
Impact
- Critical: Users cannot spawn custom agents with Opus models on Bedrock
- Workaround Available: Sonnet and Haiku models work correctly for custom agents
- Limitation: Users lose access to Opus's superior reasoning capabilities for complex agent tasks
Expected Behavior
All three model types (Haiku, Sonnet, Opus) should work correctly when spawning custom agents on Bedrock, just as they do with the standard Anthropic API.
Additional Context
- Issue is specific to Claude Code 2.1.39 + Bedrock + Opus combination
- Does not affect the main Claude Code session (only spawned agents)
- Does not affect Sonnet or Haiku agents
- Custom agents themselves are properly configured (work fine with Sonnet/Haiku)
Suggested Investigation
How attribution headers are handled differently for Opus models when constructing agent system prompts for Bedrock. The billing header appears to be leaking into the system prompt in a way that Bedrock's validation rejects for Opus but not for Sonnet/Haiku.
Current Workaround
Using Sonnet or Haiku for all custom agent tasks. This works but users lose access to Opus's advanced reasoning capabilities for complex architectural decisions and sophisticated agent orchestration tasks.
This issue has 4 comments on GitHub. Read the full discussion on GitHub ↗