fix(claude): report subagent model and effort - #7287
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 |
ApprovabilityVerdict: Not approved Macroscope's review found this PR not approvable — This production change alters Claude task lifecycle events and adds SDK hook-driven reconciliation for subagent model, effort, and resume identity. The scope is localized and well tested, but the new asynchronous state and event-ordering logic is complex enough to merit human review. Not approved because:
Review your spending limits in Billing settings. You can add or adjust custom eligibility rules. Learn more. |
…del-attribution # Conflicts: # apps/server/src/provider/Layers/ClaudeAdapter.ts
|
Merged current Two notes for reviewers:
|
|
Independent reproduction, plus one data point on Prevalence. I compared the label on every The 79%→14% gap is the part I found interesting: refinement does most of the work, so the residual is concentrated in children that never stream an assistant snapshot the parent sees. One possible addition. That would give a launch-time value between an explicit Worth noting the built-in defaults are version-sensitive: on the SDK-bundled 2.1.170 Composition. I have a separate fix for a different bug in this file, the parent context meter counting subagent tokens (#5942, PR #8453). I applied your branch and mine together on today's |
…l-attribution # Conflicts: # apps/server/src/provider/Layers/ClaudeAdapter.test.ts
|
Independent Windows test report for 1f67bd5. I checked this PR because we use a local Claude SDK / hybrid-router setup and had patched the same parent-model/effort attribution problem locally. Results
The matrix emits an assistant snapshot with BoundariesThese are adapter/client-runtime tests with synthetic SDK input, not real provider calls or a rendered sidebar check. The matrix treats model names and effort values as metadata: it does not establish that every model supports every effort, that a hybrid router applies them, or that the live CLI emits each tested hook payload. No production T3 instance was replaced or restarted, and this is not a latest-main integration/rebase test. Environment: Windows x64, Node 25.8.0, pnpm 11.10.0, lockfile-installed SDK 0.3.170. Node is outside the repository's declared For our use case, preserving runtime-reported model IDs and effort is preferable to upstreaming our local frontmatter/alias display workaround. I did not find an additional issue in the tested metadata path that warrants a competing PR. Test report prepared with Codex Desktop (local configuration: GPT-6 Astra, medium). |
Problem
Claude file-defined subagents were seeded with the parent session's model and effort. The Agents panel therefore showed the parent settings for every subagent, and authoritative model snapshots that arrived late never reached the client.
Fix
task.startedSubagentStartandSubagentStophooksVerification
pnpm exec vp test run apps/server/src/provider/Layers/ClaudeAdapter.test.ts(74 passed)pnpm exec vp test run packages/client-runtime/src/state/subagentRuntime.test.ts(48 passed)pnpm exec vp run --filter t3 typecheckFixes #7281
Model: GPT-5.6 Sol
Harness: Codex in T3 Code
Note
Medium Risk
Changes runtime event payloads and task identity logic in the Claude provider path; incorrect linkage could affect UI/analytics for subagents, but scope is localized to adapter event emission with heavy test coverage.
Overview
Fixes misattributed subagent model/effort in the Claude adapter: file-defined agents no longer inherit the parent session’s selection when the Agent tool omits overrides. Identity is seeded only from explicit launch input, then refined from subagent assistant snapshots and SDK
SubagentStart/SubagentStophooks (effort).Late or early identity is handled via a bounded pending-refinement map (model + effort, cap 256): snapshots that beat
task_startedapply on start; snapshots or hooks that arrive after terminal rows emittask.updatedcorrections. Error frames with model<synthetic>are ignored. Repeatedtask_startedon resume keeps the original Agenttool_use_idso snapshots still link correctly.Tests add
invokeSubagentEffortHookand broaden scenarios (non-inheritance, ordering, post-completion correction, resume, synthetic models, explicit overrides, eviction).Reviewed by Cursor Bugbot for commit 1f67bd5. Bugbot is set up for automated code reviews on this repo. Configure here.
Note
Fix subagent model and effort attribution in
ClaudeAdaptertask.startedevents no longer infer model or effort from the parent session; they use explicit Agent-tool overrides, buffered runtime refinements, or existing task metadata.SubagentStart/SubagentStophook callbacks to capture effort metadata, either buffering it for unregistered tasks or emittingtask.updatedcorrections for registered tasks.task.startednow reports unknown model/effort when no explicit override or runtime refinement is available — checkmakeClaudeAdapterin ClaudeAdapter.ts for the fallback removal.Macroscope summarized 1f67bd5.