feat(codex): add Ollama local provider preset with proxy fixes#4075
feat(codex): add Ollama local provider preset with proxy fixes#4075XiaoBinGan wants to merge 5 commits into
Conversation
- Add 'local' category to ProviderCategory for local models - Add Ollama (Local) preset with 5 local model entries - Configure openai_chat API format for Responses→Chat protocol conversion - Set up thinking-mode reasoning config for Qwen series models - Base URL: http://127.0.0.1:11434/v1 Models included: qwen3.5:9b, qwen2.5:14b, qwen2.5:7b, qwen3:8b, gpt-oss:20b
'thinking' is not a valid CodexChatReasoningOutputFormat. Ollama's reasoning tokens arrive in delta.reasoning, so use 'reasoning'.
Codex Responses→Chat Completions conversion correctly computes effective_endpoint=/chat/completions but adapters build_url may drop the endpoint when base_url already ends with /v1 (e.g. Ollama). Add post-build URL check: if codex_responses_to_chat is active and the endpoint is missing from the final URL, manually append it. Fixes 404 when Codex proxies to Ollama or other local models.
1. Force supports_effort=false for Ollama/local providers
- resolve_codex_chat_reasoning_config now detects Ollama by
provider id, name, or base_url (127.0.0.1:11434) and
forces supports_effort=false regardless of meta values.
- Prevents Codex reasoning.effort param from reaching
Ollama upstream (which returns 400).
2. Fix health check URL for isFullUrl + chat providers
- When isFullUrl=true but base_url doesn't actually contain
/chat/completions (common for Ollama's base_url=v1/),
automatically fall back to non-full URL building.
- Fixes 404 in health check even if isFullUrl was
accidentally persisted by the form.
When the UI form overwrites meta, apiFormat can be cleared. Add is_ollama_provider() fallback in codex_provider_uses_chat_completions so the proxy always routes Ollama requests through Chat Completions even if the config field is missing.
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 8990c36630
ℹ️ 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".
| // Fallback: Ollama 等本地模型即使 meta.apiFormat 被表单覆盖清空, | ||
| // 也必须走 Chat 转换(Responses API 不被支持)。 | ||
| if is_ollama_provider(provider) { | ||
| return true; |
There was a problem hiding this comment.
Check Ollama before the TOML wire_api return
This fallback does not cover the stated meta-cleared case for the new preset: the Ollama preset is still generated with wire_api = "responses" in its TOML config, so when meta.apiFormat is absent codex_provider_uses_chat_completions returns false from the earlier TOML wire_api branch and never reaches this is_ollama_provider check. In restored/raw-provider scenarios that lose meta, Codex /responses requests are forwarded to Ollama as /v1/responses instead of being converted to /chat/completions, so the local provider breaks again.
Useful? React with 👍 / 👎.
Summary
Add Ollama as a built-in Codex provider preset so users can run Codex against local models (qwen3.5, qwen2.5, etc.) via CC Switch proxy.
Changes
New features
"local"category inProviderCategoryfor local models (Ollama, LM Studio, etc.)qwen3.5:9b,qwen2.5:14b,qwen2.5:7b,qwen3:8b,gpt-oss:20bsupportsThinking=true,supportsEffort=false,outputFormat="reasoning"Bug fixes
Codex Chat URL endpoint dropped (
forwarder.rs) — whencodex_responses_to_chatis active but adapterbuild_urldrops the endpoint (e.g. base_url already ends with/v1), manually append/chat/completions. Fixes 404 when proxying to Ollama.Health check 404 for
isFullUrlproviders (stream_check.rs) — whenisFullUrl=truebut the base_url doesn't actually contain/chat/completions(common for Ollama'shttp://127.0.0.1:11434/v1), auto-fallback to non-full URL building.Reasoning effort 400 for local models (
codex.rs) —resolve_codex_chat_reasoning_confignow detects Ollama providers (by id/name/base_url) and forcessupportsEffort=false, preventing Codex'sreasoning.effortparam from reaching Ollama upstream.Files changed
src/types.tssrc/config/codexProviderPresets.tssrc-tauri/src/proxy/forwarder.rssrc-tauri/src/proxy/providers/codex.rssrc-tauri/src/services/stream_check.rsTesting
cargo check: zero errors