feat(ai/providers): dropped auto tool choice for reasoning models

- Add `shouldDropAutoToolChoiceForReasoning` helper to handle compatibility constraints for models where tool choice disables reasoning.
- Update OpenAI completions and responses parameter building to drop automatic tool choices when reasoning options are active.
This commit is contained in:
can1357
2026-08-20 08:00:57 +02:00
parent 57305b99cd
commit 7cb504cdb3
7 changed files with 52 additions and 11 deletions
@@ -108,7 +108,7 @@ export {
import { ModelsConfigFile, type ProviderValidationModel, validateProviderConfiguration } from "./models-config";
import type { ModelOverride, ModelsConfig, ProviderAuthMode } from "./models-config-schema";
import { settings, type Settings } from "./settings";
import { type Settings, settings } from "./settings";
// DeviceCheck attestation (`x-oai-attestation`) for ChatGPT-OAuth Codex
// requests; the pi-ai provider resolves it just-in-time per request.
+7 -3
View File
@@ -1251,9 +1251,13 @@ async function createAgentSessionScoped(options: CreateAgentSessionOptions): Pro
// / session would silently miss credential_disabled events.
const modelRegistry =
options.modelRegistry ??
new ModelRegistry(options.authStorage ?? (await logger.time("discoverModels", discoverAuthStorage, agentDir)), undefined, {
settings,
});
new ModelRegistry(
options.authStorage ?? (await logger.time("discoverModels", discoverAuthStorage, agentDir)),
undefined,
{
settings,
},
);
// Track whether we internally created the authStorage so we can close it
// if construction fails before the session takes ownership.
const ownsAuthStorage = !options.authStorage && !options.modelRegistry;