You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 513c99a
Browse filesBrowse the repository at this point in the historyBrowse files
fix: treat non-empty finalText as success regardless of finish reason
Workaround for two open upstream bugs in OpenCode's `run --format json`:
- anomalyco/opencode#26855 — race in cmd/run.ts: the run loop observes
session.status=idle and exits before draining the final step_finish
event to stdout, so lastReason stays undefined even though the model
produced a complete response. Reproduced on prod with an explore
workflow where a one-token "READY" reply from openai/gpt-5.5 came
through as `text` but no step_finish ever followed.
- anomalyco/opencode#27697 — JSON formatter drops post-tool-call assistant
text, surfacing as step_finish.reason="tool-calls" alongside a
terminal text completion that has no callable tool_use parts.
Both manifest as "OpenCode exited cleanly with a final text response
but the terminal accounting event never made it through." Until they
land upstream, generalize OpencodeAccumulator.stopReason() to trust the
text: any clean exit with non-empty finalText and no error events =
success, regardless of lastReason. Mirror in chatResultFromTurn for the
opencode-serve chat path, which has the same class of bug surfaced
through `turn.finish` instead. Genuine truncation (model wanted more
turns but got cut off) still leaves finalText empty and surfaces as
the original error_<reason>.
Cost is small: on affected runs we lose token/cost accounting from the
missing step_finish, but we already have the answer. Revisit when
anomalyco/opencode#26855 and anomalyco/opencode#27697 are resolved.
Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
0 commit comments