Subagents have no awareness of CLAUDE_CODE_MAX_OUTPUT_TOKENS value
Problem
Subagents (spawned via the Task tool) inherit CLAUDE_CODE_MAX_OUTPUT_TOKENS from the parent session but have no way to know the actual value. This means they cannot adapt their output — at non-default settings, Write tool calls silently truncate.
Impact by setting
| MAX_OUTPUT | Write limit | What happens |
|------------|-------------|--------------|
| 32000 (default) | ~3000 lines | Works fine |
| 16000 | ~1500 lines | Large files truncated without warning |
| 8000 | ~800 lines | Most multi-file writes fail silently |
Reproduction
- Set
export CLAUDE_CODE_MAX_OUTPUT_TOKENS=8000 - Use a skill/command that spawns a subagent which writes a file >800 lines
- The subagent's Write call silently truncates — no error, no warning
Current workaround
We manually include a TOKEN BUDGET block in every subagent prompt with the current value so the subagent can self-limit. This works but requires every skill/command author to remember the convention, and new skills will miss it.
Suggested improvement
Expose CLAUDE_CODE_MAX_OUTPUT_TOKENS (and optionally MAX_THINKING_TOKENS) to subagents automatically — either as:
- A system-level context variable available in the subagent's prompt (like the model name)
- A property on the Task tool response
- Documentation/guidance on the truncation behavior so skill authors know to handle it
This would eliminate the need for manual token budget forwarding in every subagent prompt.
Environment
- Claude Code: 2.1.71
- Model: claude-opus-4-6
- OS: macOS 26.3
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗