Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix: avoid duplicating streamed assistant completion text #465

Mergedjamesx0416(GitHub profile, opens in a new tab)merged 1 commit intomain fromrefs/pull/465/headmerged by t3dotgg(GitHub profile, opens in a new tab) View on GitHub

Summary

Prevent assistant message text from being appended twice when streaming deltas are followed by item.completed detail.

Changes

  • Only apply completion fallbackText when the target assistant message has no existing text.
  • Keep streaming behavior unchanged.
  • Extend streaming regression coverage to include item.completed.detail and assert no duplicated text.

Validation

  • bun run test src/orchestration/Layers/ProviderRuntimeIngestion.test.ts (from apps/server)
  • bun lint
  • bun typecheck

Note

Apply fallback completion text only when the existing assistant message is missing or empty in ProviderRuntimeIngestion.make to avoid duplicating streamed assistant text

Adds a check in ProviderRuntimeIngestion.make to compute shouldApplyFallbackCompletionText by looking up the assistant message in thread.messages, and passes fallbackText to finalizeAssistantMessage only when the message is missing or empty; updates the streaming-mode test data to include detail: "hello live" in the item.completed payload. See ProviderRuntimeIngestion.ts and ProviderRuntimeIngestion.test.ts.

📍Where to Start

Start in ProviderRuntimeIngestion.make where assistant completion events are handled in ProviderRuntimeIngestion.ts.

Macroscope summarized 1f4b976.

Summary by CodeRabbit

  • Bug Fixes
    • Fixed assistant message completion to prevent fallback text from overwriting existing message content during streaming mode.
    • Improved message detail preservation in completion events.
    1. coderabbitai[bot](GitHub profile, opens in a new tab)commented

      No actionable comments were generated in the recent review. 🎉

      ℹ️ Recent review info
      ⚙️ Run configuration

      Configuration used: Repository UI

      Review profile: CHILL

      Plan: Pro

      Run ID: 92592a5e-badc-4c18-88f1-86fd77bbf63b

      📥 Commits

      Reviewing files that changed from the base of the PR and between c97c6b7836ce888b24a157de8eb4aea761028979 and 1f4b976495ea5a9901ae4e60b0d1fb279b585672.

      📒 Files selected for processing (2)
      • apps/server/src/orchestration/Layers/ProviderRuntimeIngestion.test.ts
      • apps/server/src/orchestration/Layers/ProviderRuntimeIngestion.ts

      📝 Walkthrough

      Walkthrough

      Adds a guard condition to prevent applying fallback completion text when an existing assistant message already contains non-empty text, with corresponding test update to verify the detail field is properly passed through the completion event payload during streaming mode.

      Changes

      Cohort / File(s)Summary
      Assistant Message Completion Handling
      apps/server/src/orchestration/Layers/ProviderRuntimeIngestion.ts, apps/server/src/orchestration/Layers/ProviderRuntimeIngestion.test.ts
      Added logic to check for existing assistant message text before applying fallback completion text. The implementation introduces existingAssistantMessage lookup and shouldApplyFallbackCompletionText flag to conditionally include fallbackText only when needed. Test updated to include detail field in item.completed event payload during streaming mode.

      Estimated code review effort

      🎯 2 (Simple) | ⏱️ ~8 minutes

      Poem

      🐰 A guard so wise, a detail bright, No fallback text when words are right, The streaming flows without a doubt, With messages that truly shout!

      🚥 Pre-merge checks | ✅ 3
      ✅ Passed checks (3 passed)
      Check nameStatusExplanation
      Description Check✅ PassedCheck skipped - CodeRabbit’s high-level summary is enabled.
      Title check✅ PassedThe title 'fix: avoid duplicating streamed assistant completion text' directly and specifically describes the main change: preventing assistant message text duplication when streaming deltas are followed by item.completed.detail payload.
      Docstring Coverage✅ PassedNo functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
      ✏️ Tip: You can configure your own custom pre-merge checks in the settings.
      ✨ Finishing Touches
      🧪 Generate unit tests (beta)
      • Create PR with unit tests
      • Post copyable unit tests in a comment

      Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

      ❤️ Share
      Comment `@coderabbitai help` to get the list of available commands and usage tips.
    2. ✅ Actions performed

      Review triggered.

      Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

    3. Just saw #349 and #381, but this is cleaner.

Sign in to join this conversation.