fix(server): a cancelled delegated task no longer shows its child's question #18459
main fromrefs/pull/18459/headmerged by maria-rcks 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:M
- apps/server/src/orchestration-v2/Orchestrator.ts line 11155OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -11117,0 +11135,21 @@11135+ return yield* childAwaitsRestartContinuation(child.runs, progress.resultRun);11136+ }).pipe(11137+ Effect.mapError(11138+ (cause) => new OrchestratorProjectionError({ threadId: childThreadId, cause }),11139+ ),11140+ );11141+11142+ // Async questions do not stop a delegated child's run. Once its task result is11143+ // final, nothing reads the answers, so the questions close instead of11144+ // showing on the parent forever.11145+ const finishAppOwnedSubagent = (11146+ parentThreadId: ThreadId,11147+ childThreadId: ThreadId,11148+ options?: { readonly settledContinuationOf?: RunId },11149+ ) =>11150+ Effect.gen(function* () {11151+ yield* threadDispatch.withLock(11152+ parentThreadId,11153+ finalizeAppOwnedSubagent(childThreadId, options),11154+ );11155+ if (yield* delegatedTaskResultPending(childThreadId)) return;
juliusmarminge added labelsmacroscope-review
coderabbitai[bot](GitHub profile, opens in a new tab) requested changes
apps/server/src/orchestration-v2/Orchestrator.ts lines 11151 to 11155OutdatedResolvedby coderabbitai[bot](GitHub profile, opens in a new tab)@@ -11117,0 +11135,21 @@11135+ return yield* childAwaitsRestartContinuation(child.runs, progress.resultRun);11136+ }).pipe(11137+ Effect.mapError(11138+ (cause) => new OrchestratorProjectionError({ threadId: childThreadId, cause }),11139+ ),11140+ );11141+11142+ // Async questions do not stop a delegated child's run. Once its task result is11143+ // final, nothing reads the answers, so the questions close instead of11144+ // showing on the parent forever.11145+ const finishAppOwnedSubagent = (11146+ parentThreadId: ThreadId,11147+ childThreadId: ThreadId,11148+ options?: { readonly settledContinuationOf?: RunId },11149+ ) =>11150+ Effect.gen(function* () {11151+ yield* threadDispatch.withLock(11152+ parentThreadId,11153+ finalizeAppOwnedSubagent(childThreadId, options),11154+ );11155+ if (yield* delegatedTaskResultPending(childThreadId)) return;apps/server/src/orchestration-v2/Orchestrator.ts line 11155OutdatedResolvedby coderabbitai[bot](GitHub profile, opens in a new tab)@@ -11117,0 +11135,21 @@11135+ return yield* childAwaitsRestartContinuation(child.runs, progress.resultRun);11136+ }).pipe(11137+ Effect.mapError(11138+ (cause) => new OrchestratorProjectionError({ threadId: childThreadId, cause }),11139+ ),11140+ );11141+11142+ // Async questions do not stop a delegated child's run. Once its task result is11143+ // final, nothing reads the answers, so the questions close instead of11144+ // showing on the parent forever.11145+ const finishAppOwnedSubagent = (11146+ parentThreadId: ThreadId,11147+ childThreadId: ThreadId,11148+ options?: { readonly settledContinuationOf?: RunId },11149+ ) =>11150+ Effect.gen(function* () {11151+ yield* threadDispatch.withLock(11152+ parentThreadId,11153+ finalizeAppOwnedSubagent(childThreadId, options),11154+ );11155+ if (yield* delegatedTaskResultPending(childThreadId)) return;github-actions[bot](GitHub profile, opens in a new tab) removed labelssize:M
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:L
coderabbitai[bot](GitHub profile, opens in a new tab) approved these changes
flamboh(GitHub profile, opens in a new tab) changed the title
github-actions[bot](GitHub profile, opens in a new tab) removed labelssize:L
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:M
- apps/server/src/orchestration-v2/Orchestrator.ts line 10516Resolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -10472,0 +10482,21 @@10482+ const { resultRun } = progress;10483+ if (progress.state !== "result_available" || resultRun === undefined) return;10484+ const status = delegatedTaskTerminalStatus(runOutcome(resultRun));10485+ if (status !== "cancelled" && status !== "interrupted") return;10486+ if (10487+ yield* childAwaitsRestartContinuation(10488+ childControls.runs,10489+ resultRun,10490+ options?.settledContinuationOf,10491+ )10492+ )10493+ return;10494+ // Completed or failed tasks keep async questions: answering resumes the child.10495+ // Callers hold the parent lock; dismiss takes the child lock, as follow-up intake does.10496+ for (const request of childControls.runtimeRequests) {10497+ if (10498+ request.status === "pending" &&10499+ request.kind === "user_input" &&10500+ request.responseCapability.type === "message"10501+ ) {10502+ yield* dispatchWithReceipt({
- apps/server/src/orchestration-v2/Orchestrator.ts lines 10496 to 10500OutdatedResolvedby coderabbitai[bot](GitHub profile, opens in a new tab)@@ -10472 +10480,21 @@1047210480 }10481+10482+ const { resultRun } = progress;10483+ if (progress.state !== "result_available" || resultRun === undefined) return;10484+ const status = delegatedTaskTerminalStatus(runOutcome(resultRun));10485+ if (status !== "cancelled" && status !== "interrupted") return;10486+ if (10487+ yield* childAwaitsRestartContinuation(10488+ childControls.runs,10489+ resultRun,10490+ options?.settledContinuationOf,10491+ )10492+ )10493+ return;10494+ // Completed or failed tasks keep async questions: answering resumes the child.10495+ // Callers hold the parent lock; dismiss takes the child lock, as follow-up intake does.10496+ for (const request of childControls.runtimeRequests) {10497+ if (10498+ request.status === "pending" &&10499+ request.kind === "user_input" &&10500+ request.responseCapability.type === "message"
maria-rcks merged thisc814e51
maria-rcks closed this
Sign in to join this conversation.
macroscopeapp[bot](GitHub profile, opens in a new tab) reviewed