diff --git a/frontend/src/lib/components/copilot/lib.anthropicRouting.test.ts b/frontend/src/lib/components/copilot/lib.anthropicRouting.test.ts index 4bffcd80ac..fca7bd93a6 100644 --- a/frontend/src/lib/components/copilot/lib.anthropicRouting.test.ts +++ b/frontend/src/lib/components/copilot/lib.anthropicRouting.test.ts @@ -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') diff --git a/frontend/src/lib/components/copilot/lib.ts b/frontend/src/lib/components/copilot/lib.ts index 19f350a665..239880b780 100644 --- a/frontend/src/lib/components/copilot/lib.ts +++ b/frontend/src/lib/components/copilot/lib.ts @@ -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') &&