Skip to content

CLAUDE_CODE_MAX_OUTPUT_TOKENS not applied to subagent (Task tool) API calls — hardcoded 32K limit #25569

Description

@Dario-Arcos

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_TOKENS64000). 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

  1. Set CLAUDE_CODE_MAX_OUTPUT_TOKENS to 64000 in .claude/settings.json:
    {
      "env": {
        "CLAUDE_CODE_MAX_OUTPUT_TOKENS": "64000"
      }
    }
  2. Confirm it's active: run echo $CLAUDE_CODE_MAX_OUTPUT_TOKENS in a Bash tool call → shows 64000.
  3. Launch a Task tool subagent that produces a large output (e.g., an Explore agent doing broad codebase research).
  4. 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    duplicateThis issue or pull request already exists

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions