fix(server): a held or unread delegated message tells its owner #48230
ClosedAlb11747(GitHub profile, opens in a new tab)wants to merge 3 commits into
main fromrefs/pull/48230/headopened View on GitHubtanstack-source added labelsbug
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:L
macroscopeapp[bot](GitHub profile, opens in a new tab) approved these changes
- @@ -378,4 +391,5 @@378391 report ??379392 (run.status === "completed"380393 ? "Child task completed without an assistant result."381- : `Child task ended with status ${run.status}.`),394+ : run.status === "cancelled" && run.startedAt === null395+ ? unreadMessageResult(run, projection)@@ -0,0 +24,21 @@24+ {25+ readonly start: () => Effect.Effect<void, never, Scope.Scope>;26+ readonly handle: (event: OrchestrationV2DomainEvent) => Effect.Effect<void>;27+ }28+>()("t3/orchestration-v2/DelegatedTaskHoldReactor") {}29+30+const make = Effect.gen(function* () {31+ const engine = yield* Orchestrator.OrchestratorV2;32+ const projections = yield* ProjectionStore.ProjectionStoreV2;33+34+ // One notice per held run, whatever else updates the task (a replayed command is a no-op).35+ // The orchestrator cancels a queued notice once its run is released, so a cancelled notice36+ // means this is a later hold of the same run, which gets a notice of its own.37+ const noticeKey = Effect.fnUntraced(function* (ownerThreadId: ThreadId, base: string) {38+ for (let hold = 1; ; hold++) {39+ const key = hold === 1 ? base : `${base}:${hold}`;40+ const { messages } = yield* projections.getThreadRecords(ownerThreadId, ["messages"], {41+ messageIds: [MessageId.make(`message:delegated-task-held:${key}`)],42+ });43+ const runId = messages[0]?.runId;44+ if (runId === undefined || runId === null) return key;
Sign in to join this conversation.
Codex Review Summary: ✅ Completed
This comment shows the latest Codex review activity on this pull request.
4a2565bℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.