Skip to content

fix(codex-acp): honor config.toml model for custom providers (web chat)#2

Merged
scottzx merged 1 commit into
mainfrom
fix/codex-acp-respect-config-model
Jun 14, 2026
Merged

fix(codex-acp): honor config.toml model for custom providers (web chat)#2
scottzx merged 1 commit into
mainfrom
fix/codex-acp-respect-config-model

Conversation

@scottzx

@scottzx scottzx commented Jun 14, 2026

Copy link
Copy Markdown
Owner

Problem

Web 对话选 Codex + 自定义 provider(如 MiniMax)时,即便 ~/.codex/config.toml 配了 model = "MiniMax-M3",请求仍发出 gpt-5.5 并报错:

{"error":{"message":"unknown model 'gpt-5.5'","code":"invalid_prompt"}}

(关联 1agents issue openclaw#43,由 openclaw#41 vendor ACP adapters 暴露。)

Root cause

不在 1acp。1acp 全程没注入 model:bridge-server.js 只设 sessionOptions.systemPrompt,applyRequestedModelIfAdvertised 无 model 时是 no-op,codex-acp 启动也无 --model

真正原因在 vendored @agentclientprotocol/codex-acp@0.0.44createModelId():它在 codex listModels() 目录里找配置的 model,自定义 provider 的 model 不在目录中 → 回退到 isDefault(= gpt-5.5),并把它钉死在每个 runTurn 上。Codex CLI 对同样情况是保留配置的 model id,仅警告 "Model metadata not found"。

Fix

通过 pnpm patch 给 codex-acp 打补丁,行为对齐 CLI:目录里找不到就保留配置的 model id,只有 model id 为 null 时才回退 isDefault。下游 session state 对未知模型已有兜底(supportedReasoningEfforts ?? []inputModalities ?? ["text","image"])。

变更:

  • patches/@agentclientprotocol__codex-acp@0.0.44.patch(新增)
  • package.jsonpatchedDependencies
  • pnpm-lock.yaml

Verification

  • pnpm install 后 ACP 探针:session/newcurrentModelIdgpt-5.5MiniMax-M3[high]
  • 走完整 web 链路(bridge-server.js → patched codex-acp → codex → MiniMax):你好 正常回复,不再有 unknown model

Upstream

同等修复已提到 codex-acp 上游:agentclientprotocol/codex-acp#199。上游合并发版后可移除本补丁。

…-5.5

Patch @agentclientprotocol/codex-acp@0.0.44 so web chat honors the model
configured in ~/.codex/config.toml (e.g. a custom provider's MiniMax-M3)
instead of silently forcing the built-in default model.

codex-acp's createModelId() looked up the configured/returned model id in
codex's listModels() catalog and, when absent (custom providers expose no
catalog entry), substituted availableModels.find(m => m.isDefault) — i.e.
gpt-5.5. That id was then pinned onto every runTurn, so requests sent to a
custom endpoint failed with `unknown model 'gpt-5.5'`.

The codex CLI handles the same case by keeping the configured model id and
just warning "Model metadata not found. Defaulting to fallback metadata."
This patch mirrors that: keep modelId when it isn't in the catalog; only
fall back to isDefault when no modelId was provided at all. Downstream
session state already degrades gracefully (supportedReasoningEfforts ?? [],
inputModalities ?? ["text","image"]).

Verified end-to-end through bridge-server.js: session advertises
MiniMax-M3[high] and a prompt turn completes with a real MiniMax reply.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant