Repository navigation
fix: keep a chat's client capabilities when queued messages resume after a restart - #204787
Conversation
…r a restart Restart replay dispatches queued WebChat input through a synthetic Gateway client. Its caller context declared an empty client capability list, which rewrote the session's recorded capability catalog. Synthetic callers now declare no current capabilities, and session metadata keeps the recorded catalog when no client declaration is present.
…ter a restart OpenClaw-Publication: 846525ef-51c7-800c-a53a-e1919c5a49e2
|
🦞👀 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 preserves a chat’s recorded client capabilities when queued messages replay after a Gateway restart. Example: A Control UI chat records approvals support, queues a follow-up, and restarts.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review Keep this PR open: it fixes a current-main violation of the session capability contract, and the reviewed diff has no actionable code findings. Priority: P2 Before mergeNone. FindingsNone. Tests
Agent review detailsHow this fits togetherGateway caller context feeds session metadata and agent execution; recorded capabilities determine tool listing while current-client capabilities continue to gate execution. flowchart TD
A[Live chat client] --> C[Gateway caller context]
B[Queued restart replay] --> C
C --> D[Session metadata owner]
D --> E[Recorded capability catalog]
E --> F[Agent tool listing]
C --> G[Current client execution gate]
Technical reviewBest possible solution: Keep the existing metadata owner, preserve absent synthetic declarations, and retain current-client execution gates as this patch does. Do we have a high-confidence way to reproduce the issue? Source inspection establishes the synthetic replay-to-metadata overwrite path, and the PR reports a matching base-failing regression; no target code was executed during this read-only review. Is this the best way to solve the issue? The patch restores the documented distinction between a missing declaration and an empty declaration using existing owners, without adding state, configuration, or a parallel recovery path. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 986ad151d123. Provenance checked
TestingProof path: in-process harness. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +4, Tests +153. Total +157 across 9 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 HistoryReview history (1 earlier review cycle)
Reviewed November 24, 2026, 1:27 PM ET / 18:27 UTC (Revision 2). |
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
Merged via explicitly authorized admin squash with attributed pre-existing CI failures.
|
…ter a restart (#204787) * fix: keep a chat's client capabilities when queued input replays after a restart Restart replay dispatches queued WebChat input through a synthetic Gateway client. Its caller context declared an empty client capability list, which rewrote the session's recorded capability catalog. Synthetic callers now declare no current capabilities, and session metadata keeps the recorded catalog when no client declaration is present. * fix: keep a chat's client capabilities when queued messages resume after a restart OpenClaw-Publication: 846525ef-51c7-800c-a53a-e1919c5a49e2 * test: replay stored sessions with and without a recorded capability catalog (cherry picked from commit 511df66) Co-authored-by: RomneyDa <[email protected]>
…ter a restart (openclaw#204787) * fix: keep a chat's client capabilities when queued input replays after a restart Restart replay dispatches queued WebChat input through a synthetic Gateway client. Its caller context declared an empty client capability list, which rewrote the session's recorded capability catalog. Synthetic callers now declare no current capabilities, and session metadata keeps the recorded catalog when no client declaration is present. * fix: keep a chat's client capabilities when queued messages resume after a restart OpenClaw-Publication: 846525ef-51c7-800c-a53a-e1919c5a49e2 * test: replay stored sessions with and without a recorded capability catalog
…ter a restart (#204787) * fix: keep a chat's client capabilities when queued input replays after a restart Restart replay dispatches queued WebChat input through a synthetic Gateway client. Its caller context declared an empty client capability list, which rewrote the session's recorded capability catalog. Synthetic callers now declare no current capabilities, and session metadata keeps the recorded catalog when no client declaration is present. * fix: keep a chat's client capabilities when queued messages resume after a restart OpenClaw-Publication: 846525ef-51c7-800c-a53a-e1919c5a49e2 * test: replay stored sessions with and without a recorded capability catalog (cherry picked from commit 511df66) Release adaptation: Register only the landed restart test and use the stable exact empty-capability contract. Companions: No later #204787 references; unrelated Gateway fixture and chat policy changes are independent. Co-authored-by: RomneyDa <[email protected]>
What Problem This Solves
When the Gateway restarts while someone's chat turn is running, and a follow-up message is queued behind it, OpenClaw resumes the running turn and then replays the queued message. That replay erased the chat's record of what the person's client supports, for example Control UI approvals. After a restart, the session could lose tools that need those client features. Work on the session that had already read the earlier record could also see the session as changed and fail.
User Impact
User impact: after a Gateway restart, a chat keeps the client features it had, and both the interrupted turn and the queued message continue as before.
Why This Change Was Made
Restart replay sends the queued message through an internal Gateway caller. That caller declared an empty list of client features, and the session treated it like a real client and saved the empty list. Internal callers now declare no client features, so the session keeps the list from the last real client. Live clients still update it, including a live client that declares no features. Running a tool that needs a client feature still requires a connected client with that feature, so nothing gains new authority.
Details
resolveChatSendCallerContextdeclaresGatewayClientCapsasundefinedfor synthetic callers, where it used to declare[].prepareSessionMetaPatchskips theclientCapabilitiespatch when the turn comes in through the Gateway chat provider and no client capabilities are declared. Channel inbound turns are unchanged.agentRPC path now handle the optional value. Downstream execution already treatedundefinedand[]the same way.restart()now runs the same in-process restart reset as the Gateway run loop (prepareGatewayRestartIteration), which starts a new lifecycle generation. Without that reset, queued input is never treated as left over from the previous process.Evidence
The change was checked as follows:
src/gateway/session-restart-resume.queued-input.product.test.ts). A real Gateway with a scripted model provider and a Control UI client that declaresapprovals. The owner's first turn is running, a follow-up is queued behind it, and the Gateway restarts in-process. The test checks that the interrupted turn resumes, the queued message runs and lands in the chat history, and the recorded client capabilities match what they were before the restart.mainit fails:expected [ 'webchat-prompt-reactions' ] to deeply equal [ 'approvals', 'webchat-prompt-reactions' ].mainthe resumed turn and the queued message both still completed in this run. The lost capability record is what failed.gateway-client-identity.test.ts). It checks that only a live client updates the recorded capabilities and a synthetic caller leaves them unchanged. It fails onmainand passes with the fix.SessionEntry, the SQLite entry JSON and its canonical projection (store-entry-shape.ts) are untouched, andclientCapabilitieskeeps its type. A focused test (gateway-client-identity.test.ts, "replays stored sessions written before this change") loads entry JSON in the shape earlier releases persisted through the real SQLite row parser (parseCanonicalSqliteSessionEntry), applies the restart-replay caller's metadata patch, and resolves the tool-listing capabilities the replayed turn uses:approvals,webchat-prompt-reactions) loads unchanged, replay keeps it, and tool listing uses it.main, replay instead writes['webchat-prompt-reactions']into both sessions.src/cronrun: stopped at its 60-minute local limit on a busy machine. 1,318 tests across 35 files had run by then, and none failed.chat.sendpaths and passed in a separate run (4 files, 43 tests).01c1a943, merged withmainat986ad151). All three failed jobs also fail without this PR:checks-node-changed-4:src/agents/bash-tools.exec-gateway-approval.e2e.test.ts› "withholds the active hook token source from exec children at startup and across reload" (expected [] to deeply equal [ 'OPENCLAW_E2E_HOOK_SOURCE_OLD' ]). It fails the same way on the PR's base04d96995under Bun, and with the identical assertion in the changed-test shards of unrelated PRs (runs 45407381496, 45415821154, 45447385916).checks-node-changed-7:test/e2e/qa-lab/runtime/gateway-plugin-turn-handover.e2e.test.ts, 4 of 5 cases (JSON Parse error: Unable to parse JSON string, unhandledgateway client stopped). It fails identically, 4 failed and 1 passed, under Bun on the PR's base04d96995and on this head.checks-node-compact-small-8:test/scripts/ci-node-test-plan.test.ts› "prices serial Gateway server measurements at two workers and preserves parallel samples (github)" (expected length 4, got 5). It fails identically onmainat986ad151without this PR and passes on this head over04d96995.src/gateway/test-helpers.e2e.ts. That change only forwards an optionalcaps, which isundefinedfor these tests, andconnectGatewayClientalready forwarded it that way.openclaw/ci-gateis red only because of these three jobs.security-fastand every other job passed.pnpm tsgo:coreandpnpm tsgo:test:srcpass. oxlint and the formatter are clean on the changed files.🦞 Made with OpenClaw