Expand description
OpenCode agent runner.
§CLI invocation
opencode run --format json -m {model} - < "{msg_file}"§Output format (run --format json)
NDJSON stream:
{"type":"step_start","timestamp":...,"part":{"type":"step-start","snapshot":"..."}}
{"type":"text","timestamp":...,"part":{"type":"text","text":"hello"}}
{"type":"step_finish","timestamp":...,"part":{"type":"step-finish","reason":"stop","cost":0,"tokens":{"total":17512,"input":17509,"output":3}}}§Token extraction
Tokens are in the step_finish event: part.tokens.{input,output,total}
§Free models
Discoverable via: opencode models | grep free
Discovered dynamically at startup with 1-hour cache.
Structs§
- Open
Code Runner - Runner for OpenCode agent.
Functions§
- discover_
free_ opencode_ models - Discover free opencode models, with 1-hour cache and background refresh.
- discover_
opencode_ models - Discover all opencode models, with 1-hour cache and background refresh.
- find_
opencode_ result - Extract a structured
AgentResultfrom OpenCode NDJSON output. - prime_
free_ model_ cache - Prime the free-model cache synchronously at startup.