- 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>
46 lines
1.7 KiB
TypeScript
46 lines
1.7 KiB
TypeScript
import { describe, expect, test } from 'bun:test'
|
|
import {
|
|
getEffectiveContextWindowSize,
|
|
getAutoCompactThreshold,
|
|
} from './autoCompact.ts'
|
|
|
|
describe('getEffectiveContextWindowSize', () => {
|
|
test('returns positive value for known models with large context windows', () => {
|
|
// claude-sonnet-4 has 200k context
|
|
const effective = getEffectiveContextWindowSize('claude-sonnet-4')
|
|
expect(effective).toBeGreaterThan(0)
|
|
})
|
|
|
|
test('never returns negative even for unknown 3P models (issue #635)', () => {
|
|
// Previously, unknown 3P models got 8k context → effective context was
|
|
// 8k minus 20k summary reservation = -12k, causing infinite auto-compact.
|
|
// Now the fallback is 128k and there's a floor, so effective is always
|
|
// at least reservedTokensForSummary + buffer.
|
|
process.env.CLAUDE_CODE_USE_OPENAI = '1'
|
|
try {
|
|
const effective = getEffectiveContextWindowSize('some-unknown-3p-model')
|
|
expect(effective).toBeGreaterThan(0)
|
|
// Must be at least summary reservation (20k) + buffer (13k) = 33k
|
|
expect(effective).toBeGreaterThanOrEqual(33_000)
|
|
} finally {
|
|
delete process.env.CLAUDE_CODE_USE_OPENAI
|
|
}
|
|
})
|
|
})
|
|
|
|
describe('getAutoCompactThreshold', () => {
|
|
test('returns positive threshold for known models', () => {
|
|
const threshold = getAutoCompactThreshold('claude-sonnet-4')
|
|
expect(threshold).toBeGreaterThan(0)
|
|
})
|
|
|
|
test('never returns negative threshold even for unknown 3P models (issue #635)', () => {
|
|
process.env.CLAUDE_CODE_USE_OPENAI = '1'
|
|
try {
|
|
const threshold = getAutoCompactThreshold('some-unknown-3p-model')
|
|
expect(threshold).toBeGreaterThan(0)
|
|
} finally {
|
|
delete process.env.CLAUDE_CODE_USE_OPENAI
|
|
}
|
|
})
|
|
}) |