Skip to content

[Bug]: OpenCode: a background note steered into a run right after the answer folds the answer away #37816

Closed

Description

@nkoynov

What happens

With OpenCode 2, a background-work note (OpenCode's synthetic <shell> report) that arrives just as the model finishes its answer is delivered as a steer into the same execution. The model replies to it ("the server I used has stopped"), that reply becomes the run's last assistant message, and the timeline folds the real answer, often screenshots or file paths, into "Worked for …". On mobile the thread then shows only the reply to the note.

If the same note arrives a moment later, after the execution ended, it wakes the session, T3 opens a new run with a notification row, and the answer stays visible. So whether the answer is hidden comes down to timing.

Steps to reproduce (0.1.10-nightly.20261115.4736, OpenCode 2.3.0)

  1. In an OpenCode thread, have the agent start a background server, stop it in a way that lets it exit on its own (a stop file, docker stop), keep working for ~10 s, then give its final answer.
  2. The server's note is admitted while the execution is still running (we've seen it 16 ms after the answer finished), and OpenCode promotes it at the step boundary after the final text, in the same execution.
  3. The model answers the note. The thread shows that reply; the answer is folded.

Seen 2/2 with GPT-5.6 Sol (touch stop; sleep 10) and 1/1 with a scripted backend, plus in real use. With a 7–8 s pause the note landed just after the run instead and opened a new run, as described above.

Cause (main e65a790, same in 4736)

  • packages/provider-opencode/src/server/v2/adapter.ts:3369: a session.inbox.delivered for a report in the active turn only deletes the report and emits nothing. A note that wakes an idle session goes through offerWake / backgroundWorkNotification and gets a notification row and its own run.
  • apps/web/src/components/chat/MessagesTimeline.logic.ts: deriveTerminalAssistantMessageIds keeps one terminal assistant message per run and deriveTurnFolds folds by run, so even a notification row inside the same run wouldn't split the fold. Only an assistant message with phase: "final_answer" survives (retainedAssistantReplyEntryIds, line 771). Mobile has the same rule (finalAnswerIds in apps/mobile/src/lib/threadActivity.ts).

We replayed the thread items through 4736's own timeline logic: without a change the answer folds in every tool-visibility mode on web and mobile; a same-run notification row alone doesn't help; the row plus final_answer on the answer shows answer, row and reply.

Possible fixes (either)

  1. Adapter: when a report is delivered into the active turn and the turn's newest item is a completed assistant message, emit the same backgroundWorkNotification item a wake gets, in that run, and re-emit the message with phase: "final_answer" so the existing retention rule keeps it. Small, OpenCode only.
  2. Clients: treat a notification item inside a run like a steer in deriveTurnFolds (start a segment there) and keep each segment's last assistant message visible, on web and mobile. Covers any provider that injects notices into a running turn.

We run option 1 locally as a server preload and can share it.

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions