fix(core): use decimal Claude output limits (#6735)

Fixes #6734
This commit is contained in:
易良 2026-07-11 23:59:40 +08:00 committed by GitHub
parent 263dbba741
commit 000eee56ed
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 8 additions and 8 deletions

View file

@ -247,7 +247,7 @@ describe('DefaultOpenAICompatibleProvider', () => {
'prompt-id',
);
expect(result.max_tokens).toBe(131072);
expect(result.max_tokens).toBe(128_000);
});
it('should ignore malformed QWEN_CODE_MAX_OUTPUT_TOKENS values', () => {

View file

@ -309,9 +309,9 @@ describe('tokenLimit with output type', () => {
});
it('should return correct output limits for Claude Opus 4.6 through 4.8', () => {
expect(tokenLimit('claude-opus-4-6', 'output')).toBe(131072);
expect(tokenLimit('claude-opus-4-7', 'output')).toBe(131072);
expect(tokenLimit('vertex/claude-opus-4-8', 'output')).toBe(131072);
expect(tokenLimit('claude-opus-4-6', 'output')).toBe(128_000);
expect(tokenLimit('claude-opus-4-7', 'output')).toBe(128_000);
expect(tokenLimit('vertex/claude-opus-4-8', 'output')).toBe(128_000);
expect(tokenLimit('claude-sonnet-4-6', 'output')).toBe(65536);
});
});
@ -469,9 +469,9 @@ describe('defaultOutputCeiling', () => {
});
it('allows Claude Opus 4.6 through 4.8 to use the full 128K default', () => {
expect(defaultOutputCeiling('claude-opus-4-6')).toBe(131_072);
expect(defaultOutputCeiling('claude-opus-4-7')).toBe(131_072);
expect(defaultOutputCeiling('vertex/claude-opus-4-8')).toBe(131_072);
expect(defaultOutputCeiling('claude-opus-4-6')).toBe(128_000);
expect(defaultOutputCeiling('claude-opus-4-7')).toBe(128_000);
expect(defaultOutputCeiling('vertex/claude-opus-4-8')).toBe(128_000);
});
it('uses the default output limit for an unknown model', () => {

View file

@ -245,7 +245,7 @@ const OUTPUT_PATTERNS: Array<[RegExp, TokenCount]> = [
[/^o\d/, LIMITS['128k']], // o-series: 128K
// Anthropic Claude
[/^claude-opus-4-(?:6|7|8)/, LIMITS['128k']], // Opus 4.6-4.8: 128K
[/^claude-opus-4-(?:6|7|8)/, 128_000 as TokenCount], // Opus 4.6-4.8: 128K
[/^claude-sonnet-4-6/, LIMITS['64k']], // Sonnet 4.6: 64K
[/^claude-/, LIMITS['64k']], // Claude fallback: 64K