[BUG] Workflow tool's per-agent model override is silently ignored for subagents when running headless (claude -p)

Status Fixed / completed
Reported on v2.1.220
Maintainer reply None cached
Activity 1 comment · opened Aug 4, 2026 · closed Aug 7, 2026

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?

When a Dynamic Workflow script spawns subagents via agent(prompt, {model: 'opus'|'sonnet'|'haiku', ...}), the requested per-call model override is honored correctly under the standard Anthropic API in an interactive session, but is silently ignored when the CLI runs headless (claude -p) with CLAUDE_CODE_USE_BEDROCK=1 and the ANTHROPIC_DEFAULT_{OPUS,SONNET,HAIKU}_MODEL / CLAUDE_CODE_SUBAGENT_MODEL. Every subagent call falls back to whatever CLAUDE_CODE_SUBAGENT_MODEL resolves to, regardless of its own model: option. No error, warning, or degraded-mode signal is surfaced — the workflow completes normally and reports success.

Environment

  • Claude Code CLI: installed via npm install -g @anthropic-ai/claude-code at container image build time - latest at build time (unpinned).
  • Execution mode: headless, claude -p "<prompt>"
  • Relevant env vars (all set, non-empty, injected as process env before CLI start):

CLAUDE_CODE_USE_BEDROCK=1
AWS_REGION=eu-west-1
ANTHROPIC_MODEL=eu.anthropic.claude-sonnet-5
ANTHROPIC_DEFAULT_OPUS_MODEL=eu.anthropic.claude-opus-5
ANTHROPIC_DEFAULT_SONNET_MODEL=eu.anthropic.claude-sonnet-5
ANTHROPIC_DEFAULT_HAIKU_MODEL=eu.anthropic.claude-haiku-4-5-20251001-v1:0
CLAUDE_CODE_SUBAGENT_MODEL=eu.anthropic.claude-sonnet-5

Steps to reproduce:

  1. Launch a Workflow script that calls agent() at least three times with explicit, distinct model

options, e.g.:
await parallel([
() => agent('...', { model: 'haiku', ... }),
() => agent('...', { model: 'sonnet', ... }),
() => agent('...', { model: 'opus', ... }),
])

  1. Run it headless under Bedrock with the env vars above set.
  2. Inspect the resulting transcripts' message.model field for each subagent's assistant entries.

Expected:
Each subagent's transcript shows the model tier it was assigned matching what happens under the direct API.

Actual:
Every subagent — regardless of requested model — runs on whatever CLAUDE_CODE_SUBAGENT_MODEL is set to.

What Should Happen?

Expected:
Each subagent's transcript shows the model tier it was assigned matching what happens under the direct API.

Actual:
Every subagent — regardless of requested model — runs on whatever CLAUDE_CODE_SUBAGENT_MODEL is set to.

Error Messages/Logs

Steps to Reproduce

Steps to reproduce:

  1. Launch a Workflow script that calls agent() at least three times with explicit, distinct model

options, e.g.:
await parallel([
() => agent('...', { model: 'haiku', ... }),
() => agent('...', { model: 'sonnet', ... }),
() => agent('...', { model: 'opus', ... }),
])

  1. Run it headless under Bedrock with the env vars above set.
  2. Inspect the resulting transcripts' message.model field for each subagent's assistant entries.

Claude Model

None

Is this a regression?

I don't know

Last Working Version

_No response_

Claude Code Version

2.1.220

Platform

AWS Bedrock

Operating System

Ubuntu/Debian Linux

Terminal/Shell

Non-interactive/CI environment

Additional Information

_No response_

View original on GitHub ↗

This issue has 1 comment on GitHub. Read the full discussion on GitHub ↗