From a47e12c0e039dc004d1d75fff7e83176223b816b Mon Sep 17 00:00:00 2001 From: Simon <10131203+gaomeng1900@users.noreply.github.com> Date: Thu, 2 Jul 2026 22:11:28 +0800 Subject: [PATCH] fix: model patch for GPT and Claude --- packages/llms/src/utils.ts | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/packages/llms/src/utils.ts b/packages/llms/src/utils.ts index dff9796..b02ed3b 100644 --- a/packages/llms/src/utils.ts +++ b/packages/llms/src/utils.ts @@ -57,17 +57,29 @@ export function modelPatch(body: Record) { delete body.tool_choice } - if (modelName.startsWith('gpt-5')) { - // verbosity trims output tokens across the whole GPT-5 family. + if (modelName.startsWith('gpt')) { body.verbosity = 'low' - // The GPT-5.0 generation only supports "minimal"; 5.1+ supports "none". + + // gpt-5 gpt-5-mini gpt-5-nano only supports "minimal"; + // 5.1+ supports "none". body.reasoning_effort = /^gpt-5(-|$)/.test(modelName) ? 'minimal' : 'none' debug(`Patch GPT-5: verbosity=low, reasoning_effort=${body.reasoning_effort}`) + + if (modelName.includes('chat-latest')) { + debug('Omitting reasoning_effort and temperature for chat-latest') + delete body.reasoning_effort + delete body.temperature + } } - if (modelName.startsWith('claude') && /opus|sonnet|haiku/.test(modelName)) { - debug('Patch Claude: disable thinking') - body.thinking = { type: 'disabled' } + if (modelName.startsWith('claude')) { + if (/opus|sonnet|haiku/.test(modelName)) { + debug('Patch Claude: disable thinking') + body.thinking = { type: 'disabled' } + } else { + debug('Patch Claude: reasoning_effort=low') + body.reasoning_effort = 'low' + } // Convert tool_choice to Claude format if (body.tool_choice === 'required') {