Skip to content

fix: drain pending events before breaking on session idle in JSON format mode#31434

Closed
jangel97 wants to merge 1 commit into
anomalyco:devfrom
jangel97:dev
Closed

fix: drain pending events before breaking on session idle in JSON format mode#31434
jangel97 wants to merge 1 commit into
anomalyco:devfrom
jangel97:dev

Conversation

@jangel97

@jangel97 jangel97 commented Jun 8, 2026

Copy link
Copy Markdown

Summary

Fixes #31435

  • opencode run --format json breaks immediately on session.status = idle, but in containerized environments the idle event races ahead of text and step-finish part events in the SSE pipeline, producing incomplete JSONL output (only step_start emitted)
  • Track active step lifecycle with a counter; when idle arrives while steps are still open, defer the break and drain remaining events with a 3s safety timeout
  • Fixes JSON streaming in CI/containerized environments where event delivery latency is higher

Test plan

  • Run OPENCODE_EXPERIMENTAL=true opencode run --format json -m <provider/model> "Say hello" and verify all three JSONL events appear: step_start, text, step_finish
  • Verify non-JSON mode (opencode run "Say hello") still works as before
  • Verify multi-step responses (tool calls) emit correct step_start/step_finish pairs
  • Verify timeout fires if step-finish is never received (edge case)

…mat mode

The loop() function in opencode run --format json breaks immediately
when it receives a session.status = idle event. In containerized
environments, this event races ahead of text and step-finish part
events in the SSE pipeline, causing incomplete JSONL output (only
step_start emitted).

Track active step lifecycle with a counter. When idle arrives while steps
are still open, defer the break and drain remaining events with a 3s
safety timeout.
@github-actions github-actions Bot added the needs:compliance This means the issue will auto-close after 2 hours. label Jun 8, 2026
@github-actions

github-actions Bot commented Jun 8, 2026

Copy link
Copy Markdown
Contributor

This PR doesn't fully meet our contributing guidelines and PR template.

What needs to be fixed:

  • PR description is missing required template sections. Please use the PR template.

Please edit this PR description to address the above within 2 hours, or it will be automatically closed.

If you believe this was flagged incorrectly, please let a maintainer know.

@github-actions

github-actions Bot commented Jun 8, 2026

Copy link
Copy Markdown
Contributor

Thanks for your contribution!

This PR doesn't have a linked issue. All PRs must reference an existing issue.

Please:

  1. Open an issue describing the bug/feature (if one doesn't exist)
  2. Add Fixes #<number> or Closes #<number> to this PR description

See CONTRIBUTING.md for details.

@github-actions

github-actions Bot commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

This pull request has been automatically closed because it was not updated to meet our contributing guidelines within the 2-hour window.

Feel free to open a new pull request that follows our guidelines.

@github-actions github-actions Bot removed the needs:compliance This means the issue will auto-close after 2 hours. label Jun 9, 2026
@github-actions github-actions Bot closed this Jun 9, 2026
@jangel97

jangel97 commented Jun 9, 2026

Copy link
Copy Markdown
Author

Created new PR with correct description format #31446

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

opencode run --format json drops text and step-finish events in containerized environments

1 participant