LoopForge icon indicating copy to clipboard operation
LoopForge copied to clipboard

[Bug]: Codex executor always advertises its builtin web_search, so every SOP node 400s behind an OpenAI-compatible gateway

Open egargale opened this issue 1 week ago • 1 comments

Component / host

Platform — runner / sandbox

Edition

Platform

LoopForge version

0.4.2 (ghcr.io/tencent/loopforge:0.4.2, commit 4ff0e73c), codex-cli 0.172.0

What happened?

A SOP/run node whose Agent uses the Codex executor fails on its first turn when Codex is pointed at an OpenAI-compatible gateway instead of api.openai.com. No ChatGPT/OpenAI subscription is involved: the credential is a plain API key for a user-supplied base URL, and the platform registers it as a dedicated provider (model_providers.agentflow_user.requires_openai_auth=false). Codex always advertises its own builtin web_search tool in the /v1/responses request, and a gateway fronting a non-OpenAI provider rejects the whole request:

400 responses_feature_not_supported: tool type 'web_search' is not supported by this gateway phase.

The node log shows only:

codex thread initialized
{ ... "status_code":400, "message":"tool type 'web_search' is not supported by this gateway phase." ... }
codex turn failed
执行器失败:exit status 1

The retry runs the same deterministic 400 again, so the node burns both attempts and the pipeline ends failed. No application code is ever read or changed, and exit status 1 hides the real cause from the node error.

This is specific to the run/SOP executor catalog. The AI-conversation path already disables the same builtin — internal/httpapi/assistant_provider.go:126 and internal/httpapi/assistant_engine_codex.go:33 both pass -c web_search="disabled" — so the same Codex installation and the same credential work in chat and fail in a run.

Expected: an unattended Codex run behaves like the chat path. The platform already states that MCP is the only tool allowlist for run nodes (internal/runtime/materialize.go), so a CLI builtin web tool should not be advertised at all.

Actual: every attempt is rejected by the gateway before the model sees the prompt.

Reproduction

  1. Platform 0.4.2, no ChatGPT subscription. The user's Codex API key + base URL (codex_base_url) point at an OpenAI-compatible gateway that routes to a non-OpenAI provider.
  2. Create an Agent with executor Codex and such a model (here Xiaomi/mimo-v2.6-pro), reference it from any Agent node in a published workflow, and start a run.
  3. The node fails within seconds: codex turn failed → 执行器失败:exit status 1, then the retry fails identically and the run is marked failed.
  4. Same gateway, same model, same credential, one extra flag — Codex completes a turn (see diagnostics). So the failure is the tool advertisement, not the gateway or the credential.

Workaround currently in use: pin the node to an executor that does not advertise a builtin web tool (pi, dsh), which runs fine against the same gateway and model.

Sanitized diagnostics

Executor shipped by 0.4.2 (internal/repo/catalog.go:238) — nothing disables the builtin:

{ID: "codex", Name: "Codex", Kind: "codex", Binary: "codex",
 Args: []string{"exec", "--json", "--sandbox", "workspace-write", "--skip-git-repo-check"}, Protocol: "jsonl"},

A/B against the same gateway, using the platform's own provider flags (CodexUserProviderArgv, internal/runtime/command_binding.go:227) and codex-cli 0.172.0. Host, key and thread ids removed:

# A — argv shipped by 0.4.2
$ codex exec --json --sandbox workspace-write --skip-git-repo-check \
    -c model_provider="agentflow_user" \
    -c model_providers.agentflow_user.base_url="<gateway-base-url>/v1" \
    -c model_providers.agentflow_user.wire_api="responses" \
    -m Xiaomi/mimo-v2.6-pro "reply with the single word OK"
{"type":"error","message":"{\"status_code\":400,\"error\":{\"message\":\"provider API error: data:{\\\"error\\\":{\\\"code\\\":\\\"responses_feature_not_supported\\\",\\\"message\\\":\\\"tool type 'web_search' is not supported by this gateway phase.\\\",\\\"type\\\":\\\"unsupported_feature\\\"}}...\",\"provider\":\"Xiaomi\",\"request_type\":\"responses_stream\"}}"}
{"type":"turn.failed","error":{...same 400...}}

# B — identical argv, plus the proposed flag
$ codex exec ... --skip-git-repo-check -c web_search="disabled" \
    -m Xiaomi/mimo-v2.6-pro "reply with the single word OK"
{"type":"item.completed","item":{"id":"item_1","type":"agent_message","text":"OK"}}
{"type":"turn.completed","usage":{"input_tokens":18613,"output_tokens":12,"reasoning_output_tokens":9}}

Proposed solution

Disable Codex's builtin web tool in the run executor definition, matching the conversation path and the "MCP is the only tool surface for runs" rule:

// internal/repo/catalog.go
{ID: "codex", Name: "Codex", Kind: "codex", Binary: "codex",
 Args: []string{"exec", "--json", "--sandbox", "workspace-write", "--skip-git-repo-check",
               "-c", `web_search="disabled"`}, Protocol: "jsonl"},

Also mirror it in the live-CLI harness (internal/runtime/cli_live_config.go:29, the codex case) so smoke runs exercise the same argv, and add a unit test asserting the flag stays in the built-in executor — it is one token, easy to drop in a later argv edit.

Alternatives considered:

  • Strip web_search from the request when a gateway answers responses_feature_not_supported. That needs a retry-and-rewrite layer per CLI tool surface; the codebase already chose "disable the builtin, route tools through MCP" for chat.
  • A per-executor "extra args" field in the catalog UI. More configuration surface than the problem needs, and the builtin is not part of the Agent's MCP allowlist anyway.
  • Document "do not use Codex behind non-OpenAI gateways" as the recommended setup. That leaves a working chat configuration unusable for runs and keeps a misleading exit status 1.

A related, distinct case already has an open report: for pi the gate MCP server was dropped from the rendered config ("args": null), not a tool advertised by the CLI. Fix proposed separately in #1312.

Safety checks

  • [x] I removed credentials, private endpoints, internal identifiers, and personal data.
  • [x] I searched existing issues for duplicates. (codex web_search, responses_feature_not_supported, codex 网关, web_search 不支持, codex gateway 400 → no existing report)

egargale avatar Nov 24 '26 17:11 egargale

Thank you for the report. I understand this as: a SOP node using the Codex executor against an OpenAI-compatible gateway fails on the first turn because the request still includes Codex's builtin web_search tool, while the chat path already turns that tool off. The version, reproduction steps, and actual versus expected behavior are already in the issue.

We've seen this and will look at it along with the existing issue queue.

cocofhu00 avatar Nov 24 '26 17:11 cocofhu00