Skip to content

fix(agent): preserve resumed text segments - #3535

Merged
kojiwakayama merged 2 commits into
mainfrom
fix/issue-337-resumed-text-segment
Aug 10, 2026
Merged

kojiwakayama merged 2 commits into
mainfrom
fix/issue-337-resumed-text-segment

Conversation

@kojiwakayama

@kojiwakayama kojiwakayama commented Aug 10, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • assign a fresh content ID when assistant text resumes after tool activity
  • keep active and legacy lifecycle adapters aligned
  • namespace text IDs across later model steps
  • add production-shaped regression coverage for the missing first character

Verification

  • deno test --no-check --allow-all src/agent/runtime/chat-stream-handler.test.ts src/agent/streaming/lifecycle/live-adapter.test.ts src/agent/runtime/refresh.test.ts
  • deno fmt --check src/agent/runtime/chat-stream-handler.ts src/agent/runtime/chat-stream-handler.test.ts src/agent/runtime/index.ts src/agent/runtime/refresh.test.ts src/agent/streaming/lifecycle/live-adapter.ts
  • deno task verify:quick
  • deno task test:unit
  • deno task audit

Closes veryfront/veryfront-issue-inbox#337

Summary by CodeRabbit

  • Bug Fixes
    • Improved streamed assistant responses after tool activity, preserving resumed text in distinct segments.
    • Prevented text segments from reusing identifiers across agent steps or interruptions.
    • Ensured text-start, text-delta, and text-end events consistently reference the correct segment for smoother streaming.
  • Tests
    • Added coverage for resumed text and step-specific streaming events across supported streaming lifecycles.
    • Verified consistent behavior for live and legacy streaming flows.

@coderabbitai

coderabbitai Bot commented Aug 10, 2026 •

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 350eb7a1-4c8e-40d8-94bb-312d53dface7

📥 Commits

Reviewing files that changed from the base of the PR and between 6ab72f1 and 85dd4e1.

📒 Files selected for processing (1)
  • src/agent/runtime/chat-stream-handler.test.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/agent/runtime/chat-stream-handler.test.ts

📝 Walkthrough

Walkthrough

Streaming runtime handlers and lifecycle adapters now assign unique IDs to successive text segments. Tool interruptions and later agent steps use separate IDs. Tests verify resumed text and active-mode parity.

Changes

Streaming text segment identity

Layer / File(s) Summary
Runtime segment identifiers and validation
src/agent/runtime/chat-stream-handler.ts, src/agent/runtime/index.ts, src/agent/runtime/chat-stream-handler.test.ts, src/agent/runtime/refresh.test.ts
The runtime assigns indexed IDs to resumed text segments and step-specific IDs to later streaming steps. Text start, delta, and end events use the active segment ID. Tests verify separate segments and step-specific events.
Live lifecycle segment tracking
src/agent/streaming/lifecycle/live-adapter.ts
The live adapter tracks the active text segment, assigns indexed IDs to successive segments, and clears the active ID when text ends.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Provider
  participant processStream
  participant ChatStreamHandler
  participant live-adapter
  Provider->>processStream: tool interruption and resumed assistant text
  processStream->>ChatStreamHandler: step-specific textPartId
  ChatStreamHandler->>live-adapter: text-start, text-content, and text-end
  live-adapter->>live-adapter: preserve active segment ID
Loading

Possibly related PRs

Suggested reviewers: kwakayama

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: preserving resumed assistant text segments after tool activity.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/issue-337-resumed-text-segment

Comment @coderabbitai help to get the list of available commands.

@kojiwakayama
kojiwakayama added this pull request to the merge queue Aug 10, 2026
Merged via the queue into main with commit 4731e9a Aug 10, 2026
31 checks passed
@kojiwakayama
kojiwakayama deleted the fix/issue-337-resumed-text-segment branch August 10, 2026 14:46
@kwakayama kwakayama mentioned this pull request Aug 10, 2026
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