Skip to content

[NO-JIRA] Stream Claude thinking as it arrives instead of at block end - #20

Merged
johnnymo87 merged 1 commit into
patched/v1.54.0from
thinking-stream
Nov 22, 2026
Merged

johnnymo87 merged 1 commit into
patched/v1.54.0from
thinking-stream

Conversation

@johnnymo87

Copy link
Copy Markdown
Owner

Description

Claude thinking now streams to clients as it is generated, instead of arriving all at once when the thinking block ends. On cloudbox, honk chat sat silent for ~9 s and then got the whole thought in one agent_thought_chunk, although Vertex streams thinking_delta events the whole time.

  • formats/anthropic.rs response_to_streaming_message: each thinking_delta (and any initial text in content_block_start) is yielded as an unsigned Thinking block carrying the message id. At content_block_stop only the signature is yielded. Omitted thinking (no deltas) still yields its signed empty block. Covers gcp_vertex_ai, anthropic, databricks_v2, kimicode, muse_code and declarative Anthropic-engine providers.
  • Storage is unchanged: Conversation::push and collect_stream already merge unsigned deltas and adopt the trailing signature (upstream fix(goose): coalesce streaming Thinking deltas + list available tools on not-found aaif-goose/goose#9162), which is what made refactor(anthropic): fix N+1 thinking message storage issue aaif-goose/goose#7958's buffering necessary at the time and unnecessary now.
  • The toolshim accumulator in reply_parts.rs only joined text, so it gets the same thinking-merge rule.
  • New tests are added to patched-release.yml's test-patches list.

Verified on Vertex claude-opus-5-5 with the built CLI (isolated GOOSE_PATH_ROOT), legacy loop and GOOSE_STATE_MACHINE=1: every assistant turn stored exactly one Thinking block with the joined text and signature; a second turn, /compact, a post-compact turn and a two-tool-call turn all replayed signed thinking with no API errors; requests still carry display: summarized (#19). Cache-miss breaker (#17) and role effort (#18) tests pass.

Behaviour change worth knowing: a turn cancelled or cut off mid-thinking now keeps the partial unsigned thinking, the same way partial text is already kept. Anthropic-family providers drop unsigned thinking on replay, so it does not reach the API.

No upstream equivalent exists: aaif-goose main still buffers (checked 2026-11-21). Porting to v1.60.2: the same edit applies; there the parser routes yields through if held.is_empty() { yield } else { held.push(..) } (from aaif-goose#13226), and thinking deltas should use that same pattern. The toolshim hunk applies as is.

References

…ock_stop

The Anthropic SSE parser accumulated thinking_delta and signature_delta and
yielded the whole block at content_block_stop, so ACP clients saw nothing
while the model thought and then the whole thought at once. Yield each
thinking_delta as an unsigned Thinking block with the message id, and at
content_block_stop yield only the signature. Conversation::push and
collect_stream already merge unsigned deltas and adopt a trailing signature
(upstream aaif-goose#9162), so storage still holds one signed block per thinking block.
Omitted thinking (no deltas) still yields its signed empty block.

The toolshim accumulator in reply_parts only joined text, so it gets the same
thinking merge rules.
@johnnymo87
johnnymo87 merged commit 3a1f730 into patched/v1.54.0 Nov 22, 2026
5 checks passed
johnnymo87 added a commit to johnnymo87/workstation that referenced this pull request Nov 22, 2026
…es (#899)

#### Description

- Bumps pkgs/goose to patched-1.54.0.18, which adds patch 25
(johnnymo87/goose#20). The Anthropic SSE parser now yields each
`thinking_delta` as it arrives instead of buffering the block until
`content_block_stop`, so honk chat shows Claude's thinking before the
reply instead of after ~10 s of silence.
- Storage is unchanged: each thinking block is still stored once,
signed. This was verified on Vertex claude-opus-5-5 across a follow-up
turn, `/compact` and tool-call turns.
- There is no schema change. goose-serve picks up the binary on a manual
restart in a quiet window, or at the nightly reset.
- All three asset hashes were prefetched from the release. The
aarch64-linux package builds and passes its `--version` check.

#### References

- workstation-6w7i.25
- johnnymo87/goose#20
johnnymo87 added a commit that referenced this pull request Nov 22, 2026
…ock_stop (#20)

The Anthropic SSE parser accumulated thinking_delta and signature_delta and
yielded the whole block at content_block_stop, so ACP clients saw nothing
while the model thought and then the whole thought at once. Yield each
thinking_delta as an unsigned Thinking block with the message id, and at
content_block_stop yield only the signature. Conversation::push and
collect_stream already merge unsigned deltas and adopt a trailing signature
(upstream aaif-goose#9162), so storage still holds one signed block per thinking block.
Omitted thinking (no deltas) still yields its signed empty block.

The toolshim accumulator in reply_parts only joined text, so it gets the same
thinking merge rules.

Ported from 3a1f730 and 47c99a8 onto v1.60.2.
Adaptation: resolved test conflict in anthropic.rs alongside upstream aaif-goose#13029; included Vertex summarized-thinking test from 47c99a8 (formats/gcpvertexai.rs); dropped 9180e7e (upstream aaif-goose#13029 already present); deferred CI workflow changes to dedicated CI commit.
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.

1 participant