[BUG] CLAUDE_CODE_MAX_CONTEXT_TOKENS

Resolved 💬 2 comments Opened May 24, 2026 by chengbinw Closed May 28, 2026

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?

● Your settings look correct — 800K max context with 60% autocompact threshold should trigger at ~480K tokens, not ~80K.
This is likely a Claude Code bug: when using a non-Anthropic model backend (deepseek-v4-pro), the compaction logic
may be falling back to Anthropic's native model context windows (e.g., 200K for Opus) rather than respecting
CLAUDE_CODE_MAX_CONTEXT_TOKENS.

The model: "opus[1m]" setting with the [1m] suffix might also be getting parsed down to just opus internally,
defaulting to standard Opus limits.

This isn't something I can fix from this side — it's in Claude Code's compaction internals. I'd recommend reporting
this at https://github.com/anthropics/claude-code/issues with your settings.json. The compaction threshold not
respecting CLAUDE_CODE_MAX_CONTEXT_TOKENS when using third-party model backends is the core issue.

What Should Happen?

NA

Error Messages/Logs

NA

Steps to Reproduce

NA

Claude Model

Other

Is this a regression?

No, this never worked

Last Working Version

_No response_

Claude Code Version

2.1.146 (Claude Code)

Platform

Other

Operating System

Other Linux

Terminal/Shell

Windows Terminal

Additional Information

_No response_

View original on GitHub ↗

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