Skip to content

fix(server): separate assistant provider items - #9764

Open
t3-code[bot] wants to merge 3 commits into
mainfrom
fix/separate-assistant-provider-items
Open

fix(server): separate assistant provider items#9764
t3-code[bot] wants to merge 3 commits into
mainfrom
fix/separate-assistant-provider-items

Conversation

@t3-code

@t3-code t3-code Bot commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

summary

  • keep assistant output items with different provider item ids as separate messages
  • track streaming segments per provider item so interleaved deltas stay attached correctly
  • finalize every open item at approval boundaries and only the matching item at completion
  • add regression coverage for multi-item, interleaved, approval, and completion sequences

testing

  • vp test apps/server/src/orchestration/Layers/ProviderRuntimeIngestion.test.ts (60 passed)
  • vp run t3#typecheck
  • vp lint apps/server/src/orchestration/Layers/ProviderRuntimeIngestion.ts apps/server/src/orchestration/Layers/ProviderRuntimeIngestion.test.ts --deny-warnings
  • vp fmt --check apps/server/src/orchestration/Layers/ProviderRuntimeIngestion.ts apps/server/src/orchestration/Layers/ProviderRuntimeIngestion.test.ts

request provenance


Note

Medium Risk
Changes core orchestration message projection for multi-item assistant turns and approval boundaries; behavior is well covered by new tests but affects how thread messages are built from provider events.

Overview
Provider runtime ingestion now tracks assistant message segments per provider item within a turn, instead of one active assistant message for the whole turn.

The segment cache becomes a map keyed by item base key (derived from the event), so multiple content.delta streams in one turn land on distinct messages, interleaved deltas still merge into the correct item, and :segment:N splits after approval stay scoped to that item only.

At approval / user-input pauses, finalizeActiveAssistantSegmentsForTurn flushes every open item. item.completed finalizes only the matching item and leaves other in-flight items streaming. Regression tests cover multi-item turns, interleaving, overlapping completions, and whitespace-only approval edges.

Reviewed by Cursor Bugbot for commit b07e637. Bugbot is set up for automated code reviews on this repo. Configure here.

Note

Separate assistant provider items in ProviderRuntimeIngestion

  • Changes the per-turn assistant segment cache from a single shared state to a map keyed by item base key, so each provider item gets its own message and independent segment sequence.
  • Reworks message resolution so events reuse an active message only for their own base key; events from different items start their own segments instead of merging.
  • Updates finalizeAssistantSegmentsForTurn to iterate over every active segment state at approval/pause boundaries rather than finalizing only one.
  • Makes item completion finalize only the matching item while preserving other overlapping item streams, and applies fallback completion text to the latest matching empty message.
  • Behavioral Change: hasAssistantMessageForTurn helper is removed; callers in ProviderRuntimeIngestion.ts now use item-scoped message selection. Completion no longer clears all segment state for the turn—only the matching item's active state is cleared.

Macroscope summarized b07e637.

Keep assistant output items distinct when one provider turn emits multiple item IDs. Preserve approval-boundary segmentation and add regression coverage.

Co-authored-by: paulhenri-l <25308170+paulhenri-l@users.noreply.github.com>

Co-authored-by: maria <254055478+maria-rcks@users.noreply.github.com>
@github-actions github-actions Bot added vouch:trusted PR author is trusted by repo permissions or the VOUCHED list. size:S 10-29 changed lines (additions + deletions). labels Sep 4, 2026
Comment thread apps/server/src/orchestration/Layers/ProviderRuntimeIngestion.ts Outdated
@github-actions

github-actions Bot commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

Thread transfer impact

✅ Thread transfer remains within every enforced ceiling.

Provider Metric Main baseline This PR Impact PR ceiling
Codex Total thread wire 13.6 KiB 13.6 KiB −12 B (−0.1%) 15.1 KiB
Codex Thread snapshot wire 7.0 KiB 7.0 KiB 0 B (0.0%) 7.3 KiB
Codex Live turn WebSocket wire 6.6 KiB 6.5 KiB −12 B (−0.2%) 7.8 KiB
Codex Live turn WebSocket decoded 57.1 KiB 57.0 KiB −44 B (−0.1%) 66.4 KiB
Codex Live turn messages 10 9 −1 (−10.0%) 21
Claude Total thread wire 13.6 KiB 13.6 KiB −52 B (−0.4%) 15.1 KiB
Claude Thread snapshot wire 7.0 KiB 7.0 KiB −3 B (−0.0%) 7.3 KiB
Claude Live turn WebSocket wire 6.6 KiB 6.5 KiB −49 B (−0.7%) 7.8 KiB
Claude Live turn WebSocket decoded 57.9 KiB 57.8 KiB −44 B (−0.1%) 66.4 KiB
Claude Live turn messages 10 9 −1 (−10.0%) 21

Baseline: f6db420 · PR result: b07e637 · Source CI: success

Scenario and decoded snapshot size

10 historical turns, 5 command tools per turn, 878.9 KiB retained MCP result per historical turn, and a 1.05 MiB retained result in the measured turn.

  • Codex decoded thread snapshot: 113.8 KiB
  • Claude decoded thread snapshot: 114.5 KiB

Updated in place by a trusted workflow. PR artifacts are strictly validated and never executed.

@cursor cursor Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes using default effort and found 2 potential issues.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Want higher recall? High effort reviews run extra passes and find more bugs. A team admin can switch effort levels in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 6bdc932. Configure here.

Comment thread apps/server/src/orchestration/Layers/ProviderRuntimeIngestion.ts
Comment thread apps/server/src/orchestration/Layers/ProviderRuntimeIngestion.ts
@macroscopeapp

macroscopeapp Bot commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

Approvability

Verdict: Approved at b07e637

Macroscope's review found this PR approvable — This is a localized orchestration bug fix that keeps assistant output separated by provider item and correctly finalizes interleaved or approval-paused streams. Regression coverage addresses the affected sequences, with no schema, default, infrastructure, or sensitive-package changes.

You can add or adjust custom eligibility rules. Learn more.

Keep segment lifecycle state for every provider item so interleaved deltas, approval pauses, and item completions cannot affect sibling assistant messages.

Co-authored-by: maria <254055478+maria-rcks@users.noreply.github.com>
@github-actions github-actions Bot added size:L 100-499 changed lines (additions + deletions). and removed size:S 10-29 changed lines (additions + deletions). labels Sep 4, 2026
Comment thread apps/server/src/orchestration/Layers/ProviderRuntimeIngestion.ts
Resolve item completion against the latest projected message for that provider item, while retaining fallback text when a whitespace-only segment produced no message.

Co-authored-by: maria <254055478+maria-rcks@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:L 100-499 changed lines (additions + deletions). vouch:trusted PR author is trusted by repo permissions or the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants