feat: adaptive reasoning detection for Codex Chat providers

Auto-detect each Chat-routed Codex provider's reasoning interface from
its name, base URL, and model, then inject the matching thinking
parameter without manual configuration:

- Platform-first inference (OpenRouter, SiliconFlow) overrides model
  rules, since the same model exposes different reasoning controls
  depending on the hosting platform.
- Effort tiers are forwarded only to providers that support them
  (DeepSeek, OpenRouter, and StepFun's step-3.5-flash-2603); on/off-only
  providers (Kimi, GLM, Qwen, MiniMax, MiMo, SiliconFlow) drop the level
  instead of sending a field the upstream rejects.
- OpenRouter uses the native reasoning:{effort} object, clamps max to
  xhigh (its enum has no max), and forwards an explicit effort:"none" so
  reasoning can be turned off.
- StepFun falls back to inference so per-model effort support is honored
  (the static preset would have forced effort on step-3.5-flash too).

Includes the Codex provider-form reasoning controls, i18n strings
(zh/en/ja), and response-side reasoning extraction.
This commit is contained in:
Jason
2026-05-21 22:29:18 +08:00
parent 5048ed632d
commit 44d9aabbf3
13 changed files with 1058 additions and 16 deletions
+38
View File
@@ -137,6 +137,42 @@ export interface ClaudeDesktopModelRoute {
supports1m?: boolean;
}
export type CodexChatThinkingParam =
| "none"
| "thinking"
| "enable_thinking"
| "reasoning_split";
export type CodexChatEffortParam =
| "none"
| "reasoning_effort"
// OpenRouter 原生归一化对象 reasoning:{effort}(区别于顶层 OpenAI 别名 reasoning_effort
| "reasoning.effort";
export type CodexChatEffortValueMode =
| "passthrough"
| "low_high"
| "deepseek"
// OpenRouter effort 枚举 xhigh|high|medium|low|minimal(无 maxmax 钳到 xhigh
| "openrouter";
export type CodexChatReasoningOutputFormat =
| "auto"
| "reasoning_content"
| "reasoning"
| "reasoning_details"
| "think_tags";
export interface CodexChatReasoning {
supportsThinking?: boolean;
supportsEffort?: boolean;
thinkingParam?: CodexChatThinkingParam;
effortParam?: CodexChatEffortParam;
effortValueMode?: CodexChatEffortValueMode;
// 声明性字段:标注上游 reasoning 回传位置。当前提取靠穷举字段,未读取此值(think_tags 尚未接线)。
outputFormat?: CodexChatReasoningOutputFormat;
}
// 供应商元数据(字段名与后端一致,保持 snake_case
export interface ProviderMeta {
// 自定义端点:以 URL 为键,值为端点信息
@@ -181,6 +217,8 @@ export interface ProviderMeta {
promptCacheKey?: string;
// Codex OAuth FAST mode: injects service_tier="priority" on ChatGPT Codex requests
codexFastMode?: boolean;
// Codex Responses -> Chat Completions reasoning capability metadata
codexChatReasoning?: CodexChatReasoning;
// 供应商类型(用于识别 Copilot 等特殊供应商)
providerType?: string;
// GitHub Copilot 关联账号 ID(旧字段,保留兼容读取)