fix: prevent infinite auto-compact loop for unknown 3P models (#635) - #636
Merged
kevincodex1 merged 1 commit intoApr 12, 2026
Merged
Conversation
…ne#635) - Raise context window fallback from 8k to 128k for unknown OpenAI-compat models. The 8k fallback caused effective context (8k minus output reservation) to go negative, making auto-compact fire on every single message. - Add safety floor in getEffectiveContextWindowSize(): effective context is always at least reservedTokensForSummary + 13k buffer, ensuring the auto-compact threshold stays positive. - Add missing MiniMax model entries (M2.5, M2.5-highspeed, M2.1, M2.1-highspeed) all at 204,800 context / 131,072 max output per MiniMax docs. - Add tests for MiniMax variants, 128k fallback, and autoCompact floor. Fixes Twigpine#635
gnanam1990
approved these changes
Apr 12, 2026
kevincodex1
approved these changes
Apr 12, 2026
lunamonke
pushed a commit
to lunamonke/openclaude
that referenced
this pull request
Apr 12, 2026
…ne#635) (Twigpine#636) - Raise context window fallback from 8k to 128k for unknown OpenAI-compat models. The 8k fallback caused effective context (8k minus output reservation) to go negative, making auto-compact fire on every single message. - Add safety floor in getEffectiveContextWindowSize(): effective context is always at least reservedTokensForSummary + 13k buffer, ensuring the auto-compact threshold stays positive. - Add missing MiniMax model entries (M2.5, M2.5-highspeed, M2.1, M2.1-highspeed) all at 204,800 context / 131,072 max output per MiniMax docs. - Add tests for MiniMax variants, 128k fallback, and autoCompact floor. Fixes Twigpine#635 Co-authored-by: root <root@vm7508.lumadock.com>
euxaristia
pushed a commit
to euxaristia/openclaude
that referenced
this pull request
Apr 13, 2026
…ne#635) (Twigpine#636) - Raise context window fallback from 8k to 128k for unknown OpenAI-compat models. The 8k fallback caused effective context (8k minus output reservation) to go negative, making auto-compact fire on every single message. - Add safety floor in getEffectiveContextWindowSize(): effective context is always at least reservedTokensForSummary + 13k buffer, ensuring the auto-compact threshold stays positive. - Add missing MiniMax model entries (M2.5, M2.5-highspeed, M2.1, M2.1-highspeed) all at 204,800 context / 131,072 max output per MiniMax docs. - Add tests for MiniMax variants, 128k fallback, and autoCompact floor. Fixes Twigpine#635 Co-authored-by: root <root@vm7508.lumadock.com>
This was referenced Apr 13, 2026
C1ph3r404
pushed a commit
to C1ph3r404/openclaude
that referenced
this pull request
Apr 29, 2026
…ne#635) (Twigpine#636) - Raise context window fallback from 8k to 128k for unknown OpenAI-compat models. The 8k fallback caused effective context (8k minus output reservation) to go negative, making auto-compact fire on every single message. - Add safety floor in getEffectiveContextWindowSize(): effective context is always at least reservedTokensForSummary + 13k buffer, ensuring the auto-compact threshold stays positive. - Add missing MiniMax model entries (M2.5, M2.5-highspeed, M2.1, M2.1-highspeed) all at 204,800 context / 131,072 max output per MiniMax docs. - Add tests for MiniMax variants, 128k fallback, and autoCompact floor. Fixes Twigpine#635 Co-authored-by: root <root@vm7508.lumadock.com>
The-FOOL-00
pushed a commit
to The-FOOL-00/openclaude
that referenced
this pull request
May 24, 2026
…ne#635) (Twigpine#636) - Raise context window fallback from 8k to 128k for unknown OpenAI-compat models. The 8k fallback caused effective context (8k minus output reservation) to go negative, making auto-compact fire on every single message. - Add safety floor in getEffectiveContextWindowSize(): effective context is always at least reservedTokensForSummary + 13k buffer, ensuring the auto-compact threshold stays positive. - Add missing MiniMax model entries (M2.5, M2.5-highspeed, M2.1, M2.1-highspeed) all at 204,800 context / 131,072 max output per MiniMax docs. - Add tests for MiniMax variants, 128k fallback, and autoCompact floor. Fixes Twigpine#635 Co-authored-by: root <root@vm7508.lumadock.com>
discopops
pushed a commit
to discopops/openclaude
that referenced
this pull request
May 28, 2026
…ne#635) (Twigpine#636) - Raise context window fallback from 8k to 128k for unknown OpenAI-compat models. The 8k fallback caused effective context (8k minus output reservation) to go negative, making auto-compact fire on every single message. - Add safety floor in getEffectiveContextWindowSize(): effective context is always at least reservedTokensForSummary + 13k buffer, ensuring the auto-compact threshold stays positive. - Add missing MiniMax model entries (M2.5, M2.5-highspeed, M2.1, M2.1-highspeed) all at 204,800 context / 131,072 max output per MiniMax docs. - Add tests for MiniMax variants, 128k fallback, and autoCompact floor. Fixes Twigpine#635 Co-authored-by: root <root@vm7508.lumadock.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #635 — auto-compact fires on every message for 3P models not in the context window table.
Root cause
The 8,000 token fallback in
getContextWindowForModel()was too low. Combined with output token reservation (8k–20k) and the 13k auto-compact buffer, the effective context window went negative, causingisAboveAutoCompactThresholdto betruefor any non-zero token usage.Changes
1. Raise fallback from 8k → 128k (
src/utils/context.ts)OPENAI_FALLBACK_CONTEXT_WINDOW = 128_000instead of 8,0002. Add safety floor in
getEffectiveContextWindowSize()(src/services/compact/autoCompact.ts)Math.max(effectiveContext, reservedTokensForSummary + 13_000)CLAUDE_CODE_AUTO_COMPACT_WINDOWto a very low value, the effective context can never go below the summary reservation plus buffer3. Add missing MiniMax model entries (
src/utils/model/openaiContextWindows.ts)MiniMax-M2.7-highspeed,MiniMax-M2.5,MiniMax-M2.5-highspeed,MiniMax-M2.1,MiniMax-M2.1-highspeed(and lowercase variants)MiniMax-M2.5doesn't prefix-matchMiniMax-M2.74. Tests
autoCompact.test.ts:getEffectiveContextWindowSizenever returns negative,getAutoCompactThresholdnever returns negativeValidation
CI should pass — all changes are additive or value corrections, no breaking API changes.