Repository navigation
Conversation
Codex declares one exec_command tool and a freeform apply_patch, while the gateway advertises the official OpenCode toolset. Map those official tools onto Codex's tools whenever the client declares exec_command, translate their arguments, and keep freeform custom calls intact through Responses and streamed output. Also normalize null or missing Chat message content to an empty string: strict providers such as Alibaba DashScope and Cloudflare Workers AI reject the null that OpenAI-shaped clients send on tool-call-only assistant turns.
|
Thanks for the Codex compatibility work. Keeping this open pending blockers from static review of the current PR head: (1) tooladapt.go returns on non-Windows before registering the platform-independent patch transform, conflicting with the unconditional adapter test; (2) v1 read/write/edit use filePath but adapters only read path, and the PowerShell edit script emits true/false instead of the required dollar-prefixed booleans; (3) non-streaming Responses custom calls and Anthropic/Responses argument-delta adaptation are incomplete. Please validate protocol x streaming x platform coverage before merging. Main 14faec7 separately fixes Responses assistant-turn grouping and changes shaping helpers for optional prompt environments, so rebase against it and resolve overlapping request/tool files. No live upstream adapter verification was performed in this review. |
Summary
Codex declares a single
exec_commandtool plus a freeformapply_patch, while the gateway advertises the official OpenCode toolset. Models therefore calledshell/read/edit/… and Codex rejected them asunsupported call, retrying until the turn aborted.This change binds the official tools to Codex's tools when the client declares
exec_command, translates their arguments, and keepsapply_patchas a freeform custom tool in Responses and streamed output. It also normalizescontent: nullto""for strict Chat providers.Changes
internal/gateway/tooladapt.go: argument adapters forshell/bash→exec_command,todowrite→update_plan, and (on Windows)read/write/edit/glob/grep/webfetch/websearch/skill→ PowerShell commands. The scripts avoid .NET calls so they run in Codex's ConstrainedLanguage sandbox.internal/gateway/toolshape.go: Codex aliases and custom-tool detection; adapters are only registered whenexec_commandis declared, so Claude Code and OpenCode clients are unaffected.internal/protocol/{tools,response,stream,stream_emitter}.go: argument transforms, custom tool call plumbing, and conversion ofapply_patchinresponse.completed.internal/protocol/request.go: bridge custom tool calls and history, and normalize null or missing Chat message content to an empty string (fixes strict providers such as Alibaba DashScope and Cloudflare Workers AI returningThe content field is a required field).Testing
go test ./...go vet ./...codex-cli 0.169.0, including a freeformapply_patch, plus Chat and Responses upstream requests.