Repository navigation
fix: preserve cloud turns when follow-up input arrives - #132887
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
Codex review: needs maintainer review before merge. Reviewed August 29, 2026, 10:09 PM ET / August 30, 2026, 02:09 UTC. ClawSweeper reviewWhat this changesThe PR stages cloud follow-up input in per-agent SQLite until its own turn starts, then shows retained input separately in Gateway history and the Control UI. Warning SQLite table change This PR modifies persisted SQLite tables in Regression provenancePossible regression — probable (reproduction; reviewed change). No predecessor PR is attributed. Merge readinessKeep this maintainer-authored PR open for confirmation of its material durable-state design. Current main still appends the user turn during admission; the branch moves custody to the execution owner without weakening the worker transcript fence, and no discrete patch defect was found. Priority: P1 Review scores
Verification
How this fits togetherGateway admission accepts agent input before execution, while cloud workers commit against a fixed transcript base. This change holds follow-up input outside that transcript until the session execution owner promotes it, then projects the retained state to history consumers. flowchart LR
A[Gateway follow-up request] --> B[Admission]
B --> C[Durable pending input]
C --> D[Session execution owner]
D --> E[Canonical transcript]
C --> F[History API]
F --> G[Control UI]
Decision needed
Why: This is a durable user-visible retention and recovery policy, not a mechanical correctness choice; the linked acceptance record was unavailable for independent review. Before merge
Agent review detailsSecurityNone. PR surfaceSource +1466, Tests +1244, Docs +21, Generated +15, Other +8. Total +2754 across 74 files. View PR surface stats
Review metrics
Stored data modelPersistent data-model change detected: Root-cause clusterRelationship: Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Keep one stage-then-promote custody flow: retain accepted input only until the live execution owner appends it, preserve interrupted input as non-executable, and obtain explicit maintainer confirmation of that persistent product contract. Do we have a high-confidence way to reproduce the issue? Yes: current main visibly persists the follow-up during admission, and the changed worker-boundary regression composes overlapping admission with the worker's fixed base. Is this the best way to solve the issue? Yes for the technical defect: the branch moves input custody to the admission/execution boundary instead of weakening the worker compare-and-swap. The durable retention policy still needs maintainer confirmation. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against a1914a79cd3a. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (8 earlier review cycles)
|
f4919de to
ea11b87
Compare
|
Final maintainer verification for The retained interrupted-input policy was explicitly accepted in the task conversation before implementation, as recorded in #132547 (comment). Pending custody grants no replay authority; interruption retains readable input and requires an explicit new send. The production growth implements that accepted custody and bounded visibility boundary while reusing the existing scheduler and transcript writer. I personally inspected the sibling Codex source at The three-process older-reader proof was repeated on the final head: candidate → frozen Real API-key cloud creation and follow-ups through the Control UI and agent tools passed, including no-reload pending visibility, single promotion after the first reply, one visible command, and abrupt-restart retention without replay. The PR body contains the timeline and sanitized screenshots. The later rebase and readiness-fixture correction do not change the live-tested production patch. Final CI is green: https://github.com/openclaw/openclaw/actions/runs/33286890304. Native review and hosted preparation passed on that exact head. This addresses the latest ClawSweeper rank-up requests; its unavailable local context does not leave a new code finding unresolved. |
|
Merged via squash.
|
* fix: preserve cloud turns when follow-up input arrives * test: align session admission fixtures and checks * fix: refresh accepted input during active cloud turns * test: use complete page state for pending input events * fix(ui): keep live tool echoes with their canonical invocation * docs: clarify durable pending input coverage * fix(ui): read canonical run identity for tool activity * test: publish process readiness after signal setup
Closes #132547
Why
An agent follow-up could append to a cloud session's transcript while its first worker turn was still running. That changed the worker's expected base and caused
stale-base-leaf. The same input-ownership gap could duplicate CLI input or let an ACP prompt start before its canonical input existed.What changes
Gateway
agentadmission, includingsessions_send, retains approved input in per-agent SQLite before ACK without changing the active transcript. The existing execution owner appends the exact input and consumes its pending record in one transaction when its turn starts. Worker transcript fencing and the existing queues/scheduler remain unchanged.Pending rows retain text and existing media metadata after cancellation or restart, but grant no execution authority. Promotion requires the original private live closure, physical session, lifecycle, run and current transcript anchor. Cancelled/interrupted input is readable in bounded Control UI and
sessions_historyprojections, separately from model history, and requires an explicit new send. The writer queue preserves caller async context; stale branch projections cannot replace active anchors. Native, CLI and ACP execution use the canonical recorder, and terminal mirrors cannot synthesize replacement input.Live testing also repaired two UI defects: pending input now refreshes through the existing session/connection-fenced history owner without a reload, and canonical/live tool echoes coalesce using the actual
__openclaw.runIdhistory identity. The original top-level-only fixtures missed that payload shape; three corrected regressions fail before the final repair.The additive custody design was explicitly accepted before implementation. Schema version stays 19, with lazy first-use creation and older-reader compatibility. No new configuration option, dependency, protocol version, scheduler or automatic replay path.
Verification
Live-tested head
f4919de936b9fd7aec9439124e2e6737cde43d86: full CI passed, normal package/UI build passed, and real Chrome/cloud proof passed using an OpenAI API-key profile andopenai-responses.Main advanced during live testing, so the branch was rebased to
ea11b879f12498b718024d4df4f8de61ef6d1d2f. Range-diff confirms all production commits are unchanged; only three generated prompt snapshot hashes/counts changed. Canonical generation and independent snapshot verification passed, and the resolution passed Codex review. The rebased CI run passed all jobs except a pre-existing process-fixture readiness race: the fixture published its PID before installing its SIGTERM handler. Commit3d4cfe67478c2f26ddf392fda347cf95c7dd5a82fixes that ordering in the tracked-process and sibling watchdog fixtures, without changing assertions, timeouts or production code. Forced-interleaving proof fails before and passes after; all 34 tests in the file, the changed-file gate and Codex review pass. Final-head CI passed: 193 successful jobs and seven intentional skips, including the required aggregate gate. No additional production behavior was introduced by the rebase or fixture correction.The final UI-created AWS cloud session ran one 120-second command. While it was active, a browser follow-up and a Gateway agent follow-up were submitted. The active command appeared once; the agent input appeared as one retained pending row without a reload.
dae3095b-818f-4a9b-884f-d8688b9a88e4accepted while first turn activeThe pending indicator retired without a reload. The ordinary browser follow-up also completed afterward. Earlier real flows additionally covered Control UI parent creation → actual
sessions_spawn→sessions_send, with direct AWS filesystem marker verification. The worker's content-addressed production bundle is unchanged across these UI/test follow-ups; final Gateway/UI build is the exact head above.Abrupt restart proof: a separate accepted input was captured while an API-backed cloud command was active, then only the isolated Gateway was SIGKILLed. After restart and a normal authenticated history read, the exact input ID/text/acceptance timestamp remained, its state was
interrupted, the old execution claim was cleared, and no canonical event or output replayed that pending input. The UI explicitly says it will not run automatically. The earlier graceful-stop attempt raced promotion; the final abrupt test captures both sides of the actual crash.Focused verification includes 335 initial owner tests, 68 shared-owner siblings, 267 follow-up tests (4 platform skips), 580 native/script tests, 291 Gateway handler tests, 112 UI invalidation tests and the final 364 UI ownership/history/stream/pending tests. Core/UI/full core-test types, type-aware lint and complete changed-file gates pass. The earlier CI timeout cascade came from obsolete eager-write mocks; the handler suite now uses the admission boundary. Required P0-only independent Codex reviews reported no findings.
Frozen pre-fix tests reproduce stale-base-leaf in the original execution order, CLI duplication and ACP pre-prompt omission. Repeated on final head
3d4cfe67478c2f26ddf392fda347cf95c7dd5a82, the actual three-process candidate → frozen older-readerd3c07b02e244e73470df4a930911e8d58c4e456dappend → candidate reopen proof passed. It preserves the exact pending ID/message bytes/interrupted disposition, schema 19 and schema metadata. All 13 frozen source/loader hashes match the original baseline receipt; the older accessor performs an ordinary append and the candidate still displays the retained pending input. Storage tests cover atomic rollback, cancellation, lifecycle/physical-session replacement, exact identity and bounded pages.Direct Codex contract inspection:
codex-rs/core/src/session/inject.rs:15, including active queuing, idle recording and no-new-turn injection. No Codex protocol change. Shallow OpenClaw history does not establish the original introducing PR.Production LOC: +1708/-278, net +1430; tests net +1276; generated +27; docs +21. Growth implements the accepted custody, lifecycle cleanup and bounded visibility contract. Moving append alone would lose accepted input after interruption; the existing execution and transcript owners are reused.
Scope and follow-ups
chat.sendstill uses its existing collect/follow-up queue and does not yet receive exact-input durable custody. Docs explicitly state this. These existing surfaces do not promise global FIFO; durable source-to-aggregate collection needs a separately accepted persistence design.memory.search.remote.apiKeyreference to the same environment key, preserving the index and pending state. It does not claim the auth-profile-only startup bug is fixed.ClawSweeper rank-up follow-through: the reported merge conflict is resolved by the generated-only rebase, with final-head CI passed after the verified fixture correction; live pending/promotion and single-card proof for the unchanged production patch is supplied; the accepted storage design, older-reader proof and direct Codex inspection are recorded above. No access check, reviewer isolation or native workflow guard was bypassed.
Before and after
Before the final metadata repair: duplicate command around the browser follow-up.
After: one command, separate retained input, no reload.
Completed: replies in canonical order and no pending indicator.
After abrupt restart: retained input is explicitly interrupted and non-executable.
All six task-owned cloud leases were verified released. The isolated Gateway, tunnels, package server and test tab are stopped; the temporary API-key file, private runtime state and task dependencies were removed.