AnyAgent

opencode

Use opencode through AnyAgent: what you can ask for, how it behaves, and the endpoint underneath.

The opencode adapter drives the opencode CLI over ACP (opencode acp), detected as the opencode binary on PATH; import opencode from anyagent-js/opencode. opencode is bring-your-own-key (BYOK): it reads standard provider keys (OPENROUTER_API_KEY, ANTHROPIC_API_KEY, …) from the environment.

What you can ask for

model (as "provider/model"), readOnly, resume, forkSession, attachments, and mcp work on the endpoint’s own channels; systemPrompt and schema are provided by AnyAgent. effort is undeclared and throws: the endpoint offers no effort setting. models() runs opencode models, every printed provider/model id valid verbatim as model; authStatus() reads ~/.local/share/opencode/auth.json plus the provider key env vars, a hint rather than a guarantee. The full grid is on the support matrix.

Good to know

  • Every turn runs on a live connection, so sessions steer; the session id lands on result.sessionId and is what resume takes back.
  • readOnly: true rests on two mechanisms at once: the session switches into plan mode, which covers edits, and every permission request for a tool that is not reading is denied, which covers the rest.
  • mcp servers are added to whatever the machine already configures rather than replacing them, each under the name you key it by.
  • Usage is the endpoint’s own accounting from the finished turn — tokens, cache reads, and thinking tokens where it reports them.

Under the hood

Every session launches opencode acp and configures it over the protocol; the prompt travels as a content block. Run options become:

OptionChannel
modelconfig option model, as "provider/model"
cwdthe cwd of the new session, and of the endpoint process
readOnly: trueconfig option mode: "plan", plus a denial of every permission request for a tool that could change the machine
resumesession/load with the session id
forkSession: truesession/fork with the session id, branching instead of continuing
attachmentsa resource_link block per file, beside the prompt text
mcpmcpServers on session/new, per command or url

On this page