Repository navigation
fix: goals stop pursuing after a background command completes - #187069
Conversation
A background exec completion is admitted as a session-event turn. When that turn ended normally, its Goal successor inherited the event occurrence's abort signal, settlement hooks, and one-shot source delivery. Retiring the occurrence aborted the queued nudge, so pursuit stopped with the Goal still active. The successor now keeps only its own cancellation and the session's ordinary routed delivery when its source is a session event. Co-authored-by: hannesrudolph <[email protected]>
Worked on by: - @hannesrudolph Co-authored-by: hannesrudolph <[email protected]> OpenClaw-Publication: 303a6874-5b39-4f4a-9d76-1d270b4bf891
|
🦞👀 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 maintainer review before merge. What this changesThis PR detaches Goal continuations from completed session events’ cancellation, settlement, and one-shot delivery hooks. Example: An active Goal receives a background exec completion before its next continuation.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review Keep open: this PR addresses a concrete Goal-continuation lifetime bug still present on main; no actionable introduced defect was identified. Priority: P2 Before mergeNone. FindingsNone. Tests
Agent review detailsHow this fits togetherThe reply layer converts normally completed turns into queued Goal nudges; the session controller admits them against current Goal, session, cancellation, and operator-authority facts. flowchart TD
A[Background exec completion] --> B[Session event turn]
B --> C[Goal continuation owner]
C --> D[Followup queue]
D --> E[Session admission]
E --> F[Agent execution]
F --> G[Session reply delivery]
F --> C
Technical reviewBest possible solution: Keep the event-specific lifetime correction in the existing Goal owner while preserving ordinary queue admission, Stop, and operator-authority checks. Do we have a high-confidence way to reproduce the issue? Source shows the inherited occurrence signal and one-shot delivery lifetime mismatch, supported by the author’s reported red-base/green-fix Gateway regression; no target code was executed during this review. Is this the best way to solve the issue? The patch is a small correction at the existing successor-construction owner, and both added scenarios protect distinct lifecycle outcomes without introducing another continuation mechanism. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 2742aa01664c. Provenance checked
TestingProof path: in-process harness. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +13, Tests +53. Total +66 across 2 files. Added test files: 0. View PR surface stats
LabelsLabel changes:
Label justifications:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
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 October 28, 2026, 7:09 PM ET / 23:09 UTC. |
A Goal successor detached from its session-event source no longer kept that event's explicit delivery suppression. When a background completion was silent (deliver: false), the successor's ordinary reply could still route to the session's external origin, and its own background work could deliver. The successor now carries the suppression as a run-owned policy that follow-up delivery and background producers honor, without retaining the event's occurrence-scoped callbacks or signal. Co-authored-by: hannesrudolph <[email protected]>
Worked on by: - @hannesrudolph Co-authored-by: hannesrudolph <[email protected]> OpenClaw-Publication: 0b1f0b3a-6800-4268-8029-fcbcf34afcbd
#187090 reshaped the shutdown and spawn-broker test mock factories without updating the mock-export ratchet, so their grandfathered entries no longer matched and every pull request merged with main failed the ratchet. These factories intentionally keep the real modules unloaded: the shutdown test records which runtime modules preparation loads, and the spawn-broker test replaces core startup to observe only broker and admission ownership. Mark them with mock-isolation reasons and prune the stale baseline entries. Co-authored-by: hannesrudolph <[email protected]>
Worked on by: - @hannesrudolph Co-authored-by: hannesrudolph <[email protected]> OpenClaw-Publication: 4a4e8039-4176-4f03-b353-b15660a428e1
…-continuation # Conflicts: # src/gateway/server-shutdown.runtime.test.ts # src/gateway/server.chat-goal-continuation.test-support.ts # src/gateway/server.spawn-broker.test.ts
Worked on by: - @hannesrudolph Co-authored-by: hannesrudolph <[email protected]> OpenClaw-Publication: 1c0c6253-8ccd-42eb-bad5-1b39be252b15
A Goal successor detached from its session-event source no longer carried internalEventExecution, which also classified the run as event-originated. On a session with an external route, the successor could then mint a trusted current-conversation message-action capability from the event's captured route, and refresh command-owner authority from the run's requester origin, unlike its event source. The successor now keeps the event origin as run-owned data (sessionEventOrigin), which carries the explicit delivery suppression and is consulted by the capability and owner-authority gates without retaining the event's occurrence callbacks or signal. Co-authored-by: hannesrudolph <[email protected]>
The Goal regression tests add 149 counted test lines (measured as the test-lines ratchet's net delta against main). Raise the ceiling by exactly that allowance, from 6,243,924 to 6,244,073. Co-authored-by: hannesrudolph <[email protected]>
An exec completion from a configured channel owner is admitted with that
requester's command-owner authority, whose live check also asserts the event
occurrence is current. The Goal successor copied that capability. Once the
event settled, the successor's admission ran the occurrence check and failed
("Session event occurrence is settled"), so owner-started work still stalled.
The event context now also supplies a successor form holding only the
requester's own live owner check (or the live operator source). The Goal
successor moves to that form and drops the occurrence-bound check; without it,
the successor holds no owner authority. Ownership is not refreshed from the
event's delivery route, and revocation still stops the successor before it runs.
Co-authored-by: hannesrudolph <[email protected]>
The owner-successor regression cases bring the Goal fix's counted test lines to 260 (the test-lines ratchet's net delta against main). Keep the ceiling raised by exactly that allowance: 6,243,924 to 6,244,184. Co-authored-by: hannesrudolph <[email protected]>
Worked on by: - @hannesrudolph Co-authored-by: hannesrudolph <[email protected]> OpenClaw-Publication: 429f4f93-c651-46fe-9f26-548706c48246
…-continuation # Conflicts: # config/test-lines-baseline.txt
…vocation Co-authored-by: hannesrudolph <[email protected]>
Worked on by: - @hannesrudolph Co-authored-by: hannesrudolph <[email protected]> OpenClaw-Publication: f598e8cb-3785-4632-b4af-751ef71af046
Related: #186928, #183705
What Problem This Solves
Fixes: an active Goal stops pursuing, with no further continuation turns, after a background command completes and its completion takes the next turn.
User Impact
User impact: a Goal keeps moving after a background exec completion is delivered as its own turn, including when the command was started by a configured command owner. A completion that was explicitly silent (
deliver: false) keeps its continuation turns silent too, and pause or Stop during that pursuit is still honored. Continuation turns never gain authority the original requester did not have.Scope limits: this does not address length/token-limit endings (#186928), Goals created mid-turn (#183705 / #183706), Resume after Stop (#185273, landed separately), or non-built-in harnesses. It is not presented as the explanation for every reported Goal stall.
Why This Change Was Made
A background exec completion is admitted as a session-event turn. When that turn ended normally,
enqueueGoalContinuationbuilt the Goal nudge from the event run and inherited itsabortSignal,internalEventExecutionsettlement hooks, and one-shotqueuedFollowupReplyDisposition. Instrumentation showed two failures: retiring the settled exec occurrence (thesystem-events.tscancel path) aborted the queued nudge, and a nudge that survived reused the already-settled one-shot delivery, so its operation endedrun_failedand cancelled the next nudge. The Goal stayed active withcontinuationTurns: 0.The Goal successor of a session-event turn now owns three things separately, none of them tied to the event occurrence:
sessionEventOrigin: { deliver: false }). Follow-up delivery and background producers honor it.Non-event sources are unchanged.
Evidence
Tests that fail on the earlier code and pass on this head (Gateway goal suite; model mocked, real admission, queue and session-event handoff):
main9cb5447both time out at 120s with the Goal still active. On this head, 4 turns run, the Goal completes withcontinuationTurns: 2, and successors of the silent completion run withsessionEventDelivery: false.prepareExecExitNotification→maybeNotifyOnExit, configured ownertelegram:456). The previous candidate is70f8bd4.70f8bd4senderIsOwner: true)sessionEventDelivery: false789) completionsenderIsOwner: false)assertInvocationCurrent) allows an owner-only effect, then refuses the next one once the owner is removed from config. The refusal's cause isCommandOwnerRevokedError; no further successor runssessions.abortaborts it; no further turns run; Goal resumes onceLimitation of the after-admission case: the guarded "effect" is a test-only action (an array append) behind the production admission assertion, not a production tool's
execute. How individual tools apply that assertion is covered by their existing tests. Temporarily making the successor's owner check always pass makes this test fail, but by a drain timeout (the Goal keeps continuing) rather than at the effect assertion.goal-continuation.test.ts, "binds channel-turn authority only for successors of …"):7d36425, event-derived successors received a current-conversation capability. On this head they receive none.followup-delivery.test.ts"keeps a silent source event's successor off every automatic route". One3d85ddthe successor's progress and final reply were routed to the external origin twice. On this head there is no route or dispatcher call.server.chat-goal.test.ts52/52.goal-continuation+followup-delivery+agent-runner-utils131/131.session-event-handoff+session-event-permissions51/51.check:baseline-ratchetsagainstmain: all 9 pass.tsgo:test:src), format and changed-file lint pass.main's test-line ceiling (6,320,000, chore: restore measured test-code headroom #187162). The earlier ceiling change was dropped whenmainwas merged in.Real Gateway proof: an in-process Gateway using a scripted loopback model, a real
execbackground process with completion wake, andsessions.abortfor Stop. Delivery restrictions were read from the Gateway's live run registry. The harness is task-local and not part of this diff. Limitation: no external channel was loaded in that Gateway, so suppression of an actual outbound send is proven by the follow-up delivery test above, not by a live external send.main9cb5447e3d85dd/goal start→execbackground → real completion turn → pursuit → StopcontinuationTurns: 0continuationTurns: 2delivery: nonescheduled turn in the Goal session (silent completion)continuationTurns: 0sessionEventDelivery: false; Stop aborts and no further turns runWork sessions
Worked on by