fix(server): tell parents when a delegated task is waiting for input #13343
Closedsaphid(GitHub profile, opens in a new tab)wants to merge 2 commits into
main fromrefs/pull/13343/headopened 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
- apps/server/src/orchestration-v2/Orchestrator.ts lines 10655 to 10660OutdatedResolvedby saphid(GitHub profile, opens in a new tab)@@ -9055,0 +9120,21 @@9120+ */9121+ const notifyParentOfBlockedChild = (9122+ childThreadId: ThreadId,9123+ request: OrchestrationV2RuntimeRequest,9124+ ) =>9125+ Effect.gen(function* () {9126+ const parentThreadId = yield* appOwnedSubagentParentThreadId(childThreadId);9127+ if (parentThreadId === undefined) return;9128+ // Hold the parent lock from the eligibility check through dispatch so a9129+ // concurrent Stop, disposal, or archive cannot slip in between.9130+ yield* threadDispatch.withLock(9131+ parentThreadId,9132+ dispatchBlockedChildNotice(parentThreadId, childThreadId, request),9133+ );9134+ }).pipe(9135+ Effect.catchCause((cause) =>9136+ Effect.logWarning("Failed to notify parent of blocked delegated task", {9137+ childThreadId,9138+ requestId: request.id,9139+ cause,9140+ }),
juliusmarminge closed this
juliusmarminge added labelstriage:keep-open
juliusmarminge reopened this
- apps/server/src/orchestration-v2/Orchestrator.ts line 75OutdatedResolvedby saphid(GitHub profile, opens in a new tab)@@ -0,0 +55,21 @@55+import * as Ref from "effect/Ref";56+import * as Schema from "effect/Schema";57+import * as Stream from "effect/Stream";58+59+import { ProjectionProjectRepository } from "../persistence/Services/ProjectionProjects.ts";60+import {61+ isCheckpointRestoreIsolated,62+ SHARED_WORKSPACE_RESTORE_MESSAGE,63+} from "./CheckpointRestoreSafety.ts";64+import { CheckpointServiceV2 } from "./CheckpointService.ts";65+import { CommandPolicyV2, resolveMessageDispatchIntent } from "./CommandPolicy.ts";66+import { CommandReceiptStoreV2 } from "./CommandReceiptStore.ts";67+import { ContextHandoffServiceV2 } from "./ContextHandoffService.ts";68+import { notificationTurnItem } from "./Notification.ts";69+import { isUndeliveredMailboxSteer } from "./NotificationMailbox.ts";70+import { EventSinkV2 } from "./EventSink.ts";71+import type { OrchestrationEffectRequestV2, PendingOrchestrationEffectV2 } from "./EffectOutbox.ts";72+import { IdAllocatorV2 } from "./IdAllocator.ts";73+import {74+ ThreadCommandExecutor,75+ layer as threadCommandExecutorLayer,
- apps/server/src/orchestration-v2/runtimeLayer.ts line 31OutdatedResolvedby saphid(GitHub profile, opens in a new tab)@@ -0,0 +11,21 @@11+import { ProviderAuthServiceLive } from "../provider/Layers/ProviderAuthService.ts";12+import { layer as agentSessionImporterLayer } from "../project/AgentSessionImporter.ts";13+import * as AgentSessionScanner from "../project/AgentSessionScanner.ts";14+import { layer as projectServiceLayer } from "../project/ProjectService.ts";15+import { layer as projectSetupScriptRunnerLayer } from "../project/ProjectSetupScriptRunner.ts";16+import { layer as checkpointCaptureServiceLayer } from "./CheckpointCaptureService.ts";17+import { layer as checkpointServiceLayer } from "./CheckpointService.ts";18+import { layer as checkpointRollbackServiceLayer } from "./CheckpointRollbackService.ts";19+import { layer as commandPolicyLayer } from "./CommandPolicy.ts";20+import { layerFromApplicationReceipts as commandReceiptStoreLayer } from "./CommandReceiptStore.ts";21+import { layer as contextHandoffServiceLayer } from "./ContextHandoffService.ts";22+import { layer as effectOutboxLayer } from "./EffectOutbox.ts";23+import {24+ executorLayer as effectExecutorLayer,25+ layer as effectWorkerLayer,26+} from "./EffectWorker.ts";27+import { layerFromStores as eventSinkLayer } from "./EventSink.ts";28+import { layerFromOrchestrationEventStore as eventStoreLayer } from "./EventStore.ts";29+import { layer as idAllocatorLayer } from "./IdAllocator.ts";30+import { layer as legacyV1ThreadImporterLayer } from "./LegacyV1ThreadImporter.ts";31+import { layer as orchestratorLayer } from "./Orchestrator.ts";
- apps/server/src/orchestration-v2/Orchestrator.ts lines 10750 to 10762Resolvedby coderabbitai[bot](GitHub profile, opens in a new tab)@@ -9518,3 +9659,16 @@95189659 Effect.forkDetach,95199660 );952096619662+ yield* eventSink9663+ .stream({ afterSequence: terminalEventsAfterSequence, eventType: "runtime-request.updated" })9664+ .pipe(9665+ Stream.runForEach((stored) =>9666+ stored.event.type === "runtime-request.updated" &&9667+ stored.event.threadId !== undefined &&9668+ stored.event.payload.status === "pending" &&9669+ stored.event.payload.kind !== "dynamic_tool_call"9670+ ? notifyParentOfBlockedChild(stored.event.threadId, stored.event.payload)9671+ : Effect.void,9672+ ),9673+ Effect.forkDetach,9674+ );
juliusmarminge closed this
Sign in to join this conversation.
Approvability#
Verdict: Not approved
Macroscope's review found this PR not approvable — This change adds a server-side event reactor that wakes parent agents and queues user-visible notices when delegated children await input, alongside new lock, deduplication, retry, and cancellation behavior. Its production impact spans existing orchestration and queue lifecycle paths, making human review appropriate despite the focused tests.
You can add or adjust custom eligibility rules. [Learn more](https://docs.macroscope.com/approvability#example-custom-eligibility-rules).