feat(orchestration-v2): populate subagent observability from providers (2/5) #4629
Mergedshivamhwp(GitHub profile, opens in a new tab)merged 4 commits into
subagent-obs/01-contracts fromrefs/pull/4629/headmerged by shivamhwp(GitHub profile, opens in a new tab) View on GitHubgithub-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:trusted
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:XL
github-actions[bot](GitHub profile, opens in a new tab) removed labelssize:XL
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:XXL
- apps/server/src/orchestration-v2/testkit/fixtures/claude_workflow/output.ts lines 48 to 48OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -0,0 +28,21 @@28+ { index: 1, title: "Implement" },29+ ]);30+31+ const members = projection.subagents32+ .filter((subagent) => subagent.kind === "workflow_agent")33+ .toSorted(34+ (left, right) =>35+ (left.workflowMembership?.agentIndex ?? 0) - (right.workflowMembership?.agentIndex ?? 0),36+ );37+ assert.lengthOf(members, 2, "both workflow members must reach the projection");38+ assert.deepEqual(39+ members.map((member) => [40+ member.title,41+ member.status,42+ member.workflowMembership?.phaseIndex,43+ member.model,44+ member.usage?.totalTokens,45+ ]),46+ [47+ ["Researcher", "completed", 0, "claude-sonnet-4-6", 400],48+ ["Implementer", "running", 1, "claude-opus-4-1", 500],
- apps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.ts line 1472Resolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -1400,0 +1452,21 @@1452+ outputTokens === undefined &&1453+ nonNegativeInteger(recordField(value, "total_tokens")) === undefined &&1454+ nonNegativeInteger(recordField(value, "totalTokens")) === undefined &&1455+ toolUses === undefined &&1456+ durationMs === undefined1457+ ) {1458+ return undefined;1459+ }1460+ return {1461+ totalTokens,1462+ ...(inputTokens === undefined && cacheCreationTokens === undefined1463+ ? {}1464+ : { inputTokens: (inputTokens ?? 0) + (cacheCreationTokens ?? 0) }),1465+ ...(cachedInputTokens === undefined ? {} : { cachedInputTokens }),1466+ ...(outputTokens === undefined ? {} : { outputTokens }),1467+ ...(toolUses === undefined ? {} : { toolUses }),1468+ ...(durationMs === undefined ? {} : { durationMs }),1469+ };1470+}1471+1472+const claudeWorkflowAgentStatus = (entry: unknown) => {
- apps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.ts line 2557Resolvedby cursor[bot](GitHub profile, opens in a new tab)@@ -2376,0 +2535,21 @@2535+ const activation = startsActivation2536+ ? ({2537+ id: subagentActivationId(nodeId, task.activationCount),2538+ threadId: task.threadId,2539+ subagentId: nodeId,2540+ runId: task.runId,2541+ providerTurnId: input.context.providerTurnId,2542+ ordinal: task.activationCount,2543+ status: input.status,2544+ usage: input.usage ?? null,2545+ startedAt: now,2546+ completedAt: settled ? now : null,2547+ updatedAt: now,2548+ } satisfies OrchestrationV2SubagentActivation)2549+ : ({2550+ ...existingSubagent.activation,2551+ status: input.status,2552+ usage: mergeCumulativeSubagentUsage(existingSubagent.activation.usage, input.usage),2553+ completedAt: settled ? now : null,2554+ updatedAt: now,2555+ } satisfies OrchestrationV2SubagentActivation);apps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.ts line 2598Resolvedby cursor[bot](GitHub profile, opens in a new tab)@@ -2406,4 +2589,4 @@24062589 if (24072590 registered !== undefined &&24082591 registered.task.status !== "running" &&2409- input.status === "running" &&2592+ activeStart &&
- @@ -3272,0 +3369,21 @@3369+ const usage = {3370+ totalTokens: total.totalTokens,3371+ inputTokens: total.inputTokens,3372+ cachedInputTokens: total.cachedInputTokens,3373+ outputTokens: total.outputTokens,3374+ reasoningOutputTokens: total.reasoningOutputTokens,3375+ } satisfies OrchestrationV2SubagentUsage;3376+ yield* emitSubagentTaskUpdate({3377+ subagent,3378+ status: subagent.task.status,3379+ usage,3380+ });3381+3382+ const activeContext = (yield* Ref.get(activeTurns)).get(payload.turnId);3383+ if (3384+ activeContext === undefined ||3385+ activeContext.subagent !== subagent ||3386+ activeContext.subagentActivation === null3387+ ) {3388+ return;3389+ }
shivamhwp(GitHub profile, opens in a new tab) closed this
Sign in to join this conversation.


Important
Review skipped#
Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the
.coderabbit.yamlfile in this repository. To trigger a single review, invoke the@coderabbitai reviewcommand.⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID:
41ca544d-dcf6-4c8b-a001-f29b8fa09bfdYou can disable this status message by setting the
reviews.review_statustofalsein the CodeRabbit configuration file.Use the checkbox below for a quick retry:
✨ Finishing Touches
🧪 Generate unit tests (beta)
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