Repository navigation
fix: deliver background command results in incognito chats and when storing them fails - #204532
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: needs changes before merge. What this changesThis PR detaches background completion delivery from the finished turn’s context, attempts a live wake after storage failure, and updates affected tests and CI routing. Example: An incognito chat starts
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness⛔ Needs changes before merge - 1 item remains Keep open: this PR addresses a source-verifiable completion-delivery bug with a focused repair, and I found no discrete introduced defect. Priority: P1 Before merge
FindingsNone. Tests
Agent review detailsHow this fits togetherThe exec completion owner converts finished process output into an owed session input and submits it through session-event admission for an agent turn and chat reply. flowchart TD
A[Background command exits] --> B[Exec completion owner]
B --> C[Session actor and owed storage]
C --> D[Completion wake batching]
B -->|Storage failure| D
D --> E[Session event admission]
E --> F[Agent completion turn]
F --> G[Chat reply]
Technical reviewBest possible solution: Keep the focused forward repair in the existing completion owner while preserving stored-result ordering, restart recovery, and captured delivery authority. Do we have a high-confidence way to reproduce the issue? Current-main source establishes that an owe rejection skips delivery, and the inherited incognito binding explains the reported admission failure; no target code was executed during this review. Is this the best way to solve the issue? The patch uses existing lifetime-detachment helpers and the existing wake owner, updates consumers of the established owed-ID contract, and adds focused CI selection without introducing another delivery mechanism. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against ca33faf055fd. Provenance checked
TestingProof path: in-process harness. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +18, Tests +119, Docs +3, Other +17. Total +157 across 10 files. Added test files: 1. View PR surface stats
Preflight sourceSource unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified. LabelsLabel changes:
Label justifications:
Rating scale6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior. WorkflowClawSweeper edits this one comment on every review. Comment Reviewed November 24, 2026, 4:40 AM ET / 09:40 UTC. |
|
Maintainer override for the red check on head
All shards that run the 5 previously red exec-notification files, the new store-failure test and the planner integration test passed on this head. |
…toring them fails The exec completion runs in the async context of the turn that started the command. An incognito turn's session-actor binding and work signal end with that turn, so the owed row write (and, before #204265, the live wake) failed and the result was only logged. Store and wake outside that context. If owe() still fails, wake the chat once live. Key the durable restart notice test by the adopted process instance, and declare the exec completion tests for src/sessions/owed.ts in the changed-test planner, which missed them for #204265. Co-authored-by: obviyus <[email protected]>
434ca10 to
84c1503
Compare
…204572) ## Problem When a background command's completion fails to reach its chat, the Gateway log does not say whether the chat was incognito. #204532 fixed a loss that hit only incognito chats, and these lines could not tell the two kinds apart. ## Solution Every exec completion failure line in `bash-tools.exec-notify.ts` now names the session kind (`incognito` or `normal`): no destination, delivery failed, stays owed, no admitted destination, not stored (fallback), not admitted, and not queued. The lines add no session key or session id. The process slug and owed id stay; they identify the command, not the chat. Error text from the failing operation is still logged as it is. Logs are written raw and redacted at egress (repository logging rule). ## Impact Log text only. No behavior change. ## Evidence - `bash-tools.exec-notify.store-failure.test.ts`, `bash-tools.exec-runtime.test.ts` and `bash-tools.notify-on-exit-ack.test.ts` pass. - `pnpm tsgo:core` passes. Co-authored-by: Ayaan Zaidi <[email protected]>
Carry only the durable-process fixture correction from 0164469 (#204532). Preserve the exact notice count, fate text, collision guard and cleanup assertions. Co-authored-by: Ayaan Zaidi <[email protected]>
…toring them fails (#204532) 1. **Incognito chats never get a background command's completion turn.** On a scratch Gateway with a real model, an incognito chat runs a background command, replies, and then nothing happens when the command finishes. The completion runs in the async context of the turn that started the command. For an incognito chat, that context holds the turn's session-actor binding and work signal, and both end with the turn. - Before #204265 (`463d7748^`): the live wake fails with `SessionDeliveryGenerationUnavailableError`. - On `main`: `owe()` fails first, and the Gateway logs `[exec] completion was not admitted (Chat session storage admission ended)`. So this predates #204265. #204265 only moved the failure point. 2. **A failed `owe()` drops the result.** Since #204265, `notifyOnExit` stores the result (`owe()`) before it wakes the chat, and its catch only logs a failed `owe()`. Any store failure (busy database, store fence) silently drops a produced result. 3. **Five exec-notification test files went red on scheduled `main`** (run 45348156095); #204507 fixed four. #204265's PR CI did not select them. It changed `src/sessions/owed.ts`, and these tests live in `src/agents/`, past the two-import walk. This is the cross-directory miss the #204346 closing loop covers. - `notifyOnExit` stores and wakes outside the producing turn's session-actor binding and work scope (`runWithoutSessionActorStorage`, `runOutsideAsyncWorkScope`). Both are existing helpers for independent work. The completion acquires its own session actor, so incognito chats store the owed row and get their completion turn. - If `owe()` still fails, the completion wakes its chat once through the same live wake, without a stored row. That one result loses restart recovery, and the Gateway logs why. It is never only logged. - #204507 already moved four of the five red files to the owed-row contract (owed-id context keys). The fifth, `bash-process-durable.test.ts`, still counted restart notices by the old slug key `exec:<slug>`; its helper now resolves the adopted process instance (`processSessionInstanceId`). - New `bash-tools.exec-notify.store-failure.test.ts`: `owe()` rejects, and the completion still wakes its chat once. - #204346 closing loop: `src/sessions/owed.ts` is now an owner in `scripts/lib/ci-changed-node-test-plan.mts`. A change to it selects a declared set: the 5 test files and the new store-failure test. A planner test checks that selection. - Fixes a pre-existing loss: incognito exec results were also lost before #204265 (baseline b8c95a3 repro). On the measured production deployment: 0 events in the retained ~3.8-day window. - Incognito chats get background command completion turns. - A produced exec result is never only logged when its row cannot be stored. - Ordinary chats: no change (Goal ordering and restart exactly-once re-proven below). - Production: 1 file, +27 −7. - **Incognito, real Gateway** (scratch state and ports, real model; the chat runs a background command, replies `STARTED`, then must answer the completion): - before #204265 (`463d7748^`): no completion turn; `[exec] completion delivery failed (SessionDeliveryGenerationUnavailableError …)`. - `main`: no completion turn; `[exec] completion was not admitted (Chat session storage admission ended)`. - this PR: the completion turn runs (`SEEN_…` reply); no exec warnings, so the owed row was stored. - **Ordinary chats, real Gateway, this PR:** `Exec completed` precedes the Goal's Advance turn and is appended once; a result pending across a Gateway restart is appended exactly once after it (4/4 checks). - **Store failure:** `bash-tools.exec-notify.store-failure.test.ts` fails on `main` (the wake is called 0 times) and passes here. - **Tests (rebased on `main`):** the 5 files plus exec background follow-up, requester, queue-full, yield sweep and planner integration: all pass, except that locally on macOS `bash-process-durable.test.ts` stops at the Darwin ACL guard in `@openclaw/fs-safe` before its assertion (CI on Linux runs it). `server.chat-goal.test.ts` 72/72. `pnpm tsgo:core` passes. - **Planner:** `ci-changed-node-test-plan.integration.test.ts` checks that a change to `src/sessions/owed.ts` selects the 6 declared tests. Co-authored-by: Ayaan Zaidi <[email protected]> (cherry picked from commit 0164469) Co-authored-by: RomneyDa <[email protected]>
…toring them fails (openclaw#204532) ## Problem 1. **Incognito chats never get a background command's completion turn.** On a scratch Gateway with a real model, an incognito chat runs a background command, replies, and then nothing happens when the command finishes. The completion runs in the async context of the turn that started the command. For an incognito chat, that context holds the turn's session-actor binding and work signal, and both end with the turn. - Before openclaw#204265 (`7a8c93cd^`): the live wake fails with `SessionDeliveryGenerationUnavailableError`. - On `main`: `owe()` fails first, and the Gateway logs `[exec] completion was not admitted (Chat session storage admission ended)`. So this predates openclaw#204265. openclaw#204265 only moved the failure point. 2. **A failed `owe()` drops the result.** Since openclaw#204265, `notifyOnExit` stores the result (`owe()`) before it wakes the chat, and its catch only logs a failed `owe()`. Any store failure (busy database, store fence) silently drops a produced result. 3. **Five exec-notification test files went red on scheduled `main`** (run 45348156095); openclaw#204507 fixed four. openclaw#204265's PR CI did not select them. It changed `src/sessions/owed.ts`, and these tests live in `src/agents/`, past the two-import walk. This is the cross-directory miss the openclaw#204346 closing loop covers. ## Solution - `notifyOnExit` stores and wakes outside the producing turn's session-actor binding and work scope (`runWithoutSessionActorStorage`, `runOutsideAsyncWorkScope`). Both are existing helpers for independent work. The completion acquires its own session actor, so incognito chats store the owed row and get their completion turn. - If `owe()` still fails, the completion wakes its chat once through the same live wake, without a stored row. That one result loses restart recovery, and the Gateway logs why. It is never only logged. - openclaw#204507 already moved four of the five red files to the owed-row contract (owed-id context keys). The fifth, `bash-process-durable.test.ts`, still counted restart notices by the old slug key `exec:<slug>`; its helper now resolves the adopted process instance (`processSessionInstanceId`). - New `bash-tools.exec-notify.store-failure.test.ts`: `owe()` rejects, and the completion still wakes its chat once. - openclaw#204346 closing loop: `src/sessions/owed.ts` is now an owner in `scripts/lib/ci-changed-node-test-plan.mts`. A change to it selects a declared set: the 5 test files and the new store-failure test. A planner test checks that selection. ## Impact - Fixes a pre-existing loss: incognito exec results were also lost before openclaw#204265 (baseline e5607f8 repro). On the measured production deployment: 0 events in the retained ~3.8-day window. - Incognito chats get background command completion turns. - A produced exec result is never only logged when its row cannot be stored. - Ordinary chats: no change (Goal ordering and restart exactly-once re-proven below). - Production: 1 file, +27 −7. ## Evidence - **Incognito, real Gateway** (scratch state and ports, real model; the chat runs a background command, replies `STARTED`, then must answer the completion): - before openclaw#204265 (`7a8c93cd^`): no completion turn; `[exec] completion delivery failed (SessionDeliveryGenerationUnavailableError …)`. - `main`: no completion turn; `[exec] completion was not admitted (Chat session storage admission ended)`. - this PR: the completion turn runs (`SEEN_…` reply); no exec warnings, so the owed row was stored. - **Ordinary chats, real Gateway, this PR:** `Exec completed` precedes the Goal's Advance turn and is appended once; a result pending across a Gateway restart is appended exactly once after it (4/4 checks). - **Store failure:** `bash-tools.exec-notify.store-failure.test.ts` fails on `main` (the wake is called 0 times) and passes here. - **Tests (rebased on `main`):** the 5 files plus exec background follow-up, requester, queue-full, yield sweep and planner integration: all pass, except that locally on macOS `bash-process-durable.test.ts` stops at the Darwin ACL guard in `@openclaw/fs-safe` before its assertion (CI on Linux runs it). `server.chat-goal.test.ts` 72/72. `pnpm tsgo:core` passes. - **Planner:** `ci-changed-node-test-plan.integration.test.ts` checks that a change to `src/sessions/owed.ts` selects the 6 declared tests. Co-authored-by: Ayaan Zaidi <[email protected]>
…penclaw#204572) ## Problem When a background command's completion fails to reach its chat, the Gateway log does not say whether the chat was incognito. openclaw#204532 fixed a loss that hit only incognito chats, and these lines could not tell the two kinds apart. ## Solution Every exec completion failure line in `bash-tools.exec-notify.ts` now names the session kind (`incognito` or `normal`): no destination, delivery failed, stays owed, no admitted destination, not stored (fallback), not admitted, and not queued. The lines add no session key or session id. The process slug and owed id stay; they identify the command, not the chat. Error text from the failing operation is still logged as it is. Logs are written raw and redacted at egress (repository logging rule). ## Impact Log text only. No behavior change. ## Evidence - `bash-tools.exec-notify.store-failure.test.ts`, `bash-tools.exec-runtime.test.ts` and `bash-tools.notify-on-exit-ack.test.ts` pass. - `pnpm tsgo:core` passes. Co-authored-by: Ayaan Zaidi <[email protected]>
Problem
Incognito chats never get a background command's completion turn. On a scratch Gateway with a real model, an incognito chat runs a background command, replies, and then nothing happens when the command finishes. The completion runs in the async context of the turn that started the command. For an incognito chat, that context holds the turn's session-actor binding and work signal, and both end with the turn.
463d7748^): the live wake fails withSessionDeliveryGenerationUnavailableError.main:owe()fails first, and the Gateway logs[exec] completion was not admitted (Chat session storage admission ended).So this predates fix: let finished background commands reach the agent before an active goal advances #204265. fix: let finished background commands reach the agent before an active goal advances #204265 only moved the failure point.
A failed
owe()drops the result. Since fix: let finished background commands reach the agent before an active goal advances #204265,notifyOnExitstores the result (owe()) before it wakes the chat, and its catch only logs a failedowe(). Any store failure (busy database, store fence) silently drops a produced result.Five exec-notification test files went red on scheduled
main(run 45348156095); fix(ci): align exec completion fixtures with process identity #204507 fixed four. fix: let finished background commands reach the agent before an active goal advances #204265's PR CI did not select them. It changedsrc/sessions/owed.ts, and these tests live insrc/agents/, past the two-import walk. This is the cross-directory miss the fix(ci): bound agent owner PR selection to same-directory importers and a declared behavior set #204346 closing loop covers.Solution
notifyOnExitstores and wakes outside the producing turn's session-actor binding and work scope (runWithoutSessionActorStorage,runOutsideAsyncWorkScope). Both are existing helpers for independent work. The completion acquires its own session actor, so incognito chats store the owed row and get their completion turn.owe()still fails, the completion wakes its chat once through the same live wake, without a stored row. That one result loses restart recovery, and the Gateway logs why. It is never only logged.bash-process-durable.test.ts, still counted restart notices by the old slug keyexec:<slug>; its helper now resolves the adopted process instance (processSessionInstanceId).bash-tools.exec-notify.store-failure.test.ts:owe()rejects, and the completion still wakes its chat once.src/sessions/owed.tsis now an owner inscripts/lib/ci-changed-node-test-plan.mts. A change to it selects a declared set: the 5 test files and the new store-failure test. A planner test checks that selection.Impact
Fixes a pre-existing loss: incognito exec results were also lost before fix: let finished background commands reach the agent before an active goal advances #204265 (baseline b8c95a3 repro). On the measured production deployment: 0 events in the retained ~3.8-day window.
Incognito chats get background command completion turns.
A produced exec result is never only logged when its row cannot be stored.
Ordinary chats: no change (Goal ordering and restart exactly-once re-proven below).
Production: 1 file, +27 −7.
Evidence
STARTED, then must answer the completion):463d7748^): no completion turn;[exec] completion delivery failed (SessionDeliveryGenerationUnavailableError …).main: no completion turn;[exec] completion was not admitted (Chat session storage admission ended).SEEN_…reply); no exec warnings, so the owed row was stored.Exec completedprecedes the Goal's Advance turn and is appended once; a result pending across a Gateway restart is appended exactly once after it (4/4 checks).bash-tools.exec-notify.store-failure.test.tsfails onmain(the wake is called 0 times) and passes here.main): the 5 files plus exec background follow-up, requester, queue-full, yield sweep and planner integration: all pass, except that locally on macOSbash-process-durable.test.tsstops at the Darwin ACL guard in@openclaw/fs-safebefore its assertion (CI on Linux runs it).server.chat-goal.test.ts72/72.pnpm tsgo:corepasses.ci-changed-node-test-plan.integration.test.tschecks that a change tosrc/sessions/owed.tsselects the 6 declared tests.