GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Bug: `opencode run` output truncated in non-interactive mode - missing assistant response and step_finish · Issue #31365 · anomalyco/opencode

Bug: opencode run output truncated in non-interactive mode - missing assistant response and step_finish #31365

New issue
Copy link
New issue
Copy link
Closed as duplicate
Closed as duplicate
Bug: opencode run output truncated in non-interactive mode - missing assistant response and step_finish#31365
Copy link
Assignees
StarpTech

Description

@mingfang
mingfang
opened on Jun 8, 2026
Issue body actions

Bug Report

When using opencode run in non-interactive mode, the output is truncated after step_start. The assistant response text and step_finish event are never emitted.

This affects all output formats (JSON, plain text, etc.) — not just --format json. The core issue is that the event subscription is fire-and-forget and the process exits before events finish flowing through.

Steps to Reproduce

bun opencode run "What is 2+2?" --format json

Expected Output

All events should be emitted:

  1. text - user message
  2. step_start - step initiated
  3. text - assistant response
  4. step_finish - step completed

Actual Output

Only text (user message) and step_start are emitted. The process exits before emitting:

  • The assistant response text event
  • The step_finish event

Root Cause

In commit eab329d0de (fix(run): restore non-interactive exit behavior #27371), the loop function was changed from await completed to fire-and-forget.

Before (correct):

const completed = loop(client, events)
await client.session.prompt({...})
const error = await completed  // waits for event loop to finish

After (broken):

loop(client, events).catch(...)  // fire-and-forget
await client.session.prompt({...})
return  // process exits before cleanup events emit

The event subscription runs asynchronously. When prompt returns and the function exits, the SSE subscription hasn't finished emitting the remaining events (assistant text stream, step-finish). The process terminates, truncating the output.

Why It Doesn't Affect Interactive Mode

Interactive mode (opencode run "message" without --format json) keeps the TUI/CLI alive until the user exits. Events continue to flow as long as the process is running. Non-interactive mode exits immediately after prompt returns.

Impact

  • Programmatic output broken: Any consumer of opencode run stdout gets an incomplete response
  • Sessions appear hung: Users see the assistant appear to not respond
  • Tool calls silently dropped: Tool execution events after step_start are never emitted

Proposed Fix

Either:

  1. Revert the loop to be awaited (like before commit eab329d), or
  2. Add a mechanism to wait for session idle before exiting (e.g., polling session.status() until idle, then a short delay for SSE cleanup)

Activity

  1. github-actions
    assigned
    StarpTech
    on Jun 8, 2026
  2. github-actions commented on Jun 8, 2026

    @github-actions
    github-actionsBot
    on Jun 8, 2026 – with GitHub Actions
    Contributor
    More actions

    This issue might be a duplicate of existing issues. Please check:

    • run --format json can exit before emitting final step_finish event #26855: run --format json exits before emitting final step_finish event - same symptom of truncated JSON output missing step_finish
    • CLI: JSON stream output truncated when process exits quickly (stdout buffer not flushed) #29866: CLI JSON stream output truncated when process exits quickly - same symptom of output stopping after step_start

    If your issue is distinct or provides additional context (e.g., the specific commit regression identified here), please clarify how it differs from those issues.

  3. mingfang
    changed the title [-]Bug: `opencode run --format json` output truncated - missing assistant response and step_finish events[/-] [+]Bug: `opencode run` output truncated in non-interactive mode - missing assistant response and step_finish[/+] on Jun 8, 2026
  4. rekram1-node commented on Jun 8, 2026

    @rekram1-node
    rekram1-node
    on Jun 8, 2026
    Member
    More actions

    AUTOMATED: closing as duplicate of: #26855

  5. rekram1-node
    closed this as a duplicateof run --format json can exit before emitting final step_finish event #26855 on Jun 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

  • @StarpTech
    StarpTech

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    You are visitor 01402775 — GeezerVison does not store the pages you look up.
    Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.