[Bug] Output token limit settings not being applied, agent output capped at 32k tokens
## Bug Description
Environment variables for output token limits are not being respected by agent subprocesses. Agents consistently
hit the 32,000 token output limit despite explicit configuration attempts.
## Expected Behavior
Agents should respect the CLAUDE_CODE_MAX_OUTPUT_TOKENS environment variable and allow up to 100,000 output
tokens as configured.
## Actual Behavior
- Agents process for 20+ minutes
- Hit 32,000 token output limit
- All processing output is lost
- Configuration variables have no effect
## Impact
Critical for production workflows:
- Loss of valuable synthesized information after long processing
- Wasted computational tokens (input tokens consumed, no output saved)
- Forces manual work-splitting or content reduction workarounds
- Makes agent-based consolidation workflows unreliable
## Configuration Attempted
Tried setting in all configuration files (project-level and global):
```json
{
"env": {
"MAX_MCP_OUTPUT_TOKENS": "100000",
"CLAUDE_CODE_MAX_OUTPUT_TOKENS": "100000",
"MAX_THINKING_TOKENS": "20000"
}
}
Also attempted via PowerShell:
[System.Environment]::SetEnvironmentVariable('CLAUDE_CODE_MAX_OUTPUT_TOKENS', '100000', 'User')
Variable confirms as set:
PS> [System.Environment]::GetEnvironmentVariable('CLAUDE_CODE_MAX_OUTPUT_TOKENS', 'User')
100000
But agents still fail at 32K output tokens.
Steps to Reproduce
- Set CLAUDE_CODE_MAX_OUTPUT_TOKENS=100000 in config or environment
- Launch agent with Task tool for large synthesis task (e.g., consolidating 1,200 lines into single deliverable)
- Agent processes for 20+ minutes
- Observe error: "API Error: Claude's response exceeded the 32000 output token maximum"
- Verify config shows 100000, but limit is ignored
Environment
- Platform: win32
- Terminal: PowerShell
- Claude Code Version: 2.0.30
- Feedback ID: ca11bc04-3729-4a2a-8c62-f42c7711e180
Related Context
Error occurs specifically when using Task tool with subagent types (e.g., general-purpose, custom agents). The 32K
limit appears hardcoded for agent subprocesses and doesn't inherit parent environment configuration.
Suggested Fix
Ensure agent subprocesses inherit or explicitly receive the CLAUDE_CODE_MAX_OUTPUT_TOKENS environment variable
from:
- Parent process environment
- Project .claude/config.json
- Global config ~/.claude/config.json
---
Note: Error logs were truncated in feedback submission.
This issue has 6 comments on GitHub. Read the full discussion on GitHub ↗