opencode
v0.1.9OpenCode as an iii worker — opencode::* functions run headless OpenCode turns, mirror raw JSON events onto opencode::events, and stream AgentEvent frames onto agent::events.
exact versions are immutable; binary and bundle artifacts are digest-pinned.
skill doc
opencode
The opencode worker exposes the OpenCode API as iii functions. One
opencode::run call executes one headless OpenCode turn — the same agent the
user runs in their terminal, with the same tools — in a chosen working
directory, and returns the final result, token usage, and cost. Every JSON
event OpenCode emits (step_start, text, tool_use, step_finish) mirrors
verbatim onto opencode::events; a translated AgentEvent view lands on
agent::events, which the iii console and the acp worker render.
Requires the opencode CLI on the host and an API key for the LLM provider you
use (e.g. ANTHROPIC_API_KEY, or opencode auth). When a turn needs a
capability beyond OpenCode itself, add another iii worker to the bus instead of
bolting anything onto this one.
When to Use
- Delegate a whole coding task ("add an endpoint and run the tests") in one
call:
opencode::runwithpromptandcwd. - Continue a conversation across calls: pass the same
session_idagain and the worker resumes the underlying OpenCode session (--session). - Run long jobs without holding the call open:
opencode::startreturns{session_id, started}immediately; followagent::events(group_id = session_id) for the rendered view oropencode::eventsfor raw JSON; interrupt withopencode::stop. - Act on the whole backend: turns carry the iii runtime context by default, so
the agent discovers and calls any registered function through the iii CLI
(engine::functions::list,
iii trigger); disable per turn with--help iii_context: false. - Pick a model or agent per turn:
modelasprovider/model,agentas an OpenCode agent name.
Boundaries
- Spawns the host
opencodeCLI per turn — needs OpenCode installed and a provider key; not available in a bare container without it. opencode::run/opencode::startare not agent-callable without human approval (they spawn a full agent with the host's shell + filesystem); read-only introspection is allowed (see iii-permissions.yaml).- One turn per session at a time: check
opencode::status(live: true) before anotheropencode::runfor the samesession_id.
Functions
opencode::run— run one turn, wait; acceptsprompt(or amessagesarray), plusmodel,cwd,agent,iii_context; returns{session_id, opencode_session_id, result, stop_reason, usage, total_cost_usd}.opencode::start— same payload, returns{session_id, started}immediately.opencode::stop— interrupt the live run for a session.opencode::status— point-in-time session view: live flag, status, turns, usage, cost.opencode::sessions::list— every session this worker has run.run::start_and_wait— alias foropencode::rununder the entrypoint the console and acp worker drive.