Files
pipelines/docs/chat-backends.md
T

4.1 KiB

Chat backends

Chats can be created on more than one harness. OpenCode remains the default; Codex is available when its App Server control socket exists. The selected backend is stored on the operator-session row and returned as backend on every chat_sessions row, so a restart does not have to guess from the session id.

Codex

The adapter in internal/codex connects to the Codex App Server's Unix WebSocket control socket ($CODEX_HOME/app-server-control/app-server-control.sock, falling back to ~/.codex). It uses the operator's existing Codex login. A new chat issues thread/start; a prompt issues turn/start; history comes from thread/read; questions map from item/tool/requestUserInput to the normal question card and chat_answer returns the JSON-RPC response. Threads created this way are ordinary Codex threads and remain visible to the Codex app.

New threads retain the workspace-write sandbox and inherit Codex's configured approval policy (Pipelines no longer forces never). Command, file-change, network and explicit permission requests appear in the web approval cards. Each JSON-RPC callback has its own identity, including Code Mode subcommands sharing one item. Allow once maps to accept, session grants to acceptForSession, and Reject to decline; explicit permission profiles grant only requested fields. The web labels session scope explicitly, never as a permanent policy change.

Pending questions and approvals survive browser reconnects while the App Server connection lives. Standard MCP form/URL elicitation supports typed answers, Accept/Decline/Cancel and safe external links. Extended OpenAI elicitation is not advertised; unknown request formats return an explicit unsupported RPC error, not a fake empty success or silent auto-approval. App Server socket loss does not provide durable callback recovery; a disconnected transport is reported as an error rather than claiming old requests are still actionable.

Claude is not advertised as a backend until its sidecar and login flow are wired.

Web interaction contract

Both advertised chat adapters (OpenCode V2 and Codex) implement the same server contract for uploads, models, pending approvals, questions, form replies, interrupts, command readback and bounded output. Compile-time assertions and a browser regression run against both backend identities protect this contract; support is not satisfied by text streaming alone. Pi's pipeline executor is not advertised as a Pi web-chat adapter, and an unavailable Claude adapter is not presented as a working choice.

Codex uploads use native localImage for verified supported images. Other files are retained intact with an explicit server-local reference; the model's own tools inspect them rather than pretending their contents were already loaded. The saved next-turn model is also respected with uploads. Model sandbox and approval policy remain in force.

Codex's paged history retains tool and reasoning items, including structured MCP errors and Code Mode outputs, instead of discarding everything except text. Unknown item kinds remain inspectable. Tool detail is explicitly truncated at 64 KiB, not silently represented as complete. Running commands and their output use real command items plus read-only thread history; no unsupported terminal endpoint, process control, resumed turn or experimental flag is invented. Output reads are bounded and verify thread ownership. The installed Codex version exposes no API for controlling an agent-owned terminal through the separate, client-owned command/exec process IDs; those IDs are never conflated.

A fresh Codex connection can accept a turn without subscribing to its native thread notifications. The adapter therefore reconciles the latest turn through the read-only paged API and emits an authoritative-history resync when it changes. It does not call thread/resume on open/model selection, so merely watching a chat cannot awaken a queued goal. Native turn IDs protect the queue/UI from stale completion events. A real, isolated tool-free turn passed after replacing the owning connection; no command, permission grant or global setting was involved.