fix(server): separate assistant provider items - #9764
Conversation
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>
Thread transfer impact✅ Thread transfer remains within every enforced ceiling.
Baseline: Scenario and decoded snapshot size10 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.
Updated in place by a trusted workflow. PR artifacts are strictly validated and never executed. |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 2 potential issues.
❌ 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.
ApprovabilityVerdict: Approved at 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>
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>

summary
testing
vp test apps/server/src/orchestration/Layers/ProviderRuntimeIngestion.test.ts(60 passed)vp run t3#typecheckvp lint apps/server/src/orchestration/Layers/ProviderRuntimeIngestion.ts apps/server/src/orchestration/Layers/ProviderRuntimeIngestion.test.ts --deny-warningsvp fmt --check apps/server/src/orchestration/Layers/ProviderRuntimeIngestion.ts apps/server/src/orchestration/Layers/ProviderRuntimeIngestion.test.tsrequest 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.deltastreams in one turn land on distinct messages, interleaved deltas still merge into the correct item, and:segment:Nsplits after approval stay scoped to that item only.At approval / user-input pauses,
finalizeActiveAssistantSegmentsForTurnflushes every open item.item.completedfinalizes 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
ProviderRuntimeIngestionfinalizeAssistantSegmentsForTurnto iterate over every active segment state at approval/pause boundaries rather than finalizing only one.hasAssistantMessageForTurnhelper 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.