Description
opencode run --format json emits step_start / step_finish events with tokens and cost, but no model. Nothing in the stream says which model produced a step, so a headless consumer can't attribute usage or cost to a model.
The data isn't missing from opencode — only from the stream. opencode export <sessionID> has providerID / modelID on every assistant message, and the default (human) format already prints the model header. It just never reaches the JSON path.
This matters for multi-model sessions: switching models mid-session, or subagents running a different model than the parent, are unattributable today. Recovering it needs a second opencode export call after the run, which doesn't work for a live consumer.
Event keys, same across three runs: cost, id, messageID, reason, sessionID, tokens, type.
OpenCode version
1.14.28
Steps to reproduce
opencode run --format json -m opencode/ling-3.0-flash-free "Reply with exactly: OK"
- Continue that session with a different model:
opencode run --format json --session <sessionID> -m opencode/mimo-v2.5-free "Reply with exactly: SECOND"
- The
step_finish events from both turns are indistinguishable:
{"id":"prt_…","reason":"stop","messageID":"msg_fcdd0d049001VruQNZZOX4Z9LQ","sessionID":"ses_032300dcdffeods08f6tn9QMAy","type":"step-finish","tokens":{"total":21335,"input":20277,"output":4,"reasoning":30,"cache":{"write":0,"read":1024}},"cost":0}
opencode export <sessionID> on that same session does distinguish them:
msg_fcdcff80c001Cp | opencode / ling-3.0-flash-free
msg_fcdd0386f001gQ | opencode / ling-3.0-flash-free
msg_fcdd0d049001Vr | opencode / mimo-v2.5-free
Operating System
macOS 26.5
Terminal
VS Code integrated terminal
Description
opencode run --format jsonemitsstep_start/step_finishevents with tokens and cost, but no model. Nothing in the stream says which model produced a step, so a headless consumer can't attribute usage or cost to a model.The data isn't missing from opencode — only from the stream.
opencode export <sessionID>hasproviderID/modelIDon every assistant message, and the default (human) format already prints the model header. It just never reaches the JSON path.This matters for multi-model sessions: switching models mid-session, or subagents running a different model than the parent, are unattributable today. Recovering it needs a second
opencode exportcall after the run, which doesn't work for a live consumer.Event keys, same across three runs:
cost, id, messageID, reason, sessionID, tokens, type.OpenCode version
1.14.28
Steps to reproduce
opencode run --format json -m opencode/ling-3.0-flash-free "Reply with exactly: OK"opencode run --format json --session <sessionID> -m opencode/mimo-v2.5-free "Reply with exactly: SECOND"step_finishevents from both turns are indistinguishable:{"id":"prt_…","reason":"stop","messageID":"msg_fcdd0d049001VruQNZZOX4Z9LQ","sessionID":"ses_032300dcdffeods08f6tn9QMAy","type":"step-finish","tokens":{"total":21335,"input":20277,"output":4,"reasoning":30,"cache":{"write":0,"read":1024}},"cost":0}opencode export <sessionID>on that same session does distinguish them:Operating System
macOS 26.5
Terminal
VS Code integrated terminal