Skip to content

fix(opencode): exit nonzero when run produces no assistant message - #13832

Merged
iscekic merged 2 commits into
mainfrom
kwf/surface-the-cli-packages-ope-c31e
Sep 7, 2026
Merged

fix(opencode): exit nonzero when run produces no assistant message#13832
iscekic merged 2 commits into
mainfrom
kwf/surface-the-cli-packages-ope-c31e

Conversation

@iscekic

@iscekic iscekic commented Sep 6, 2026

Copy link
Copy Markdown
Collaborator

Request

Surface: the CLI (packages/opencode).

kilo run exits 0 when the model returns no assistant message, so a caller cannot tell an empty run from a successful one. Reproduce first on a live CLI build: force a run that produces no assistant message and read its exit code. If it already exits non-zero, stop with the evidence and no code change. If it does not, exit non-zero with a clear stderr line, leave the exit code of a normal run unchanged, add a test beside the existing run tests, and show both exit codes in the PR body.

Changelog for users

  • kilo run now exits non-zero when the model returns no assistant message, printing run ended without an assistant message; the model returned no output to stderr. Previously an empty run exited 0, indistinguishable from a successful run.
  • A normal kilo run that produces assistant output still exits 0.

Changelog for maintainers

  • The run command now records whether any assistant output arrived (a tool part, or a non-empty text/reasoning part that finished) and sets the exit code to 1 when a completed run produced none; under --format json it emits a final error record with the same message instead of stderr.
  • A prompt-level request failure (result.error) keeps its own error as the only reported cause; the empty-output diagnostic is suppressed so a failed request does not also claim a silent model.
  • Exit codes: empty run reproduced live exiting 0 → now exits 1; a normal run stays at 0.
  • New subprocess tests beside the existing run subprocess tests cover the nonzero exit + stderr diagnostic, the JSON error record, and two request-failure cases that must not emit the empty-output diagnostic.
  • Review: the empty-output check sits at the end of the run command's drain; the request-failure cases exercise an oversized attachment that triggers a BadRequest, and the empty-output diagnostic must stay absent there.

E2E proof

Surface: the CLI (packages/opencode).

`kilo run` exits 0 when the model returns no assistant message, so a caller cannot tell an empty run from a successful one. Reproduce first on a live CLI build: force a run that produces no assistant message and read its exit code. If it already exits non-zero, stop with the evidence and no code change. If it does not, exit non-zero with a clear stderr line, leave the exit code of a normal run unchanged, add a test beside the existing run tests, and show both exit codes in the PR body.
@iscekic
iscekic marked this pull request as draft September 6, 2026 17:32
@iscekic
iscekic marked this pull request as ready for review September 6, 2026 17:38
@kilo-code-bot

kilo-code-bot Bot commented Sep 6, 2026

Copy link
Copy Markdown
Contributor

Code Review Summary

Status: No Issues Found | Recommendation: Merge

Files Reviewed (2 files)
  • packages/opencode/src/cli/cmd/run.ts
  • packages/opencode/test/cli/run/run-empty.process.test.ts

Reviewed by grok-4.6 · Input: 200.5K · Output: 20.1K · Cached: 841K

Review guidance: REVIEW.md from base branch main

@iscekic iscekic added the human-ready PR is ready for a human review. label Sep 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

human-ready PR is ready for a human review.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants