Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(server): parent Stop clears orphaned delegated follow-ups #20310

Merged1kuna(GitHub profile, opens in a new tab)merged 2 commits intomain fromrefs/pull/20310/headmerged by juliusmarminge View on GitHub

Showing 2 changed files with 108 additions and 0 deletions (loading 1).

x
0 of 2 viewed, 2 left
108 additions and 0 deletionsapps/server/src/orchestration-v2/Orchestrator.tsModified
View file
@@ -20,6 +20,7 @@
ORCHESTRATION_V2_WORKSPACE_PREPARATION_FAILURE_CODE,
type ChatAttachment,
CommandId,
+ isOrchestrationV2WorkActive,
isProviderNativeSubagentThread,
MessageId,
type NodeId,
@@ -9465,6 +9466,111 @@
if (projection.thread.deletedAt !== null) return undefined;
+ const cancelIdleOrphans = Effect.gen(function* () {
+ const pending = yield* Ref.get(events);
+ const children = new Map<
+ ThreadId,
+ ProjectionRecords<"runs" | "providerThreads" | "runtimeRequests" | "turnItems"> | null
+ >();
+ const idleChildren = new Map<ThreadId, boolean>();
+ let nodes: ReadonlyArray<OrchestrationV2ExecutionNode> | undefined;
+ for (const recorded of projection.subagents) {
+ const updated = pending.findLast(
+ (event) => event.type === "subagent.updated" && event.payload.id === recorded.id,
+ );
+ const task = updated?.type === "subagent.updated" ? updated.payload : recorded;
+ if (
+ task.origin !== "app_owned" ||
+ task.childThreadId === null ||
+ !isOrchestrationV2WorkActive(task.status)