Skip to content

fix(vscode): prevent duplicate reasoning with subagent inspectors - #13430

Merged
marius-kilocode merged 1 commit into
mainfrom
investigate-duplicate-sse-rendering
Aug 25, 2026
Merged

fix(vscode): prevent duplicate reasoning with subagent inspectors#13430
marius-kilocode merged 1 commit into
mainfrom
investigate-duplicate-sse-rendering

Conversation

@marius-kilocode

Copy link
Copy Markdown
Collaborator

What Problem This Solves

Assistant reasoning and response text could appear twice while a turn was still streaming in Agent Manager. The duplication disappeared when the turn finished because the final persisted message.part.updated event replaced the temporary client-side text with the canonical server value.

This was especially easy to misdiagnose as duplicate SSE delivery because the persisted conversation and completed transcript were correct.

Why This Change Was Made

This fixes a regression introduced by #13173, feat(vscode): add subagent inspector tabs, merged on August 18. Its nested SessionProvider in SubagentPanel.tsx allowed the main Agent Manager transcript and an open subagent inspector to consume the same webview message object.

Solid stores proxy their underlying objects instead of copying them. When both providers adopted the same incoming reasoning or text part, their stores shared the same raw part object. Each provider then processed the same valid streaming delta and mutated part.text in place. A single " chunk" therefore changed "start" into "start chunk chunk". The original event payload was also mutated.

A live backend capture recorded 494 SSE frames, including 172 message.part.delta events, with zero duplicate event IDs. The regression was shared client-side object ownership, not duplicate backend events, reconnects, or durable live/sync compatibility envelopes.

The fix creates a shallow, provider-owned copy whenever incoming parts enter a session store, including history snapshots, initial message parts, new streamed parts, optimistic replacements, and cloud-session history. Shallow copies preserve existing nested data without copying streamed strings or dropping legitimate repeated provider output.

User Impact

Reasoning and response fragments now appear exactly once when the subagent inspector is open, including when multiple session providers process the same webview event. Final turn reconciliation, optimistic attachment replacement, session history, and completed reasoning rendering retain their existing behavior.

Evidence

  • Reproduced the original failure with two real Solid stores: one shared part plus one valid delta produced "start chunk chunk" before the fix.
  • Added regression coverage for both shared reasoning snapshots and streamed optimistic/canonical text parts.
  • Ran 4,149 extension unit tests, all passing.
  • Passed extension lint, extension/webview typechecks, Knip, the complete extension build, and the changeset check.
  • In an isolated VS Code instance, opened Agent Manager and its real subagent inspector so two SessionProvider instances were mounted, dispatched one reasoning delta through the actual webview message path, and verified exactly one rendered fragment plus an unchanged original event payload.

Subagent inspector reasoning renders a streamed fragment exactly once

@kilo-code-bot

kilo-code-bot Bot commented Aug 25, 2026

Copy link
Copy Markdown
Contributor

Code Review Summary

Status: No Issues Found | Recommendation: Merge

Files Reviewed (4 files)
  • .changeset/isolated-reasoning-streams.md
  • packages/kilo-vscode/tests/unit/session-parts.test.ts
  • packages/kilo-vscode/webview-ui/src/context/session-parts.ts
  • packages/kilo-vscode/webview-ui/src/context/session.tsx

Reviewed by grok-4.6 · Input: 98.2K · Output: 11.3K · Cached: 455.6K

Review guidance: REVIEW.md from base branch main

@marius-kilocode
marius-kilocode merged commit 145809f into main Aug 25, 2026
24 checks passed
@marius-kilocode
marius-kilocode deleted the investigate-duplicate-sse-rendering branch August 25, 2026 16:04
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.

2 participants