CLAUDE_CODE_MAX_OUTPUT_TOKENS not applied to subagent (Task tool) API calls — hardcoded 32K limit
Bug Description
CLAUDE_CODE_MAX_OUTPUT_TOKENS=64000 is correctly set in project-level .claude/settings.json and confirmed present in the runtime environment (echo $CLAUDE_CODE_MAX_OUTPUT_TOKENS → 64000). However, subagents launched via the Task tool hit a 32,000 token limit, producing:
API Error: Claude's response exceeded the 32000 output token maximum.
To configure this behavior, set the CLAUDE_CODE_MAX_OUTPUT_TOKENS environment variable.
The error message itself suggests setting the variable — but it's already set to 64K. The variable only applies to the main conversation, not to subagent API calls.
Steps to Reproduce
- Set
CLAUDE_CODE_MAX_OUTPUT_TOKENSto64000in.claude/settings.json:
``json``
{
"env": {
"CLAUDE_CODE_MAX_OUTPUT_TOKENS": "64000"
}
}
- Confirm it's active: run
echo $CLAUDE_CODE_MAX_OUTPUT_TOKENSin a Bash tool call → shows64000. - Launch a Task tool subagent that produces a large output (e.g., an Explore agent doing broad codebase research).
- Subagent hits the 32K limit and fails with the error above.
Expected Behavior
CLAUDE_CODE_MAX_OUTPUT_TOKENS should apply uniformly to all API calls made by Claude Code, including subagent (Task tool) requests. Or, at minimum, a separate CLAUDE_CODE_SUBAGENT_MAX_OUTPUT_TOKENS variable should be available.
Actual Behavior
- Main conversation: respects the 64K setting.
- Subagents: ignore the setting, use hardcoded 32K default.
Environment
- Claude Code version: latest (as of 2026-02-13)
- OS: macOS (Darwin 25.2.0)
- Model: claude-opus-4-6
Additional Context
The official docs describe the variable as applying to "most requests" — the qualifier "most" appears to exclude subagent API calls. The subagent configuration schema (maxTurns, model, tools, etc.) has no maxOutputTokens field, making this limit non-configurable.
The error message telling users to "set the CLAUDE_CODE_MAX_OUTPUT_TOKENS environment variable" is misleading when the variable is already set but not applied to the failing request.
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗