061. OpenCode is a harness, over its ACP server

Status: accepted 2026-10-16 — built the same day

Context

ADR-054 made harnesses pluggable and named OpenCode as one of the two open ones worth having ("the open ones matter — pi and OpenCode"). pi followed; OpenCode did not.

The question was never whether it could be added — the plug-in point exists — but which of OpenCode's transports fits a session. A session is a long-lived process that takes turn after turn, streams what it is doing, and can be interrupted. Measured on opencode 1.19.2:

So ACP is the transport — not opencode serve, which this was expected to need. The earlier guess was that a harness for OpenCode would have to be a server: start opencode serve, speak HTTP to it, and add a second kind of process behind the same Codec idea. It was wrong, and nothing like it was needed: ACP is stdio, the shape the plug-in point already had.

This ADR records the things that followed from using it, none of which were obvious before trying it.

Decision

OpenCode is a harness, spoken to over ACP.

1. The codec writes while decoding — the interface had to say so

Every other harness here writes at one of three moments: when the process starts (Start), for a turn (Turn), or to answer a prompt (Respond). Decode only ever produced events for the apps.

ACP cannot work that way. The session does not exist until initialize is answered with session/new, and the session id that comes back is what every session/prompt needs. Worse, a device may send a message the moment a session is up — Session.SendID writes it at once — so a turn can arrive before there is a session to put it in.

So a codec must be able to answer its process while reading from it. That is a capability, not something every harness has, so it is opt-in — the way Transcripts, Gatewayed and CageEnv are: Answering, whose Decoding() returns what the codec queued to write, and the read loop writes that before the messages from the same line. Claude Code and pi do not implement it and their codecs are unchanged — they do not carry a return value they would never use, which is what the first draft of this change did to them.

2. The session is created by a round trip, so a turn can be queued

The turn that arrives before the session exists is kept and goes out with the session/new request. Dropping it would be a message the person watched leave and never arrive.

3. OpenCode raises no permission request, so auto-approve is not offered

Claude Code is started with --permission-prompt-tool stdio, which is what turns a permission prompt into a control request a session answers — the basis of the apps' approve button and of Caps.Approve.

OpenCode has no equivalent. Measured twice: asked to write a file, it wrote it with no prompt, both through run without --auto and over ACP. Its permission config decides per action — run, block, or ask inside a TUI — and nothing reaches a client. So Caps.Approve is false, rather than offered and doing nothing.

Its session/new also ignores a system prompt (a systemPrompt param asking for BANANA was ignored and the model answered Paris), so the session's own note goes on the first prompt as a block of its own, once.

Consequences

What was not verified