Under opencode 2, live thinking streams as answer text and turns grey only when it ends #177

Closed
opened 2026-10-16 17:54:40 -04:00 by cmoriarty · 1 comment
Owner

Found in run 67, the first run on opencode 2 (#171) and llama.cpp. With Show thinking on, a thought streams onto the screen in white, like answer text. It turns grey, as a thought, only when the model moves on to its next statement. The Thinking indicator is not shown while it streams.

Cause

It's the opencode 2 adapter, not llama.cpp: opencode 2 tags the stream as reasoning (session.reasoning.delta).

  • The console decides how to draw a live part from the stream's kind. Measured on run 67's live stream: 400 of 400 frames for part prt_…-reasoning-0 had kind: "", so the console drew them as answer text.
  • On opencode 1.x, kind came from message.part.updated, which opencode sent for a part before its first delta. The delta buffer remembered the type from it.
  • opencode 2 has no such event. src/osf/agent/v2.py's delta handler turns session.reasoning.delta into a 1.x message.part.delta with only field: "text", and drops the kind it was called with.
  • So the buffer first learns the kind from session.reasoning.ended, the moment the part settles. That is the grey.

Fix

The adapter's delta carries the kind it fills (partType). DeltaFrame keeps it, and the delta buffer records it as it feeds the delta. Every frame then says reasoning or text, including the first frame after a reconnect in the middle of a part.

Announcing at session.reasoning.started instead was considered. It would write an extra revision per part into the log, and a reconnect in the middle of a part would still miss the kind.

Done when

  • A unit test replays the recorded opencode 2 reasoning session: each delta's kind is known before its part settles.
  • The adapter's existing tests stay green, including that the stream and the message list give the same parts.
  • On production, with Show thinking on, a live thought draws as a thought from its first token.
Found in run 67, the first run on opencode 2 (#171) and llama.cpp. With **Show thinking** on, a thought streams onto the screen in white, like answer text. It turns grey, as a thought, only when the model moves on to its next statement. The Thinking indicator is not shown while it streams. ## Cause It's the opencode 2 adapter, not llama.cpp: opencode 2 tags the stream as reasoning (`session.reasoning.delta`). - The console decides how to draw a live part from the stream's `kind`. Measured on run 67's live stream: 400 of 400 frames for part `prt_…-reasoning-0` had `kind: ""`, so the console drew them as answer text. - On opencode 1.x, `kind` came from `message.part.updated`, which opencode sent for a part before its first delta. The delta buffer remembered the type from it. - opencode 2 has no such event. `src/osf/agent/v2.py`'s delta handler turns `session.reasoning.delta` into a 1.x `message.part.delta` with only `field: "text"`, and drops the kind it was called with. - So the buffer first learns the kind from `session.reasoning.ended`, the moment the part settles. That is the grey. ## Fix The adapter's delta carries the kind it fills (`partType`). `DeltaFrame` keeps it, and the delta buffer records it as it feeds the delta. Every frame then says `reasoning` or `text`, including the first frame after a reconnect in the middle of a part. Announcing at `session.reasoning.started` instead was considered. It would write an extra revision per part into the log, and a reconnect in the middle of a part would still miss the kind. ## Done when - A unit test replays the recorded opencode 2 reasoning session: each delta's kind is known before its part settles. - The adapter's existing tests stay green, including that the stream and the message list give the same parts. - On production, with Show thinking on, a live thought draws as a thought from its first token.
Author
Owner

Shipped in 55f376c (change live-thought-from-its-first-word, commit daa43d2), live since 23:32Z on 2026-10-16, and archived in 2f7d842.

  • opencode 2's adapted deltas now carry the type of part they fill (partType). DeltaFrame keeps it as kind, and the delta buffer records it as it feeds each delta.
  • So every stream B frame says reasoning or text from the first word, a reconnect in the middle of a part included. opencode 1.x's deltas carry no type, and still use the part's announcement.
  • Checked on production in the verification run (run_01M53R7621CJW6PCZG7S6R94HS, thorough on cmoriarty/braid-combined-test, vLLM): openspec.explore's live frames were 174 reasoning and 8 text. openspec.propose.proposal had 247 reasoning. The two spec children had 294 and 15, and 359 and 12. agent.revise.operator had 344 and 7. No frame had an empty kind.
  • Test: the recorded opencode 2 reasoning session, fed into the delta buffer, has each delta's kind before its part settles. It fails without the fix.

Closing.

Shipped in 55f376c (change `live-thought-from-its-first-word`, commit daa43d2), live since 23:32Z on 2026-10-16, and archived in 2f7d842. - opencode 2's adapted deltas now carry the type of part they fill (`partType`). `DeltaFrame` keeps it as `kind`, and the delta buffer records it as it feeds each delta. - So every stream B frame says `reasoning` or `text` from the first word, a reconnect in the middle of a part included. opencode 1.x's deltas carry no type, and still use the part's announcement. - Checked on production in the verification run (`run_01M53R7621CJW6PCZG7S6R94HS`, thorough on cmoriarty/braid-combined-test, vLLM): openspec.explore's live frames were 174 reasoning and 8 text. openspec.propose.proposal had 247 reasoning. The two spec children had 294 and 15, and 359 and 12. agent.revise.operator had 344 and 7. No frame had an empty kind. - Test: the recorded opencode 2 reasoning session, fed into the delta buffer, has each delta's kind before its part settles. It fails without the fix. Closing.
Sign in to join this conversation.
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
cmoriarty/braid#177
No description provided.