Use ContentThinkingDelta for streaming thinking#211
Closed
cpsievert wants to merge 8 commits intoui/thinkingfrom
Closed
Use ContentThinkingDelta for streaming thinking#211cpsievert wants to merge 8 commits intoui/thinkingfrom
cpsievert wants to merge 8 commits intoui/thinkingfrom
Conversation
Replace the ContentThinking accumulator pattern with
ContentThinkingDelta's phase-based inline construction. The phase
property ("start", "body", "end") lets the server build stored
messages with <thinking> tags in a single pass — no accumulator
or finally-block reconstruction needed.
- R: add ContentThinkingDelta dispatch in contents_shinychat
- Python: replace _is_content_thinking + accumulator with
_is_content_thinking_delta + phase-based message building
- Remove _current_stream_thinking field entirely
Depends on posit-dev/chatlas#299.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
ContentThinking still appears in non-streaming contexts like bookmark restore, so it needs to remain registered alongside ContentThinkingDelta. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Both packages need versions that export ContentThinkingDelta. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
6 tasks
The method registration fails at load time if the installed ellmer doesn't export ContentThinkingDelta yet. Guard with exists() so shinychat can still load with older ellmer versions. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
CI failure is expected until ellmer ships ContentThinkingDelta. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
gadenbuie
reviewed
May 8, 2026
Collaborator
gadenbuie
left a comment
There was a problem hiding this comment.
I think it'd be helpful if you could take a step back and discuss the problem you're wanting to solve with these additional PRs. It's hard to read between the lines of Claude's PR description to understand what part is bugging you and what problem you're wanting to solve. And I think it'd be best to do that in my original PR as a review so we can have that discussion there.
cpsievert
commented
May 8, 2026
6 tasks
Instead of computing content_type inside _send_append_message (via a content_type_override parameter), resolve it at each call site using a shared resolve_content_type() helper. This lets thinking content be detected from the original message before normalization loses the type, and handles both streaming (ContentThinkingDelta) and non-streaming (ContentThinking) paths uniformly.
c4dbf7a to
775bc64
Compare
cpsievert
commented
May 8, 2026
Comment on lines
+1617
to
+1619
| content_type=resolve_content_type( | ||
| message_dict, stored.content | ||
| ), |
Collaborator
Author
There was a problem hiding this comment.
Currently this won't restore the correct content type. We already have this problem on main though, and I think it's worth us actually fixing this.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Thinking content (
ContentThinkingDeltaandContentThinking) now flows through the same normalization and message-sending pipeline as all other content types, instead of being special-cased in the stream loop. This makes thinking a property of the message rather than the code path, so non-streaming thinking (e.g., bookmark restore) works correctly without separate handling.Dependencies
ContentThinkingDeltato chatlasContentThinkingDeltato ellmerWhat this replaces
Alternative to #210, which removed
content_type: "thinking"from the wire protocol entirely. This PR keeps the typed wire protocol while achieving the server-side simplification.TODO