Skip to content

fix: consolidate streaming thought partials into single bubble#444

Open
ferponse wants to merge 1 commit into
google:mainfrom
ferponse:fix/consolidate-streaming-thought-partials
Open

fix: consolidate streaming thought partials into single bubble#444
ferponse wants to merge 1 commit into
google:mainfrom
ferponse:fix/consolidate-streaming-thought-partials

Conversation

@ferponse
Copy link
Copy Markdown

Summary

When thought/reasoning chunks arrive via SSE streaming (e.g., Claude extended thinking, Gemini with thinking_config), each partial ReasoningChunk renders as a separate "Thought" bubble in the Dev UI instead of consolidating into one.

The consolidation logic in chat.component.ts correctly locates the existing partial thought event (lines ~1246/1255), but buildUiEventFromEvent creates a fresh UiEvent with only the current chunk's text. On replacement (line 1285), the previously accumulated text is lost.

Fix

Before replacing the existing thought event, prepend the existing thought text to the new event's text. This makes consecutive thought partials merge into a single progressively-growing bubble — matching the behavior of regular text streaming.

if (uiEvent.thought && existingEvent.thought) {
  uiEvent.text = (existingEvent.text || '') + (uiEvent.text || '');
}

Testing

  • All 459 existing tests pass (ng test --no-watch --browsers=ChromeHeadless)
  • Manually verified with vertex_ai/claude-sonnet-4-6 via LiteLLM with thinking={"type": "enabled", "budget_tokens": 10000}

Fixes #443

@google-cla
Copy link
Copy Markdown

google-cla Bot commented May 19, 2026

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

When thought chunks arrive via SSE streaming, each partial
ReasoningChunk was rendered as a separate Thought bubble instead
of being accumulated into one. The consolidation logic found the
existing partial thought event but replaced it without preserving
the accumulated text.

Prepend the existing thought text before replacing so consecutive
thought partials merge into a single progressively-growing bubble,
matching the behavior of regular text streaming.

Fixes google#443
@ferponse ferponse force-pushed the fix/consolidate-streaming-thought-partials branch from a94ba79 to 767c44d Compare May 19, 2026 14:52
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.

Streaming thought chunks render as separate bubbles instead of consolidating

1 participant