[BUG] Haiku 4.5 incorrectly limited to 8192 output tokens instead of 64K

Resolved 💬 11 comments Opened Oct 16, 2025 by VirenMohindra Closed Oct 19, 2025

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 using Haiku 4.5 (claude-haiku-4-5-20251001) in lengthy conversations that require summarization/compacting, Claude Code throws an error indicating that the output exceeded the 8192 token maximum:

API Error: Claude's response exceeded the 8192 output token maximum. To configure this behavior, set the CLAUDE_CODE_MAX_OUTPUT_TOKENS environment variable.

However, according to Anthropic's model comparison table, Haiku 4.5 has a 64,000 token max output, not 8,192 tokens.

The 8,192 token limit is the correct limit for Haiku 3.5 (claude-3-5-haiku-20241022), not Haiku 4.5.

What Should Happen?

Haiku 4.5 should use its correct maximum output token limit of 64,000 tokens, as specified in the official Anthropic documentation.

Error Messages/Logs

API Error: Claude's response exceeded the 8192 output token maximum. To configure this behavior, set the CLAUDE_CODE_MAX_OUTPUT_TOKENS environment variable.

This error occurs during conversation summarization/compacting after a lengthy enough conversation with Haiku 4.5.

Steps to Reproduce

  1. Select Haiku 4.5 as your model using /model command
  2. Have a lengthy conversation that requires multiple turns
  3. Continue until the conversation is long enough to trigger automatic summarization/compacting
  4. Observe the error when Claude's summarization response exceeds 8192 tokens

Technical Analysis

Based on investigation of issue #4255, the root cause appears to be in the model detection logic that determines output token limits:

function AL0(A){
  if(A.includes("3-5"))return 8192;
  if(A.includes("haiku"))return 8192;  // ← Bug: This catches ALL Haiku models
  // ...
  return 32000
}

The current logic uses a simple string check if(A.includes("haiku"))return 8192; which matches ANY model name containing "haiku", including:

  • claude-haiku-4-5-20251001 → incorrectly returns 8192 (should be 64000)
  • claude-3-5-haiku-20241022 → correctly returns 8192
  • claude-3-haiku-20240307 → correctly returns 8192 (though docs say 4096)

Suggested Fix

Update the model detection logic to check for Haiku 4.5 specifically before the generic Haiku check:

function AL0(A){
  if(A.includes("3-5"))return 8192;
  if(A.includes("haiku-4"))return 64000;  // ← Check Haiku 4.5 first
  if(A.includes("haiku"))return 8192;     // ← Then check older Haiku models
  // ...
  return 32000
}

Alternatively, use more specific model name matching to avoid future issues with new model releases.

Reference Documentation

Model Output Token Limits (from Anthropic docs):

  • Claude Haiku 4.5 (claude-haiku-4-5-20251001): 64,000 tokens
  • Claude Haiku 3.5 (claude-3-5-haiku-20241022): 8,192 tokens
  • Claude Haiku 3 (claude-3-haiku-20240307): 4,096 tokens

Related Context:

  • Haiku 4.5 was added in v2.0.17 (commit 32d0be9)
  • Issue #4255 documents the model token limit logic
  • Environment variable ANTHROPIC_DEFAULT_HAIKU_MODEL can be used for manual override

Claude Model

Haiku 4.5

Is this a regression?

No, this never worked

Last Working Version

N/A - Haiku 4.5 support is new in v2.0.17

Claude Code Version

2.0.17+ (latest version with Haiku 4.5 support)

Platform

Anthropic API

Operating System

macOS

Terminal/Shell

Terminal.app (macOS)

Additional Information

Impact: This bug significantly limits Haiku 4.5's usefulness for long conversations or complex tasks that require substantial output, as it incorrectly enforces the Haiku 3.5 token limit instead of the actual 64K limit.

Workaround: Currently, there's no effective workaround besides:

  1. Switching to a different model (Sonnet 4.5 has 64K output)
  2. Setting CLAUDE_CODE_MAX_OUTPUT_TOKENS environment variable (though this is capped at 32K per #4255)

Note: Setting CLAUDE_CODE_MAX_OUTPUT_TOKENS=64000 won't work as a workaround because it gets rejected with validation error, and even if it didn't, the model-specific check happens first in the code logic.

View original on GitHub ↗

This issue has 11 comments on GitHub. Read the full discussion on GitHub ↗