File tree Expand file tree Collapse file tree
packages/lib/services/ai/providers Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -171,6 +171,14 @@ export default class OpenAiCompatibleProvider extends ChatProviderBase {
171171 ( { response, json } = await doFetch ( ) ) ;
172172 }
173173
174+ // Reasoning models apply a reasoning_effort default server-side, which OpenAI then rejects
175+ // alongside tools on /chat/completions. Opt out of the default to keep tools working.
176+ if ( response . status === 400 && 'tools' in body && / r e a s o n i n g _ e f f o r t / i. test ( errorMessage ( ) ) ) {
177+ logger . warn ( `Model ${ this . model_ } rejected function tools with reasoning; retrying with reasoning disabled.` ) ;
178+ body . reasoning_effort = 'none' ;
179+ ( { response, json } = await doFetch ( ) ) ;
180+ }
181+
174182 // Older OpenAI models might reject `response_format` json_schema (see https://stackoverflow.com/q/79039544).
175183 // For compatibility, retry without response_format on failure:
176184 if ( response . status === 400 && 'response_format' in body && / j s o n _ s c h e m a | r e s p o n s e _ f o r m a t / i. test ( errorMessage ( ) ) ) {
You can’t perform that action at this time.
0 commit comments