Skip to content

run --format json: final step_finish is missing #54661

Closed as duplicate
Closed as duplicate

Description

@oldantique

With opencode v2.0.26 (9b4ec57) on Linux x86_64, --standalone, model deepseek/deepseek-v4-flash, successful --format json runs never print a step_finish for the final step.

Repro

cd "$(mktemp -d "$HOME/oc-json.XXXXXX")" && git init -q
opencode run --standalone --format json --model deepseek/deepseek-v4-flash "Reply with exactly: OK"
echo "exit=$?"

stdout (abbreviated):

{"type":"step_start","part":{"type":"step-start", ...}}
{"type":"text","part":{"type":"text","text":"OK", ...}}

exit=0, and no step_finish.

Same in 8/8 JSON runs: two plain replies and six runs with file reads. Runs that call tools print step_finish (reason tool-calls) for every intermediate step, but not for the final one; every stream ends on text.

Expected

The final step's step_finish, with its finish reason, tokens and cost. Those fields are currently missing from stdout for the last step, which is the only step in a plain reply.

Possible cause

From reading packages/cli/src/run/noninteractive.ts (not an instrumented trace): once session.wait resolves, finalizing is set and output is reconciled; from then on the consumer skips every event that is not session.execution.*, including session.step.ended, and reconciliation does not restore step_finish. The subscription is then aborted without draining pending events.

Background: #36413 and #50341 were closed in the V1 freeze with a request to retest on V2. The original empty-stdout symptom did not reproduce on 2.0.26; this report is only about the missing final step_finish.

Activity

  1. opencode-agent commented on Oct 12, 2026

    @opencode-agent
    Contributor

    Thanks for the clear report and for retesting on v2. I think this is a duplicate of #53207, which reports the same missing final step_finish in the v2 opencode run --format json client and points to the same cause in packages/cli/src/run/noninteractive.ts: once session.wait resolves and finalizing is set, events other than session.execution.* are skipped, and reconcile() doesn't rebuild step_finish.

    Possible duplicates and related issues, ordered by likelihood:

    It would help to add to #53207 that this still happens on 2.0.26 on Linux with deepseek/deepseek-v4-flash. The bot will close this issue as a duplicate in 1 day unless you reply explaining how your problem is different.

  2. opencode-agent commented on Oct 13, 2026

    @opencode-agent
    Contributor

    We haven't heard back, so we're closing this as a duplicate of #53207. That issue covers the same missing final step_finish from opencode run --format json in the v2 client, with the same suspected cause in noninteractive.ts. Please follow #53207 for updates. If you can, add a note there that it still happens on 2.0.26 on Linux with deepseek/deepseek-v4-flash. If your problem turns out to be different, reply here and we'll take another look. Thanks for the detailed report!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions