fix: prevent infinite auto-compact loop for unknown 3P models (#635) (#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 #635

Co-authored-by: root <root@vm7508.lumadock.com>
This commit is contained in:
Vasanth T
2026-04-12 23:33:02 +05:30
committed by GitHub
parent d2a057c6f1
commit aeaa658f77
5 changed files with 100 additions and 9 deletions

View File

@@ -107,9 +107,23 @@ test('MiniMax-M2.7 uses explicit provider-specific context and output caps', ()
expect(getMaxOutputTokensForModel('MiniMax-M2.7')).toBe(131_072)
})
test('unknown openai-compatible models still use the conservative fallback window', () => {
test('unknown openai-compatible models use the 128k fallback window (not 8k, see #635)', () => {
process.env.CLAUDE_CODE_USE_OPENAI = '1'
delete process.env.CLAUDE_CODE_MAX_OUTPUT_TOKENS
expect(getContextWindowForModel('some-unknown-3p-model')).toBe(8_000)
expect(getContextWindowForModel('some-unknown-3p-model')).toBe(128_000)
})
test('MiniMax-M2.5 and M2.1 use explicit provider-specific context and output caps', () => {
process.env.CLAUDE_CODE_USE_OPENAI = '1'
delete process.env.CLAUDE_CODE_MAX_OUTPUT_TOKENS
expect(getContextWindowForModel('MiniMax-M2.5')).toBe(204_800)
expect(getContextWindowForModel('MiniMax-M2.5-highspeed')).toBe(204_800)
expect(getContextWindowForModel('MiniMax-M2.1')).toBe(204_800)
expect(getContextWindowForModel('MiniMax-M2.1-highspeed')).toBe(204_800)
expect(getModelMaxOutputTokens('MiniMax-M2.5')).toEqual({
default: 131_072,
upperLimit: 131_072,
})
})