fix(codex): Chat Completions adapter continuity, DeepSeek v4 thinking, streaming state sync#3125
Conversation
修复 Responses -> Chat Completions 转换中导致工具调用断节的多个问题: - assistant 消息合并(content + tool_calls 不再拆成两条消息) - stream_options 注入(修复 usage=0) - call_id 保留(防止空值覆盖) - developer -> system 角色映射 - finish_reason 完整映射 - AGENT_LOOP_HINT 注入 - Responses-only 工具过滤
- Add ProviderMeta.chatCompatibilityMode field ("deepseek_thinking")
- DeepSeek thinking mode preserves reasoning_content merged with tool_calls
in the same assistant message (fixes DeepSeek "reasoning_content must be
passed back" error)
- DeepSeek mode: strips sampling params, maps reasoning_effort, injects
thinking: { type: "enabled" }, filters frequency/presence_penalty
- Add model override from provider TOML config in Responses -> Chat adapter path
- Add "Chat 兼容模式" UI field to Codex provider form (visible when
app_type=codex && apiFormat=openai_chat)
- Add i18n strings for zh/en/ja
…reset When editing a saved Codex provider, localCodexApiFormat was initialized via useState() which only runs once on mount. If initialData.meta.apiFormat arrives asynchronously (e.g. after liveSettings load), the state stays at the default value instead of showing the saved format. Add a useEffect that syncs localCodexApiFormat and localCodexChatCompatibilityMode from initialData.meta whenever the initialData reference updates. Fixes: editing a Codex provider resets "API Format" to default.
…ride, UI polish - Fix ProviderForm.tsx fallback default from openai_responses to openai_chat (3 locations) - Add codex_api_format_override to stream check for Codex Chat Completions providers - Invalidate provider list cache after editing (App.tsx) - Replace Codex chat compat Select with Switch, add auto-detect via model name - Fix duplicate usage log dedup for DeepSeek model name mismatch - Tweak i18n text for clarity
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 57ee992d5a
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| appId === "codex" && | ||
| category !== "official" && | ||
| localCodexApiFormat === "openai_chat" && | ||
| localCodexChatCompatibilityMode !== "standard" | ||
| ? { chatCompatibilityMode: localCodexChatCompatibilityMode } |
There was a problem hiding this comment.
Clear chatCompatibilityMode when switching back to standard
nextMeta is built from ...(baseMeta ?? {}), but this branch only writes chatCompatibilityMode when the local mode is non-standard. If a provider previously saved chatCompatibilityMode: "deepseek_thinking", then switching the UI toggle off leaves the old value in baseMeta and resubmits it unchanged, so users cannot actually disable compatibility mode once enabled.
Useful? React with 👍 / 👎.
| .and_then(|m| m.api_format.as_deref()) | ||
| }) | ||
| .unwrap_or("openai_chat"); |
There was a problem hiding this comment.
Preserve legacy Codex apiFormat when meta is missing
This fallback defaults to openai_chat whenever meta.apiFormat is absent, but many existing providers may only encode wire mode in TOML (wire_api = "responses") and have no meta field yet. In that case stream check will hit Chat Completions (/v1/chat/completions) instead of Responses (/v1/responses), producing false health-check failures for otherwise working Responses-only endpoints.
Useful? React with 👍 / 👎.
|
Update pushed: What changed in this follow-up:
Manual verification:
Verification run locally:
|
Preserve existing PR behavior: - openai_chat still converts Codex Responses -> Chat Completions - DeepSeek Thinking mode still preserves/returns reasoning_content and merges with tool_calls - responses_passthrough remains a Codex provider meta mode only - responses_passthrough writes TOML wire_api = responses, not responses_passthrough - responses_passthrough forwards native /v1/responses without Chat conversion - responses_passthrough overrides stale Codex request model with provider-configured model - stream check falls back to TOML wire_api when meta is missing - DeepSeek compatibility switch uses unified isDeepSeekModelForCompatCheck helper
- Use dedicated passthrough model override instead of chat adapter path - Restore chat_error_to_response_error lost during merge - Remove duplicate should_convert_codex_responses_to_chat export - Fix unused variable warning in stream_check.rs - Clean up CodexFormFields props (remove unused shouldShowModelField/onModelNameChange) - Simplify modelName prop to derive from extractCodexModelName in ProviderForm
|
Follow-up pushed: This finalizes the Responses passthrough path after syncing with Key fixes:
Verification:
|
|
@codex review The PR has been updated to |
|
To use Codex here, create a Codex account and connect to github. |
Summary
Codex Chat Completions adapter enhancements for cc-switch proxy layer.
Changes
Commits
Files changed (19)
src-tauri/src/proxy/— Rust proxy layer (adapter continuity, streaming, thinking mode)src/components/providers/forms/— React form componentssrc/i18n/locales/— en/ja/zh translationssrc/utils/— config utilitiesdocs/— adapter notes