fix: raise deepseek output budget for reasoning responses

This commit is contained in:
Guilhem Lemouel
2026-09-22 08:55:47 +02:00
parent 56a6ad322e
commit fa4e6ce832
2 changed files with 23 additions and 2 deletions
@@ -116,13 +116,31 @@ async function setupClients() {
beforeEach(async () => {
await setupClients()
})
}, 60000)
afterEach(() => {
vi.restoreAllMocks()
h.currentModel = undefined
})
describe('DeepSeek output budget', () => {
it.each(['deepseek-flash', 'deepseek-v4-flash', 'deepseek-v4-pro'])(
'sends the full reasoning and answer budget for %s',
async (model) => {
const { getCompletion, getNonStreamingMetadataCompletion, METADATA_MAX_TOKENS } =
await import('./lib')
h.currentModel = { provider: 'deepseek', model }
await getCompletion(messages, new AbortController())
expect(openaiCreate.mock.calls[0][0].max_tokens).toBe(393216)
openaiCreate.mockClear()
await getNonStreamingMetadataCompletion(messages, new AbortController())
expect(openaiCreate.mock.calls[0][0].max_tokens).toBe(METADATA_MAX_TOKENS)
}
)
})
describe('Anthropic Messages API routing', () => {
it('getNonStreamingCompletion routes Foundry Claude through the Anthropic client', async () => {
const { getNonStreamingCompletion } = await import('./lib')
+4 -1
View File
@@ -310,7 +310,10 @@ export async function fetchAvailableModels(
}
export function getModelMaxTokens(provider: AIProvider, model: string) {
if (model.includes('gpt-5')) {
if (/^(deepseek-flash|deepseek-v4-(flash|pro))$/.test(model.split('/').pop() ?? '')) {
// DeepSeek counts reasoning against the output budget as well as the answer.
return 393216
} else if (model.includes('gpt-5')) {
return 128000
} else if (
(provider === 'azure_openai' || provider === 'openai' || provider === 'azure_foundry') &&