Repository navigation
Chat worker errors alert the orchestration coordinator - #31941
Conversation
…rdinator A native-chat agent working a Dispatch whose turn ends in an error (usage limit, signed out, provider refused, agent died mid-turn, failed start) now sends one high-priority escalation to the Run that dispatched it, carrying the error sentence the chat recorded plus the agent's own detail. The task stays assigned to the chat. Terminal workers already escalated on exit; both now share one escalation helper. On by default; a new switch on the Agent Orchestration settings page turns it off. It only works for agents in Chat UI, so it is disabled while Chat UI is off.
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
Walkthrough
Priority: Merge Risk:
|
There was a problem hiding this comment.
Actionable comments posted: 2
ℹ️ Review info
⚙️ Run configuration
- Source mode: Auto
- Repository: Unavailable
- Branch: Unavailable
- File: No configuration file from this repository applied
- Commit: Unavailable
- Layers: Repository UI
- Review profile: CHILL
- Plan: Advanced
- Run ID:
4fdc9e26-cd88-4a55-b3c9-de0538dcd95a
📒 Files selected for processing: 29
src/main/native-chat/agent-session-wire/structured-agent-session-status-feed.tssrc/main/native-chat/agent-session-wire/structured-agent-session-status-observation.tssrc/main/runtime/orchestration/chat-worker-error-escalation.tssrc/main/runtime/orchestration/chat-worker-error-words.tssrc/main/runtime/orchestration/lightweight-run-worker-exit-escalation.test.tssrc/main/runtime/orchestration/structured-mailbox-pointer-host.tssrc/main/runtime/orchestration/worker-failure-escalation.tssrc/main/runtime/runtime-store-contract.tssrc/main/runtime/structured-chat-coordinator-mail-rig.test-fixture.tssrc/main/runtime/structured-chat-worker-error-escalation.test.tssrc/main/runtime/terminal/layout/terminal-resize-listeners.tssrc/main/runtime/workspaces/workspace-process-listing-dependencies.tssrc/main/runtime/workspaces/workspace-process-listing.tssrc/main/runtime/workspaces/workspace-selectors.tssrc/renderer/src/components/settings/OrchestrationChatErrorSetting.tsxsrc/renderer/src/components/settings/OrchestrationPane.test.tsxsrc/renderer/src/components/settings/OrchestrationPane.tsxsrc/renderer/src/components/settings/chat-error-escalation-copy.tssrc/renderer/src/components/settings/orchestration-search.tssrc/renderer/src/hooks/settings-navigation-capability-sections.tssrc/renderer/src/i18n/locales/en.jsonsrc/renderer/src/i18n/locales/es.jsonsrc/renderer/src/i18n/locales/fr.jsonsrc/renderer/src/i18n/locales/ja.jsonsrc/renderer/src/i18n/locales/ko.jsonsrc/renderer/src/i18n/locales/pt.jsonsrc/renderer/src/i18n/locales/zh.jsonsrc/shared/default-global-settings.tssrc/shared/global-settings-types.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 1 remain after this review.
There was a problem hiding this comment.
Actionable comments posted: 3
ℹ️ Review info
⚙️ Run configuration
- Source mode: Auto
- Repository: Unavailable
- Branch: Unavailable
- File: No configuration file from this repository applied
- Commit: Unavailable
- Layers: Repository UI
- Review profile: CHILL
- Plan: Advanced
- Run ID:
e2dd1160-a8bb-41af-abbc-baca4f33c414
📒 Files selected for processing: 15
src/main/native-chat/agent-session-journal/journal-store.tssrc/main/native-chat/agent-session-wire/structured-agent-session-client-delivery.tssrc/main/native-chat/agent-session-wire/structured-agent-session-conversations.tssrc/main/native-chat/agent-session-wire/structured-agent-session-host-types.tssrc/main/native-chat/agent-session-wire/structured-agent-session-host.tssrc/main/native-chat/agent-session-wire/structured-agent-session-request-failures.tssrc/main/persistence/loading-store/normalize-loaded-global-settings.test.tssrc/main/runtime/orchestration/chat-worker-error-escalation.tssrc/main/runtime/orchestration/chat-worker-error-words.tssrc/main/runtime/orchestration/chat-worker-request-failures.test.tssrc/main/runtime/structured-agent-session-runtime.tssrc/main/runtime/structured-chat-coordinator-mail-rig.test-fixture.tssrc/main/runtime/structured-chat-worker-error-escalation.test.tssrc/main/runtime/workspaces/workspace-process-listing.tssrc/renderer/src/components/settings/OrchestrationPane.test.tsx
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 0 remain after this review.
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to GitHub limitations.
🟡 Minor · Order interruption accounting behind committed… · structured-agent-session-request-failures.ts:124-141
src/main/native-chat/agent-session-wire/structured-agent-session-request-failures.ts:124-141
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick winOrder interruption accounting behind committed journal writes.
generationEndedreadsrunningTurn()before the child-exit path flushes lifecycle writes. A successful ACPturn.endcan therefore still appear as running whenrequest(..., true)produces an interruption. The later successful journal commit changes the mark but cannot retract the escalation.Queue this check with
journal.readInOrderso already-admitted completion writes settle first.Suggested fix
- const running = session.journal.runningTurn() - if (running) { - this.account( - sessionId, - baseline, - this.request(baseline, 'turn', running.item.itemId, true), - false - ) - } + void session.journal + .readInOrder(() => { + if ( + this.baselines.get(sessionId) !== baseline || + session.journal.epoch !== baseline.epoch + ) { + return + } + const running = session.journal.runningTurn() + if (running) { + this.account( + sessionId, + baseline, + this.request(baseline, 'turn', running.item.itemId, true), + false + ) + } + }) + .catch(() => undefined)
ℹ️ Review info
⚙️ Run configuration
- Source mode: Auto
- Repository: Unavailable
- Branch: Unavailable
- File: No configuration file from this repository applied
- Commit: Unavailable
- Layers: Repository UI
- Review profile: CHILL
- Plan: Advanced
- Run ID:
7809c60f-316c-4b48-8261-1e6c898cc07d
📒 Files selected for processing: 13
src/main/acp/acp-chat-worker-error-escalation.test.tssrc/main/acp/acp-prompt-turns.tssrc/main/acp/acp-structured-child-lifecycle.tssrc/main/acp/acp-structured-host.test-support.tssrc/main/acp/acp-structured-lane.tssrc/main/acp/acp-structured-session-adapter.tssrc/main/acp/acp-structured-turns.tssrc/main/native-chat/agent-session-wire/structured-agent-session-adapter-router.tssrc/main/native-chat/agent-session-wire/structured-agent-session-adapter.tssrc/main/native-chat/agent-session-wire/structured-agent-session-client-delivery.tssrc/main/native-chat/agent-session-wire/structured-agent-session-request-failures.tssrc/main/runtime/orchestration/chat-worker-error-escalation.tssrc/main/runtime/orchestration/chat-worker-request-failures.test.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 2 remain after this review.
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to GitHub limitations.
🟠 Major · Prefer pane identity when resolving a reminted… · chat-worker-error-escalation.ts:44-50
src/main/runtime/orchestration/chat-worker-error-escalation.ts:44-50
🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick winPrefer pane identity when resolving a reminted structured worker.
A structured worker can retain its persisted
paneKeywhile its handle is reminted.chatWorkerDispatchespasses both values togetActiveDispatchForTerminal, but the lookup returns the active row for the handle before checking the pane key. If another active Dispatch owns the reminted handle, the failure selects that row. The final recheck accepts it because its status and handle match the selected row. The failure is then escalated to the wrong Dispatch, while the pane-matching Dispatch receives no escalation.Suggested fix
diff --git a/src/main/runtime/orchestration/chat-worker-error-escalation.ts b/src/main/runtime/orchestration/chat-worker-error-escalation.ts @@ - const dispatch = worker && db.getActiveDispatchForTerminal(worker.handle, worker.paneKey) + const dispatch = + worker && + db.getActiveDispatchForTerminal(worker.handle, worker.paneKey, { preferPaneKey: true }) diff --git a/src/main/runtime/orchestration/db/dispatch-context/dispatch-lookup.ts b/src/main/runtime/orchestration/db/dispatch-context/dispatch-lookup.ts @@ export function getActiveDispatchForTerminal( this: OrchestrationDb, handle: string, @@ - assigneePaneKey?: string + assigneePaneKey?: string, + options?: { preferPaneKey?: boolean } ): DispatchContextRow | undefined { - return this.findActiveDispatchForAssignee(handle, assigneePaneKey) + return this.findActiveDispatchForAssignee(handle, assigneePaneKey, options) } @@ export function findActiveDispatchForAssignee( this: OrchestrationDb, assigneeHandle: string, - assigneePaneKey?: string + assigneePaneKey?: string, + options?: { preferPaneKey?: boolean } ): DispatchContextRow | undefined { const byHandle = this.db.prepare(ACTIVE_DISPATCH_BY_HANDLE_SQL).get(assigneeHandle) as | DispatchContextRow | undefined + if (options?.preferPaneKey && assigneePaneKey) { + const exactPane = this.db.prepare(ACTIVE_DISPATCH_BY_PANE_KEY_SQL).get(assigneePaneKey) as + | DispatchContextRow + | undefined + if (exactPane) { + return exactPane + } + if (parsePaneKey(assigneePaneKey)) { + const byPane = this.db + .prepare(ACTIVE_DISPATCH_BY_PANE_SUFFIX_SQL) + .get(paneKeyMatchSuffix(assigneePaneKey)) as DispatchContextRow | undefined + if (byPane) { + return byPane + } + } + } if (byHandle) { return byHandle }
ℹ️ Review info
⚙️ Run configuration
- Source mode: Auto
- Repository: Unavailable
- Branch: Unavailable
- File: No configuration file from this repository applied
- Commit: Unavailable
- Layers: Repository UI
- Review profile: CHILL
- Plan: Advanced
- Run ID:
67bf8001-786c-49e9-b9d0-290034b1cf6f
📒 Files selected for processing: 2
src/main/acp/acp-chat-worker-error-escalation.test.tssrc/main/native-chat/agent-session-wire/structured-agent-session-request-failures.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 2 remain after this review.
|
When an assigned Chat UI worker fails, its coordinator can keep waiting because only the chat records the error. This PR sends one high-priority escalation with the exact saved error to the owning coordinator and keeps the task assigned. The default-on desktop Orchestration setting explains Chat UI coverage and is disabled while Chat UI is off. Exact-request detail waits at most two seconds, with one alert and no follow-up. Review, product QA, final merge acceptance and CI passed. One normal Codex recovery reply completed after graceful same-profile relaunch, its task and Dispatch remain assigned and unrevoked, and exactly the original two error alerts remain. Final reviewed head is Three general review rounds, the architecture decision, late-detail verification, independent final comparison and performance review are complete. Fixes observe committed request outcomes, capture the admitted assignment/request, exclude Stop/close, and keep notification detached from user actions. Contracts cover the two-second boundary, saved settings migration, no replay, retained assignment and bounded work at 100/1,000 records. The earlier focused integration passed 139 tests in 11 named files; paired-web renderer assertions passed 7/7; the final merge check passed 41 tests in six named files. Independent final merge acceptance found no new integration regression. Final-head CI is green: run 40062724492.
The real mailbox contains one Claude incident and one Codex incident. Codex OFF produced no mail and UI reenable did not replay it. Normal Stop recorded Interrupted; deliberate close/reopen retained history without mail. A Deferred outside this PR: pre-existing Claude effort issue tracked in #31927, existing provider-error conversion observation and incoming-main queue-scan observations. No fix or pass for them is claimed. QA-only supported Claude 2.1.309 with explicit High completed the flow; machine CLI stayed untouched. Prior rigs stopped with recorded identities absent, ports clear and config hashes unchanged. Targeted ticket 2068 completed only the missing Codex reply and retained-profile evidence; the final rig and controllers stopped gracefully; sanitized export and visual audit are complete and ticket 2068 is released. For Brennan's review Main Retained branch settings proof (37a4c43, unchanged screen): Claude real error and successful recovery after restart, Codex actual error on Codex normal recovery after the graceful same-profile relaunch, on Three code spots for judgment: exact-request detail boundary, owning-coordinator mail insertion, and disabled setting with preserved choice. |









Problem
When a coordinator dispatches a task to an agent running in Chat UI, a failed request leaves the task assigned but gives the coordinator no error mail. The user can see the error in the chat while the coordinator continues waiting. Terminal-worker exit alerts already exist, but they do not cover a chat whose request fails while the chat remains open.
What changes for users
An assigned Chat UI worker's new request failure sends one high-priority escalation to its owning coordinator. The mail contains the exact error sentence and available detail recorded for that request. The task stays assigned, so the coordinator can help the worker recover or decide how to continue.
Settings → Agent Orchestration adds Tell the coordinator about chat errors, on by default. The description says it applies only to agents running in Chat UI. With Chat UI off, the row is disabled and explains how to enable it; the saved preference is preserved. The setting is local to the desktop and cannot be changed through the agent settings command.
A person's Stop or deliberate close does not trigger an alert. Historical errors are not replayed when a chat is restored or the setting is enabled. A new error after restoration can alert normally. A Dispatch whose initial instruction was definitively never delivered retains its existing failed-delivery behavior.
Implementation
The chat owner observes newly committed request outcomes, captures the active assignment and exact request identity, and handles notification separately from sending messages, stopping work, and completing turns. This covers failures even when other work remains queued. The sender rechecks assignment, setting, and journal lifetime before inserting mail; a stable incident identifier prevents duplicate mail. Notification failure cannot refuse the user's next action.
For a request whose exact agent answer is still pending, the alert waits up to two seconds for its saved error detail, then sends once using the words recorded by that boundary. Detail arriving later remains in the chat; there is no second alert. Unexpected process death uses the matching saved startup or exit cause.
Terminal and chat errors share the exception-contained mail sender. Terminal helper failures retain current creator-mailbox routing; chat failures retain the owning-Run destination.
Deliberate choices
Validation and current status
Product QA, final merge acceptance and CI passed. The retained Codex chat completed one normal reply after its error and graceful same-profile relaunch. Its task and Dispatch remain assigned and unrevoked; the mailbox still contains exactly the original Claude and Codex alerts. Final reviewed head is
b219ef6093f8a2cd27488c592090f86ecf05c70e. All 48 checks completed: 35 successful and 13 skipped. The sole initial filesystem-watcher timing failure passed on a failed-job-only retry; no product change was needed. All owned processes and controllers stopped, ticket 2068 is released, and the transferred evidence archive and screenshots were inspected.Three general review rounds, the architecture decision, late-detail verification, independent final comparison and performance review are complete. Automated contracts cover the exact-request two-second boundary, assignment revalidation, silence for Stop/close, no historical replay, settings migration, and bounded work at 100 and 1,000 saved records. The latest focused integration run passed 139 tests across 11 named files; the paired-web renderer suite passed all 7 tests, including absence from rendering and search. CI on QA source
1c8f53301493c8975073d2c054c49326eb294137completed all 48 checks (35 successful, 13 skipped). Final-head CI also completed all 48 checks (35 successful, 13 skipped). The final merge focused check passed 41 tests in six named files.Running-app QA uses shared-code representatives Claude and Codex on Windows low spec. A profile created on main
52e413ecwas gracefully upgraded to1c8f533; recorded source/process identities and graceful-stop receipts are retained.(code 1)detail; assignment retained; no duplicate after graceful restart; real recovery replies.CODEX2068_RECOVERY_OKcompleted after the graceful stop/relaunch, with no duplicate alert and the same assignment retained.Both real errors read “[Agent] stopped while this response was in progress. You can continue in this conversation.” The actual coordinator mailbox contains exactly one Claude incident and one Codex incident. Tests establish the late-detail timing cases; the live process-death trial does not establish every timing permutation.
QA source remains
1c8f533; test-only2ac088aadds the paired-web assertions and main mergesf573f4bandb219ef6carry the evidence under the merge/non-shipped-commit rule. Green final-head CI and the independent final merge acceptance cover integration. No individual provider adapter changed, so Claude and Codex represent the shared code; no agent waiver is claimed. The pre-existing Claude effort rejection is tracked in #31927 and was avoided with explicit High on the supported QA-only CLI. No fix for it is included.Screenshots
Main before upgrade, without the new row:
Branch setting default ON and disabled without Chat UI. These retained screenshots are from
37a4c430; the rendered screen is unchanged:Claude error and recovery after graceful restart on
1c8f533:Codex actual error on
1c8f533:Codex normal recovery after the graceful same-profile relaunch, on
1c8f533: