fix(orchestration): Preserve Claude subagent attribution after settle - #5388
Conversation
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
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. Comment |
There was a problem hiding this comment.
Effect Service Conventions review: one convention issue found in the newly added test module's service imports. Everything else in the changed Effect code (subpath namespace imports, layer construction, dependency acquisition via yield* Service, error modeling) matches the conventions.
Posted via Macroscope — Effect Service Conventions
ApprovabilityVerdict: Needs human review Diff is too large for automated approval analysis. A human reviewer should evaluate this PR. You can customize Macroscope's approvability policy. Learn more. |
38aefa4 to
f1d3119
Compare
f1d3119 to
7370ca6
Compare
7370ca6 to
1a18bba
Compare
There was a problem hiding this comment.
Reviewed the changed Effect service code against the service conventions. One import-shape issue in the new server test; everything else (namespace imports from effect/* subpaths, Context.Service shapes, error modelling, and dependency acquisition in the touched orchestration/adapter code) looks consistent with the conventions.
Posted via Macroscope — Effect Service Conventions
1a18bba to
f80ad36
Compare
f80ad36 to
38e7184
Compare
38e7184 to
49162a7
Compare
49162a7 to
fe0878f
Compare
fe0878f to
8e4dc09
Compare
8e4dc09 to
905b5a1
Compare
e24b59c to
4213ac5
Compare
905b5a1 to
48f545d
Compare
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 48f545d. Configure here.
48f545d to
f223029
Compare

Summary
and fresh buffered continuations.
threads without changing ordinary root assistant text.
generic Claude prompt, preserve other providers' requested detail, and hide
automatic provider entries from queue controls.
Problem and Fix
task_notification.summarywas used as the provider-owned Claude continuation input and could render as raw child text labelled as another agent's message. A shared override would also erase Codex background-command context.Background task completed., while preserving provider-specific continuation detail for Codex. Omit provider-owned automatic entries from visible queue controls.task_started.tool_use_idby arrival order.task_startedregisters their alias. A structuredagentIdcan also appear in ordinary root tool output.agentIddata.Defensive Fixes
failIfCurrent, where a live-buffer rescan pulled the sibling into the failed cohort.running.tool_use_result, then incorrectly apply that shared structured result when one buffered block replayed.Validation
client-runtime set passed 189 tests with 1 skipped.
vp check: passed all 2,690 files.vp run typecheck: passed all 15 packages.passed the exact packaged Grok post-settlement subagent, Claude
post-settlement subagent, and Codex background-command wake scenarios. Claude
projected one generic provider-owned root input while keeping raw child
output on the child; Grok and Codex retained their provider-specific
behavior.
agentIdcollision. Theregression was fixed and covered. Fresh Grok 4.5 high-reasoning source and deliberate-integration reviews
returned SHIP after verifying teardown ordering, exactly-once terminals,
semaphore safety, independent batched-result lineage, and fail-closed pending-launch overflow.
Note
High Risk
Changes orchestration routing for Claude native tasks, continuations, and session teardown; mis-attribution or drain bugs could leak child output to the root or drop completions.
Overview
Fixes Claude subagent frames arriving after a root turn settles being mis-attributed to the root thread when continuation turns no longer have launch-time tool-use maps.
Durable native-thread session state now holds task identity, launch/resume aliases, bounded pre-registration buffering, and resume metadata so every child frame resolves through the same lineage. Child narration, tools, results, and distinct terminal output stay on child threads; ordinary root assistant text is unchanged.
Continuation input for provider-owned Claude root wakes uses fixed text (
Background task completed.) instead of rawtask_notification.summary, while Codex keeps its provider-specific detail. Automatic provider entries are omitted from visible queue controls.Adds fail-closed behavior for unknown lineage (bounded buffer until registration; overflow dropped child-side), single unambiguous launch-alias inference when
task_started.tool_use_idis missing, routing for early Agent results/approvals, and defensive handling for failed continuation cohorts, sibling completions, rejected approvals in inference queues, session teardown, and split multi-result SDK frames so siblings replay independently without shared frame-level results.Reviewed by Cursor Bugbot for commit f223029. Bugbot is set up for automated code reviews on this repo. Configure here.
Note
Preserve Claude subagent attribution after settlement in orchestration v2
ClaudeAdapterV2to be keyed per native thread, replacing a single global registry withClaudeNativeThreadSubagentState/ClaudeSessionSubagentStatestructures that support alias resolution, bounded history, and generation tracking.Semaphorepermit to eliminate race conditions in concurrent subagent/approval flows.approvalsCanOriginateFromSubagents: true), with tool calls routed to the correct child thread viaparentToolUseId/subagentTaskId.PROVIDER_CONTINUATION_MESSAGE_TEXTas the canonical default continuation message text, used inProviderContinuationServiceand filtered from the visible queue inthreadWorkflows.Macroscope summarized f223029.