fix(router): выровнять max_tokens по потолку модели (65536)
66000 был на 464 токена выше предела вывода deepseek-v4-flash (65 536) → запрос отбивался ошибкой 400. Выставлено ровно 65536 в обоих форматах запроса; тесты обновлены. Совпадает и с потолком Claude-моделей судьи/ наставника, идущих через тот же транспорт. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -501,14 +501,14 @@ export async function callAnthropicAPI(promptOrMessages, {
|
||||
if (typeof promptOrMessages === 'string') {
|
||||
body = JSON.stringify({
|
||||
model,
|
||||
max_tokens: 66000,
|
||||
max_tokens: 65536,
|
||||
messages: [{ role: 'user', content: promptOrMessages }],
|
||||
});
|
||||
} else {
|
||||
const { system, user } = promptOrMessages;
|
||||
body = JSON.stringify({
|
||||
model,
|
||||
max_tokens: 66000,
|
||||
max_tokens: 65536,
|
||||
system: [{ type: 'text', text: system, cache_control: { type: 'ephemeral' } }],
|
||||
messages: [{ role: 'user', content: user }],
|
||||
});
|
||||
|
||||
@@ -608,24 +608,24 @@ describe('PAMYATKA extensions (Phase 3 brain-retro #9)', () => {
|
||||
// plus max_tokens 1500 too low for future long skill chains (silent truncation).
|
||||
|
||||
describe('callAnthropicAPI — max_tokens budget for long chains', () => {
|
||||
it('sends max_tokens 66000 for the structured {system,user} form', async () => {
|
||||
it('sends max_tokens 65536 for the structured {system,user} form', async () => {
|
||||
let body;
|
||||
const fetchImpl = async (url, opts) => {
|
||||
body = JSON.parse(opts.body);
|
||||
return { ok: true, json: async () => ({ content: [{ text: '{"task_type":"question"}' }] }) };
|
||||
};
|
||||
await callAnthropicAPI({ system: 'S', user: 'U' }, { apiKey: 'k', fetchImpl });
|
||||
expect(body.max_tokens).toBe(66000);
|
||||
expect(body.max_tokens).toBe(65536);
|
||||
});
|
||||
|
||||
it('sends max_tokens 66000 for the legacy string form', async () => {
|
||||
it('sends max_tokens 65536 for the legacy string form', async () => {
|
||||
let body;
|
||||
const fetchImpl = async (url, opts) => {
|
||||
body = JSON.parse(opts.body);
|
||||
return { ok: true, json: async () => ({ content: [{ text: '{"task_type":"question"}' }] }) };
|
||||
};
|
||||
await callAnthropicAPI('hi', { apiKey: 'k', fetchImpl });
|
||||
expect(body.max_tokens).toBe(66000);
|
||||
expect(body.max_tokens).toBe(65536);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user