fix(server): track resumed subagent follow-ups as separate tasks #17696
MergedYash-Singh1(GitHub profile, opens in a new tab)merged 3 commits into
main fromrefs/pull/17696/headmerged by Yash-Singh1(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:L
juliusmarminge added labelsmacroscope-review
- apps/server/src/orchestration-v2/Orchestrator.ts line 10066OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -9874,2 +10046,21 @@987410046 });98751004710048+ const finalizeAppOwnedSubagent = (10049+ childThreadId: ThreadId,10050+ options?: { readonly settledContinuationOf?: RunId },10051+ ) =>10052+ Effect.gen(function* () {10053+ const childControls = yield* projectionStore.getThreadRecords(10054+ childThreadId,10055+ ["runs", "messages", "subagents", "providerThreads", "providerTurns", "attempts"],10056+ { messageRoles: ["user"] },10057+ );10058+ const parentThreadId = childControls.thread.lineage.parentThreadId;10059+ if (10060+ childControls.thread.lineage.relationshipToParent !== "subagent" ||10061+ parentThreadId === null ||10062+ childControls.thread.forkedFrom?.type !== "node"10063+ )10064+ return;10065+ const progress = delegatedTaskProgress(childControls);10066+ if (progress.state !== "result_available" || progress.resultRun === undefined) return;
- apps/server/src/orchestration-v2/DelegatedCompletionDelivery.test.ts line 44OutdatedResolvedby Yash-Singh1(GitHub profile, opens in a new tab)@@ -41,3 +41,4 @@4141 import * as RuntimeLayer from "./runtimeLayer.ts";4242 import * as ProviderTurnStartServiceTestkit from "./ProviderTurnStartService.testkit.ts";4343 import type * as ProviderAdapter from "@t3tools/provider-core/server/ProviderAdapter";44+import * as ProviderContinuationRequests from "./ProviderContinuationRequests.ts";apps/server/src/orchestration-v2/Orchestrator.ts lines 10065 to 10066OutdatedResolvedby coderabbitai[bot](GitHub profile, opens in a new tab)@@ -9874,2 +10046,21 @@987410046 });98751004710048+ const finalizeAppOwnedSubagent = (10049+ childThreadId: ThreadId,10050+ options?: { readonly settledContinuationOf?: RunId },10051+ ) =>10052+ Effect.gen(function* () {10053+ const childControls = yield* projectionStore.getThreadRecords(10054+ childThreadId,10055+ ["runs", "messages", "subagents", "providerThreads", "providerTurns", "attempts"],10056+ { messageRoles: ["user"] },10057+ );10058+ const parentThreadId = childControls.thread.lineage.parentThreadId;10059+ if (10060+ childControls.thread.lineage.relationshipToParent !== "subagent" ||10061+ parentThreadId === null ||10062+ childControls.thread.forkedFrom?.type !== "node"10063+ )10064+ return;10065+ const progress = delegatedTaskProgress(childControls);10066+ if (progress.state !== "result_available" || progress.resultRun === undefined) return;packages/client-runtime/src/state/threadRelationships.ts line 108Resolvedby coderabbitai[bot](GitHub profile, opens in a new tab)@@ -92,11 +92,12 @@9292 const ownerThreadId = input.projection.thread.id;9393 for (const subagent of input.projection.subagents) {9494 if (subagent.childThreadId === null) continue;95- // The subagent record settles with the delegated task's first run, but the96- // parent can keep sending the child follow-ups. A live run on the child97- // thread outranks that settled status.95+ const child = threadsById.get(subagent.childThreadId);96+ // The row describes the child conversation, including queued follow-ups97+ // and their outcomes. A child without an app run still uses its task.9898 addEdge({9999 sourceThreadId: ownerThreadId,100100 targetThreadId: subagent.childThreadId,101101 kind: "subagent",102- status: threadsById.get(subagent.childThreadId)?.activityRunStatus ?? subagent.status,102+ status:103+ child?.activityRunStatus ?? (child?.latestRunId != null ? child.status : subagent.status),
Yash-Singh1(GitHub profile, opens in a new tab) closed this
Sign in to join this conversation.
macroscopeapp[bot](GitHub profile, opens in a new tab) reviewed