Compaction fails: max_tokens must be greater than thinking.budget_tokens

Resolved 💬 3 comments Opened Apr 21, 2026 by mgailey Closed May 29, 2026

Bug Description

Compaction fails with an API error when the context window gets large during a session. The only recovery option is /clear, which destroys all conversation context.

Error Message

Error during compaction: Error: API Error: 400
{
  "type": "error",
  "error": {
    "type": "invalid_request_error",
    "message": "max_tokens must be greater than thinking.budget_tokens. Please consult our documentation at https://docs.claude.com/en/docs/build-with-claude/extended-thinking#max-tokens-and-context-window-size"
  }
}

Steps to Reproduce

  1. Use Claude Code (Opus model) for an extended session with many file reads and edits
  2. Context window grows large
  3. Run /compact or automatic compaction triggers
  4. Error occurs, compaction fails
  5. Only option is /clear, losing all conversation context

Impact

  • Loss of all conversation context mid-task
  • Established decisions, reasoning, and tradeoffs from the session are lost
  • Subsequent work in a cleared session produces inconsistent results because prior context is gone
  • No graceful recovery path

Expected Behavior

Compaction should handle the max_tokens / thinking.budget_tokens relationship correctly and succeed, preserving conversation context.

Environment

  • Model: claude-opus-4-6
  • Platform: Windows (win32)

View original on GitHub ↗

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