mirror of
https://github.com/tiennm99/ccs.git
synced 2026-10-14 06:17:27 +00:00
Merge pull request #1069 from sgaluza/feat/opus-4-7-adaptive-thinking
fix(cliproxy): use adaptive thinking for Opus 4.7 + add 'max' level
This commit is contained in:
20 files changed
+220
-22
No files matched your search
@@ -538,6 +538,20 @@ describe('applyThinkingConfig - composite variant integration', () => {
|
||||
expect(result.ANTHROPIC_DEFAULT_OPUS_MODEL).toBe('claude-opus-4-6-thinking(32768)');
|
||||
});
|
||||
|
||||
it('rewrites legacy budget suffixes for claude level-based models', () => {
|
||||
const envVars: NodeJS.ProcessEnv = {
|
||||
ANTHROPIC_MODEL: 'claude-opus-4-7(32768)',
|
||||
ANTHROPIC_DEFAULT_OPUS_MODEL: 'claude-opus-4-7(32768)',
|
||||
ANTHROPIC_DEFAULT_SONNET_MODEL: 'claude-sonnet-4-6',
|
||||
ANTHROPIC_DEFAULT_HAIKU_MODEL: 'claude-haiku-4-5-20251001',
|
||||
};
|
||||
|
||||
const result = applyThinkingConfig(envVars, 'claude' as CLIProxyProvider, 'max');
|
||||
|
||||
expect(result.ANTHROPIC_MODEL).toBe('claude-opus-4-7(max)');
|
||||
expect(result.ANTHROPIC_DEFAULT_OPUS_MODEL).toBe('claude-opus-4-7(max)');
|
||||
});
|
||||
|
||||
it('should use codex effort suffix style when provider is codex', () => {
|
||||
const envVars: NodeJS.ProcessEnv = {
|
||||
ANTHROPIC_MODEL: 'gpt-5.3-codex',
|
||||
|
||||
@@ -58,4 +58,24 @@ describe('model-catalog compatibility lookups', () => {
|
||||
|
||||
expect(catalog?.models.map((model) => model.id)).toEqual(['gemini-2.5-pro']);
|
||||
});
|
||||
|
||||
it('preserves static maxLevel when live thinking metadata omits it', () => {
|
||||
const catalog = mergeCatalog('claude', [
|
||||
{
|
||||
id: 'claude-opus-4-7',
|
||||
display_name: 'Claude Opus 4.7',
|
||||
thinking: {
|
||||
levels: ['low', 'medium', 'high', 'xhigh', 'max'],
|
||||
dynamic_allowed: true,
|
||||
},
|
||||
},
|
||||
]);
|
||||
|
||||
expect(catalog?.models[0]?.thinking).toMatchObject({
|
||||
type: 'levels',
|
||||
levels: ['low', 'medium', 'high', 'xhigh', 'max'],
|
||||
maxLevel: 'max',
|
||||
dynamicAllowed: true,
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -147,9 +147,11 @@ describe('Model Catalog', () => {
|
||||
const opus47 = MODEL_CATALOG.claude.models.find((m) => m.id === 'claude-opus-4-7');
|
||||
assert(opus47, 'Should include Claude Opus 4.7');
|
||||
assert.strictEqual(opus47.name, 'Claude Opus 4.7');
|
||||
// Claude provider differs from AGY: zero thinking budget is disallowed,
|
||||
// and extended (1M) context is available on the Anthropic API.
|
||||
assert.strictEqual(opus47.thinking.zeroAllowed, false);
|
||||
// Opus 4.7 requires adaptive thinking (type: 'levels'); manual budget_tokens
|
||||
// is rejected by the Anthropic API with 400. Extended (1M) context is available.
|
||||
assert.strictEqual(opus47.thinking.type, 'levels');
|
||||
assert.deepStrictEqual(opus47.thinking.levels, ['low', 'medium', 'high', 'xhigh', 'max']);
|
||||
assert.strictEqual(opus47.thinking.maxLevel, 'max');
|
||||
assert.strictEqual(opus47.extendedContext, true);
|
||||
});
|
||||
|
||||
|
||||
@@ -29,6 +29,7 @@ describe('Thinking Validator', () => {
|
||||
expect(VALID_THINKING_LEVELS).toContain('medium');
|
||||
expect(VALID_THINKING_LEVELS).toContain('high');
|
||||
expect(VALID_THINKING_LEVELS).toContain('xhigh');
|
||||
expect(VALID_THINKING_LEVELS).toContain('max');
|
||||
expect(VALID_THINKING_LEVELS).toContain('auto');
|
||||
});
|
||||
|
||||
@@ -38,6 +39,24 @@ describe('Thinking Validator', () => {
|
||||
expect(THINKING_LEVEL_BUDGETS.medium).toBe(8192);
|
||||
expect(THINKING_LEVEL_BUDGETS.high).toBe(24576);
|
||||
expect(THINKING_LEVEL_BUDGETS.xhigh).toBe(32768);
|
||||
// `max` sits above xhigh — unconstrained thinking on Opus 4.7 / Mythos
|
||||
expect(THINKING_LEVEL_BUDGETS.max).toBeGreaterThan(THINKING_LEVEL_BUDGETS.xhigh);
|
||||
});
|
||||
|
||||
it('should treat max as a distinct top tier on models that list it (Opus 4.7)', () => {
|
||||
// Opus 4.7 exposes both xhigh and max; max must not collapse into xhigh.
|
||||
const result = validateThinking('claude', 'claude-opus-4-7', 'max');
|
||||
expect(result.valid).toBe(true);
|
||||
expect(result.value).toBe('max');
|
||||
expect(result.warning).toBeUndefined();
|
||||
});
|
||||
|
||||
it('should still alias max -> xhigh for models without a max level (backcompat)', () => {
|
||||
// Codex catalog uses ['low','medium','high','xhigh'] with maxLevel 'xhigh'.
|
||||
// User input "max" should map down to xhigh rather than be rejected.
|
||||
const result = validateThinking('codex', 'gpt-5.4', 'max');
|
||||
expect(result.valid).toBe(true);
|
||||
expect(result.value).toBe('xhigh');
|
||||
});
|
||||
|
||||
it('should export off values', () => {
|
||||
|
||||
Reference in new issue
Block a user