Skip to content

fix: retain accepted browser follow-ups across restarts - #133457

Merged
steipete merged 8 commits into
mainfrom
codex/browser-collect-custody
Aug 30, 2026
Merged

steipete merged 8 commits into
mainfrom
codex/browser-collect-custody

Conversation

@steipete

@steipete steipete commented Aug 30, 2026 •

Copy link
Copy Markdown
Contributor

Related: #132887

What Problem This Solves

A Control UI follow-up could be acknowledged while its approved input still existed only in the Gateway's in-memory queue. A restart before transcript append could lose it. Collection could also leave stale browser copies when several inputs became one turn and the browser missed the corresponding events.

What Changes

The existing per-agent pending-input store takes custody before ACK. The existing transcript transaction consumes every collected source when it appends their combined turn. Exact source identities, approved bytes, physical-session identity and live lifecycle authority remain required. History returns bounded, session-scoped consumption receipts so the browser can reconcile missed events.

Restart retains accepted input visibly as Interrupted for explicit resend. It does not restore old callbacks, grants, or worker claims, and it does not automatically replay queued input. Unsubmitted browser drafts keep their existing local ownership. Native steering carries the incoming input's own recorder; queued shutdown uses the canonical restart reason; collection reuses staged approval rather than running the source hook twice.

One bare nullable consumed_event_id TEXT column is added to the existing table. Agent schema version remains 19, with canonical schema declaration, first-use ensure and the existing Doctor migration owner. The maintainer explicitly accepted this persistence design and forward beta-to-release Doctor boundary, and renewed authorization to simplify, live-test and land. Intermediate pending-aware development builds can reject the extra column despite sharing version 19; arbitrary downgrade compatibility is not promised. No additional database, table, journal, configuration, index, cache, retention or concurrency policy is introduced.

Simplification and Performance

The final pass removes 12 production lines. It folds duplicate recorder resolution/callback paths together, batches indexed physical-session and source-row reads, scans history once against bounded source IDs, and retires existing projection entries without reseeding and repeatedly searching them. Single-flight resolution, immutable sorting, media timing, cancellation and exact authority validation remain intact.

Local source-helper measurements—not end-to-end browser or model latency:

Operation Before After
Reconcile 20 pending inputs against 1,000 history messages 1.635 ms 0.076 ms
Retire 8 accepted sources against 1,000 history messages 0.451 ms 0.023 ms
Read 50 collected 1 KiB sources from file-backed SQLite 0.513–0.521 ms 0.106–0.109 ms

Whole-PR LOC: production +844/-209 (net +635); tests/support +1802/-135 (net +1667); generated +10/-1; docs +34/-11. Production growth owns durable admission, atomic multi-source consumption, bounded receipts and lifecycle validation; it reuses the existing store/collector/transcript transaction instead of creating a second service.

Single-source SQLite performance was effectively unchanged. The storage probe confirms one physical-session query per batch and one query for the collected source rows; private operational predicates are still validated at promotion.

Validation

The performance candidate passed 579 UI tests and 116 recorder/media/storage/collector tests, plus corrected scoped lint. Fresh Codex reviews were scoped-clean at the configured P0 threshold. Earlier full-owner coverage includes gateway admission/history/shutdown, native first-turn Stop, direct promotion/recovery, consumed-source retry, source-byte/lifecycle rejection, physical-session isolation and browser receipt coalescing. Admission, collection, native-recorder and UI regressions were observed failing against pre-fix production code.

Actual Doctor validation upgraded synthetic frozen beta schema 17 data to schema 19, preserved exact transcript bytes and labels, made repeat migration a no-op, and passed cold-reopen integrity/foreign-key checks. Frozen historical schema helpers proved pre-pending reader use and an old-owned write, expected rejection by an intermediate pending-aware reader, and successful candidate reopen. This is historical schema-gate proof, not full historical CLI execution.

The first performance CI run exposed immutable-sort/shadowing lint violations and four tests coupled to the old recorder callback argument count. These are corrected while retaining message-content and invocation-count assertions. A subsequent merge-ref run exposed a stale hard-coded release list after main added a release. The test now derives translated release routes from canonical English navigation while still checking group names, index-first ordering, uniqueness and exact locale parity. This reuses the maintainer repair from #133565 (e755ce0a5992): the old fixture failed on the CI docs config, and the corrected full six-test suite passed against that same config. After main’s history-batch change, CI found two remaining 100-message literals in this PR’s new receipt-coalescing test. Both are updated to 400 without changing receipt assertions or runtime behavior. The failing full UI job otherwise passed 12,976 tests; the corresponding Node shard passed 4,512. A local attempt through the shared dependency tree exited before tests with a Vitest worker error; no shared dependencies were changed, and all 579 tests in the five affected UI files passed in the isolated native checkout on final e7f546c2f95. The upstream lifecycle/cloud Stop integration passed 138 tests across 9 files, including browser admission, exact cleanup ownership, pending cancellation, queue lifecycle and consumed-source retries. The two-literal correction passed fresh scoped Codex review (P0, confidence 0.99).

Final exact-head CI33340813771 passed on e7f546c2f95063410286f30f47ff0dd328c23c42: 193 jobs succeeded, 7 were skipped, and none failed or remained pending.

Live Proof and Limits

Earlier real OpenAI proof passed local session creation, normal composer follow-up, A/B collection into one C, reload reconciliation, SIGKILL retention and explicit resend through the normal composer. The inspected synthetic captures below show candidate states before and after consumption/recovery, not a pre-fix build.

Fresh real OpenAI proof on the CI-built performance candidate passed: A/B were durably accepted before consumption, browser reload showed both, collection assigned both the same committed event and wrote both marker files, and reload had no stale pending copies. After SIGKILL/restart, a third input remained Interrupted with no marker or automatic execution. Explicit resend through the normal composer wrote the exact marker and completed; reload kept the original Interrupted input. The build is GitHub merge 99209b345947 from CI33338160264, whose only failure was the stale docs fixture described above. Temporary provider credentials were removed. The final history integration refresh retains main’s 400-message startup/refresh and 1,000-message older-page limits together with bounded custody receipt IDs. Range-diff confirms only the two corresponding test expectation resolutions; the docs fixture repair is now identical upstream and drops from this PR. Fresh full-branch Codex review before that mechanical refresh was scoped-clean at P0 (confidence 0.96). On 75d88f67186 (before the final two test-literal corrections), the actual Doctor 17→19 migration, repeated no-op, exact transcript/label preservation, candidate cold reopen and integrity/FK checks all passed again. Frozen historical reader-helper/open-use/candidate-reopen proof passed with the documented intermediate-reader refusal. Final exact-head CI is recorded below. Root CHANGELOG entries are release-generated; this body carries the release-note context.

Cloud execution is not proved. Three earlier AWS attempts failed before worker enrollment/model execution, including temporary public-tunnel archive interruption. Leases were inspected as released; an additional cleanup attempt timed out and independent instance deletion was not proved. Follow-ups: improve bootstrap phase/error diagnostics, prove stable archive ingress, and repair Crabbox cleanup target selection. No blind retry, timeout increase or UI bypass is included here.

The test Gateway was still draining after 60 seconds and was force-terminated after completed proof. Source review confirms plain SIGTERM allows 315 seconds for active work, so this observation does not prove a hang or timeout. The logs did not identify the remaining process-work owner; improved drain diagnostics are a separate follow-up. Only task-owned processes were stopped.

A separate live cold retry of an already-consumed source was not completed because browser control timed out; deterministic no-replay tests cover it. The latest live fixture also exposed tool-call-shaped text in one model response and a sluggish Debug event view; these are recorded as separate provider-output/Debug-performance follow-ups, not attributed to this persistence change.

Synthetic Browser Evidence

Accepted A/B and completed combined turn

Accepted A and B

Combined turn completed

Restart retention and explicit recovery

Retained Interrupted input

Explicit resend completed

Normal composer recovery

@clawsweeper

clawsweeper Bot commented Aug 30, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation app: web-ui App: web-ui gateway Gateway runtime agents Agent runtime and tooling size: XL maintainer Maintainer-authored PR labels Aug 30, 2026
@steipete
steipete force-pushed the codex/browser-collect-custody branch from e99d32f to 26d3850 Compare August 30, 2026 19:39
@clawsweeper clawsweeper Bot added merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. P1 High-priority user-facing bug, regression, or broken workflow. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Aug 30, 2026
@steipete
steipete marked this pull request as ready for review August 30, 2026 19:47
@clawsweeper

clawsweeper Bot commented Aug 30, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 30, 2026, 7:15 PM ET / 23:15 UTC.

ClawSweeper review

What this changes

The branch durably records accepted browser chat follow-ups, promotes them only through the live turn owner, and shows their pending or interrupted state in Control UI after a restart.

Warning

SQLite table change

This PR modifies persisted SQLite tables in src/state/openclaw-agent-schema.sql. Prefer a design that avoids changing persisted SQLite tables. If the change is necessary, verify migration and upgrade compatibility against an existing database before merge.

Merge readiness

⚠️ Ready for maintainer review - 2 items remain

The PR remains necessary: #132887 explicitly left durable custody for ordinary browser chat sends as follow-up work. Source and boundary tests support the staged-input design; human release review is still needed for its documented same-version SQLite compatibility boundary.

Priority: P1
Reviewed head: e7f546c2f95063410286f30f47ff0dd328c23c42
Owner decision: Required. See Decision needed.

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) The patch has strong supplied real-flow evidence and focused owner-boundary coverage, with one maintainer release-compatibility decision remaining.
Proof confidence 🦞 diamond lobster (5/6) Not applicable: The external-contributor proof gate is not applicable to this maintainer PR; its supplied live browser and restart evidence is consistent with the reviewed owner path.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The external-contributor proof gate is not applicable to this maintainer PR; its supplied live browser and restart evidence is consistent with the reviewed owner path.
Evidence reviewed 6 items Verified introduced range: The checked-out PR head is the endpoint of the pinned introduction range; the review used that range rather than base-branch drift.
Admission and promotion owner: Browser input is staged before acknowledgement, then the execution path re-enters the pending-input recorder before dispatch.
Transactional custody checks: The pending-input owner revalidates live closure, lifecycle, physical session, exact source row, and consumption state before appending; consumption follows the successful transcript append in the transaction.
Findings None None.
Security None None.

How this fits together

Control UI submits a browser message to the Gateway, which stages it in the agent’s SQLite state before acknowledging it. The active turn later promotes that exact input into the transcript, while history responses let the UI reconcile pending and consumed copies.

flowchart LR
  A[Browser operator] --> B[Gateway chat send]
  B --> C[Durable pending input]
  C --> D[Live turn admission]
  D --> E[Canonical transcript]
  C --> F[History receipts]
  E --> F
  F --> G[Control UI reconciliation]
Loading

Decision needed

Question Recommendation
Is the documented Doctor-mediated beta-to-release compatibility boundary for the version 19 pending-input column acceptable for this release? Accept the bounded upgrade path: Treat the documented Doctor-mediated convergence path as the supported route for intermediate version 19 deployments.

Why: The implementation and tests support safe convergence, but support policy for operators running an intermediate pending-input-aware build is a release decision.

Before merge

  • Resolve merge risk (P1) - A pending-input-aware intermediate version 19 build may not accept the new nullable column until Doctor-mediated convergence; maintainers need to accept that supported beta-to-release boundary before merge.
Agent review details

Security

None.

PR surface

Source +637, Tests +1665, Docs +23, Generated +1, Other +8. Total +2334 across 46 files.

View PR surface stats
Area Files Added Removed Net
Source 28 846 209 +637
Tests 12 1800 135 +1665
Docs 4 34 11 +23
Config 0 0 0 0
Generated 1 1 0 +1
Other 1 9 1 +8
Total 46 2690 356 +2334

Review metrics

Metric Value Why it matters
Production versus test delta production +844/-209; tests/support +1802/-135; docs +34/-11; generated +10/-1 The substantial production growth implements durable input custody and its owner-boundary validation; tests exceed production changes and cover rollback, lifecycle, schema, and UI reconciliation.
Schema compatibility surface 1 nullable column added at schema version 19 The additive column is safe for converged stores but defines the intermediate-build upgrade decision before release.

Stored data model

Persistent data-model change detected: database schema: src/state/openclaw-agent-schema.sql, unknown-data-model-change: packages/gateway-protocol/src/schema/logs-chat.ts, unknown-data-model-change: src/state/openclaw-agent-pending-inputs-schema.ts. Confirm migration or upgrade compatibility proof before merge.

Root-cause cluster

Relationship: partial_overlap
Canonical: #132887
Summary: This extends the pending-input custody work from #132887 to the browser chat.send path that its merged scope intentionally left out.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Merge-risk options

Maintainer options:

  1. Accept the bounded upgrade path (recommended)
    Merge with the documented Doctor-mediated convergence route as the supported path for intermediate version 19 deployments.
  2. Pause for a broader compatibility design
    Do not merge until intermediate pending-input-aware builds can upgrade without the documented boundary if that support is required.

Technical review

Best possible solution:

Merge only with explicit acceptance of the documented Doctor-mediated upgrade path for intermediate version 19 deployments.

Do we have a high-confidence way to reproduce the issue?

Yes—source inspection provides a high-confidence path: an accepted browser follow-up is staged, the Gateway restarts before promotion, and history must retain it as interrupted rather than silently dropping or executing it.

Is this the best way to solve the issue?

Yes—the design repairs custody at the admission and transcript owners, rather than compensating in the UI; its session, lifecycle, and transactional checks are covered by focused boundary tests.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 6cf8e884edbd.

Labels

Label justifications:

  • P1: This addresses accepted browser follow-ups that could otherwise be lost across a Gateway restart in an active operator workflow.
  • merge-risk: 🚨 compatibility: The same-version nullable column has a documented intermediate-build compatibility boundary.
  • merge-risk: 🚨 session-state: The PR changes durable session input custody and recovery behavior across interruption and restart.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: The external-contributor proof gate is not applicable to this maintainer PR; its supplied live browser and restart evidence is consistent with the reviewed owner path.

Evidence

Acceptance criteria:

  • [P1] Verify the Doctor-mediated convergence path on the supported beta-to-release upgrade route.
  • [P1] Confirm the existing owner-boundary tests and supplied live restart proof remain attached to the final head.

What I checked:

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Confirm the supported Doctor-mediated upgrade boundary before merge.

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (11 earlier review cycles; latest 8 shown)
  • reviewed 2026-08-30T20:52:56.720Z sha 12016bbb1b62e2c44a148c041be123e8add480b5 :: needs maintainer review before merge. :: none
  • reviewed 2026-08-30T21:03:33.312Z sha 9a61891 :: needs maintainer review before merge. :: none
  • reviewed 2026-08-30T21:17:23.331Z sha 9a61891 :: needs maintainer review before merge. :: none
  • reviewed 2026-08-30T21:48:30.013Z sha d85396b :: needs maintainer review before merge. :: none
  • reviewed 2026-08-30T22:12:44.561Z sha 7f910d7 :: needs maintainer review before merge. :: none
  • reviewed 2026-08-30T22:42:33.694Z sha dc0ff6212bd5396e95c9a930c851e773151e42d6 :: needs maintainer review before merge. :: none
  • reviewed 2026-08-30T22:51:38.372Z sha 364da847a7e72e927874891628d7c1abe3bb05ba :: needs maintainer review before merge. :: none
  • reviewed 2026-08-30T23:02:03.666Z sha 75d88f6 :: needs maintainer review before merge. :: none

@clawsweeper clawsweeper Bot added rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. and removed rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. labels Aug 30, 2026
@steipete
steipete force-pushed the codex/browser-collect-custody branch 2 times, most recently from 12016bb to 9a61891 Compare August 30, 2026 20:54
@clawsweeper clawsweeper Bot added merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. merge-risk: 🚨 other 🚨 Merging this PR has meaningful risk outside the owned taxonomy. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. proof: 🎥 video Contributor real behavior proof includes video or recording evidence. proof: sufficient ClawSweeper judged the real behavior proof convincing. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. merge-risk: 🚨 other 🚨 Merging this PR has meaningful risk outside the owned taxonomy. proof: sufficient ClawSweeper judged the real behavior proof convincing. labels Aug 30, 2026
@clawsweeper clawsweeper Bot added the proof: sufficient ClawSweeper judged the real behavior proof convincing. label Aug 30, 2026
@steipete
steipete force-pushed the codex/browser-collect-custody branch from 364da84 to 75d88f6 Compare August 30, 2026 22:53
@clawsweeper clawsweeper Bot added rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. and removed rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. labels Aug 30, 2026
@clawsweeper clawsweeper Bot added rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. and removed proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. labels Aug 30, 2026
@steipete
steipete merged commit 5f0aa4f into main Aug 30, 2026
265 checks passed
@steipete
steipete deleted the codex/browser-collect-custody branch August 30, 2026 23:44
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

@steipete

Copy link
Copy Markdown
Contributor Author

Live cloud follow-up passed with a real OpenAI API key, openai/gpt-5.4-mini, real Chrome, and AWS workers. The Gateway ran the complete final-PR CI runtime from 65023f439a807546e0c96316bb9371b948cf373a (CI merge containing the reviewed PR head); no runtime source overlay or mocked provider was used.

The normal New Session → Cloud flow created a managed worktree and executed the marker task remotely. Two inputs submitted while busy survived browser reload, were consumed by one combined transcript event, and left no stale pending copies. The Gateway worktree contained the exact original marker and A/B file bytes. The cloud agent then used sessions_spawn to create a visible child on another worker; its marker file also reconciled exactly to its own Gateway worktree.

Both placements auto-suspended and their old leases were confirmed released. A normal next message provisioned a fresh worker with warm images disabled. That worker verified the original three files and produced a new resume marker. Final read-only checks verified all five files, a distinct replacement lease, the original shared consumption event, and no duplicate combined transcript event.

Bootstrap diagnostics discovered during the wider investigation landed separately in #133663: production −5 lines, real interrupted-download proof on AWS, 254 passing owner tests, and green exact-head CI. An initial malformed test-profile shell command was corrected before the successful cloud runs. Its teardown timeout remained durably owned and later reconciled to a confirmed release; no timeout increase or unsafe cleanup shortcut was added.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 31, 2026
)

* fix: retain accepted browser follow-ups across restarts

* refactor: share pending-input reconciliation bookkeeping

* test: align durable input fixtures and shared worker teardown

Keep chat fixtures aligned with queue ownership and receipt-aware history requests. Reuse the shared-worker admission cleanup already landed in openclaw#133466 from commit 08c49b7.

* test: synchronize chat races with committed admission

* docs: defer queued-input release note to release generation

* perf: simplify accepted-input reconciliation and batch reads

* test: assert recorder message semantics after simplification

* test: align custody receipt queries with history batch size
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling app: web-ui App: web-ui docs Improvements or additions to documentation gateway Gateway runtime maintainer Maintainer-authored PR merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. P1 High-priority user-facing bug, regression, or broken workflow. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: XL status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant