Skip to content
This repository was archived by the owner on Nov 7, 2026. It is now read-only.
This repository was archived by the owner on Nov 7, 2026. It is now read-only.

fix(cli): non-interactive run can exit before printing its turn in two cases #50

Closed as not planned

Description

@brentyates-swx

Found by GPT-6 Sol during review of #49 (round 3). Both are existing opencode run (non-interactive) behavior, inherited from upstream and not introduced by #49.

  1. run --attach returns as soon as the HTTP request completes. finish() skips awaiting the event loop in attach mode (if (args.attach) return, added upstream in fix(opencode): await run event loop anomalyco/opencode#31389, "await run event loop", with no stated reason for the attach exception). The event stream is a separate connection, so the process can exit before the loop prints the answer or a provider error, and can exit 0 after an error.
  2. run --session <id> against a session still finishing an earlier turn. The loop breaks on the first session.status: idle for the session. That turn's idle can arrive after server.connected but before the new prompt starts, leaving the new request with no listener: output is lost, and a failed request falls back to the generic 500.

Why this isn't in #49: both change the completion contract of upstream-owned code, and the attach exception probably exists to avoid a hang (an attached event stream may never report idle for the directory scope). A fix needs to (a) find out why anomalyco#31389 excluded attach, then wait for the session's terminal event in attach mode too and propagate its error to the exit code, and (b) only treat idle as completion after the newly sent turn has been observed running.

Tests to add: a successful serve + run --attach with delayed event delivery; a run --session on a session with a turn in flight.

Refs #49

Activity

  1. brentyates-swx commented on Sep 26, 2026

    @brentyates-swx
    Author

    Closing as won't-fix. Fixing it would mean changing completion logic in inherited run.ts (attach mode was deliberately excluded from waiting upstream in anomalyco#31389), which adds divergence for a path no swXtch workflow currently relies on: plain in-process opencode run is unaffected. Reopen if a workflow comes to depend on non-interactive run --attach or --session.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions