Repository navigation
fix(acp): start a fresh session after /acp close - #168522
synthalorian wants to merge 4 commits into
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. |
|
Proof for head
Also passed on this head's patch (rebased onto current main without touching these files):
|
|
Codex review: needs real behavior proof before merge. What this changesManual ACP close requests persistent-state discard, durably prepares persisted sessions for fresh creation, and surfaces preparation failures before clearing metadata. Example: Close agent:main:acp:closed, restart OpenClaw, then initialize that session again.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness⛔ Blocked before merge - 2 items remain Keep open: this PR addresses a current ACP session-reuse bug, and neither earlier repair merged; no introduced correctness defect was identified. Priority: P2 Before merge
FindingsNone. Tests
Agent review detailsHow this fits togetherACP chat commands enter the session manager, which coordinates OpenClaw metadata and the ACPX plugin; ACPX delegates backend close and persistent-record updates to acpx. flowchart TD
A[ACP close command] --> B[Session manager]
B --> C[ACPX plugin]
C --> D[acpx runtime]
D --> E[Persistent session record]
B --> F[OpenClaw session metadata]
E --> G[Later session initialization]
Technical reviewBest possible solution: Keep manual discard and durable preparation in the existing manager and ACPX lifecycle owners. Do we have a high-confidence way to reproduce the issue? Current-main command arguments and the verified acpx release/reuse contract establish stale backend identity reuse during later initialization; no target code was executed in this review. Is this the best way to solve the issue? Using existing discard and prepare-fresh operations fixes the owning lifecycle boundary without deleting unrelated records or introducing another persistence policy. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 4aaefe346732. Provenance checked
TestingProof path: shipped entry point. SecurityNone. EvidenceWhat I checked:
PR surfaceSource +67, Tests +565. Total +632 across 9 files. Added test files: 3. View PR surface stats
Review metrics
Root-cause clusterRelationship: Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. LabelsLabel changes: No label 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 HistoryReview history (5 earlier review cycles)
Reviewed November 2, 2026, 10:38 AM ET / 15:38 UTC (Revision 6). |
Manual close released the acpx record, so the stored session id stayed reusable and the next turn resumed it. Request discard, and persist acpx's reset marker when recovery only has a persisted record. Leave unrelated sessions in place. Surface an invoked fresh-session preparation failure before metadata is cleared; missing-backend cleanup stays best-effort.
a30fade to
fd21d6e
Compare
|
Live proof for head The harness uses the real Command: Result:
{
"beforePrompts": {
"closed": {
"backendSessionId": "d5f9fa02-fafb-47cc-92c0-5276e4523da2",
"acpxRecordId": "agent:main:acp:closed",
"history": [
"before"
]
},
"kept": {
"backendSessionId": "c772d0b2-c2c5-4d87-ae73-62c901e8ec05",
"acpxRecordId": "agent:main:acp:kept",
"history": [
"kept-before"
]
}
},
"fixtureBeforeClose": [
{
"file": "c772d0b2-c2c5-4d87-ae73-62c901e8ec05.json",
"history": [
"kept-before"
]
},
{
"file": "d5f9fa02-fafb-47cc-92c0-5276e4523da2.json",
"history": [
"before"
]
}
],
"afterLegacyPlant": [
{
"file": "agent%3Amain%3Aacp%3Aclosed.json",
"bytes": 2496,
"sha256": "b3b64e724829496effea2be68e759f50ca81e837dfe9df85a416350e4dfa6b99",
"schema": "acpx.session.v1",
"acpx_record_id": "agent:main:acp:closed",
"acp_session_id": "d5f9fa02-fafb-47cc-92c0-5276e4523da2",
"name": "agent:main:acp:closed",
"closed": false,
"reset_on_next_ensure": null,
"acpx_keys": [
"config_options"
]
},
{
"file": "agent%3Amain%3Aacp%3Akept.json",
"bytes": 2505,
"sha256": "5ab473254c2d9c893f88c03a9a8569bb4bde6f9b50f7a2a91c24f79215a72f09",
"schema": "acpx.session.v1",
"acpx_record_id": "agent:main:acp:kept",
"acp_session_id": "c772d0b2-c2c5-4d87-ae73-62c901e8ec05",
"name": "agent:main:acp:kept",
"closed": false,
"reset_on_next_ensure": null,
"acpx_keys": [
"config_options"
]
},
{
"file": "agent%3Amain%3Aacp%3Alegacy.json",
"bytes": 1790,
"sha256": "b038ba695e7030916af8b9ebfb0b64dbed95dfb36a2cdd06ee37539e988b6821",
"schema": "acpx.session.v1",
"acpx_record_id": "agent:main:acp:legacy",
"acp_session_id": "c772d0b2-c2c5-4d87-ae73-62c901e8ec05",
"name": "agent:main:acp:legacy",
"closed": false,
"reset_on_next_ensure": null,
"acpx_keys": []
}
],
"loadedWithoutRewrite": {
"legacyReset": null,
"keptReset": null,
"closedReset": null,
"legacySchema": "acpx.session.v1",
"storeAfterLoad": [
{
"file": "agent%3Amain%3Aacp%3Aclosed.json",
"bytes": 2496,
"sha256": "b3b64e724829496effea2be68e759f50ca81e837dfe9df85a416350e4dfa6b99",
"schema": "acpx.session.v1",
"acpx_record_id": "agent:main:acp:closed",
"acp_session_id": "d5f9fa02-fafb-47cc-92c0-5276e4523da2",
"name": "agent:main:acp:closed",
"closed": false,
"reset_on_next_ensure": null,
"acpx_keys": [
"config_options"
]
},
{
"file": "agent%3Amain%3Aacp%3Akept.json",
"bytes": 2505,
"sha256": "5ab473254c2d9c893f88c03a9a8569bb4bde6f9b50f7a2a91c24f79215a72f09",
"schema": "acpx.session.v1",
"acpx_record_id": "agent:main:acp:kept",
"acp_session_id": "c772d0b2-c2c5-4d87-ae73-62c901e8ec05",
"name": "agent:main:acp:kept",
"closed": false,
"reset_on_next_ensure": null,
"acpx_keys": [
"config_options"
]
},
{
"file": "agent%3Amain%3Aacp%3Alegacy.json",
"bytes": 1790,
"sha256": "b038ba695e7030916af8b9ebfb0b64dbed95dfb36a2cdd06ee37539e988b6821",
"schema": "acpx.session.v1",
"acpx_record_id": "agent:main:acp:legacy",
"acp_session_id": "c772d0b2-c2c5-4d87-ae73-62c901e8ec05",
"name": "agent:main:acp:legacy",
"closed": false,
"reset_on_next_ensure": null,
"acpx_keys": []
}
]
},
"afterMissingRecordPrepareFresh": [
{
"file": "agent%3Amain%3Aacp%3Aclosed.json",
"bytes": 2496,
"sha256": "b3b64e724829496effea2be68e759f50ca81e837dfe9df85a416350e4dfa6b99",
"schema": "acpx.session.v1",
"acpx_record_id": "agent:main:acp:closed",
"acp_session_id": "d5f9fa02-fafb-47cc-92c0-5276e4523da2",
"name": "agent:main:acp:closed",
"closed": false,
"reset_on_next_ensure": null,
"acpx_keys": [
"config_options"
]
},
{
"file": "agent%3Amain%3Aacp%3Akept.json",
"bytes": 2505,
"sha256": "5ab473254c2d9c893f88c03a9a8569bb4bde6f9b50f7a2a91c24f79215a72f09",
"schema": "acpx.session.v1",
"acpx_record_id": "agent:main:acp:kept",
"acp_session_id": "c772d0b2-c2c5-4d87-ae73-62c901e8ec05",
"name": "agent:main:acp:kept",
"closed": false,
"reset_on_next_ensure": null,
"acpx_keys": [
"config_options"
]
},
{
"file": "agent%3Amain%3Aacp%3Alegacy.json",
"bytes": 1790,
"sha256": "b038ba695e7030916af8b9ebfb0b64dbed95dfb36a2cdd06ee37539e988b6821",
"schema": "acpx.session.v1",
"acpx_record_id": "agent:main:acp:legacy",
"acp_session_id": "c772d0b2-c2c5-4d87-ae73-62c901e8ec05",
"name": "agent:main:acp:legacy",
"closed": false,
"reset_on_next_ensure": null,
"acpx_keys": []
}
],
"afterDiscardClose": [
{
"file": "agent%3Amain%3Aacp%3Aclosed.json",
"bytes": 2572,
"sha256": "2dc6d04a470a856945c4a360de8f6be0c3e73fff5c6b44f2bcbd2824ffc64ca6",
"schema": "acpx.session.v1",
"acpx_record_id": "agent:main:acp:closed",
"acp_session_id": "d5f9fa02-fafb-47cc-92c0-5276e4523da2",
"name": "agent:main:acp:closed",
"closed": true,
"reset_on_next_ensure": true,
"acpx_keys": [
"config_options",
"reset_on_next_ensure"
]
},
{
"file": "agent%3Amain%3Aacp%3Akept.json",
"bytes": 2505,
"sha256": "5ab473254c2d9c893f88c03a9a8569bb4bde6f9b50f7a2a91c24f79215a72f09",
"schema": "acpx.session.v1",
"acpx_record_id": "agent:main:acp:kept",
"acp_session_id": "c772d0b2-c2c5-4d87-ae73-62c901e8ec05",
"name": "agent:main:acp:kept",
"closed": false,
"reset_on_next_ensure": null,
"acpx_keys": [
"config_options"
]
},
{
"file": "agent%3Amain%3Aacp%3Alegacy.json",
"bytes": 1790,
"sha256": "b038ba695e7030916af8b9ebfb0b64dbed95dfb36a2cdd06ee37539e988b6821",
"schema": "acpx.session.v1",
"acpx_record_id": "agent:main:acp:legacy",
"acp_session_id": "c772d0b2-c2c5-4d87-ae73-62c901e8ec05",
"name": "agent:main:acp:legacy",
"closed": false,
"reset_on_next_ensure": null,
"acpx_keys": []
}
],
"fixtureAfterDiscardClose": [
{
"file": "c772d0b2-c2c5-4d87-ae73-62c901e8ec05.json",
"history": [
"kept-before"
]
}
],
"afterRestart": {
"closed": {
"previousBackendSessionId": "d5f9fa02-fafb-47cc-92c0-5276e4523da2",
"backendSessionId": "c34e5c3e-c78f-4aaf-8575-966979005452",
"sameBackendSession": false,
"history": [
"after"
]
},
"kept": {
"previousBackendSessionId": "c772d0b2-c2c5-4d87-ae73-62c901e8ec05",
"backendSessionId": "c772d0b2-c2c5-4d87-ae73-62c901e8ec05",
"sameBackendSession": true,
"history": [
"kept-before",
"kept-after"
]
},
"store": [
{
"file": "agent%3Amain%3Aacp%3Aclosed.json",
"bytes": 2493,
"sha256": "979498835eb43c85164018b525360d79b60cfd476c5f8f4ef84d48268a3b32df",
"schema": "acpx.session.v1",
"acpx_record_id": "agent:main:acp:closed",
"acp_session_id": "c34e5c3e-c78f-4aaf-8575-966979005452",
"name": "agent:main:acp:closed",
"closed": false,
"reset_on_next_ensure": null,
"acpx_keys": [
"config_options"
]
},
{
"file": "agent%3Amain%3Aacp%3Akept.json",
"bytes": 3021,
"sha256": "ec75a9afa056d26ac27ba2836cdf18871a9ee88f5b706f9c77d73b1ed98dd168",
"schema": "acpx.session.v1",
"acpx_record_id": "agent:main:acp:kept",
"acp_session_id": "c772d0b2-c2c5-4d87-ae73-62c901e8ec05",
"name": "agent:main:acp:kept",
"closed": false,
"reset_on_next_ensure": null,
"acpx_keys": [
"config_options"
]
},
{
"file": "agent%3Amain%3Aacp%3Alegacy.json",
"bytes": 1790,
"sha256": "b038ba695e7030916af8b9ebfb0b64dbed95dfb36a2cdd06ee37539e988b6821",
"schema": "acpx.session.v1",
"acpx_record_id": "agent:main:acp:legacy",
"acp_session_id": "c772d0b2-c2c5-4d87-ae73-62c901e8ec05",
"name": "agent:main:acp:legacy",
"closed": false,
"reset_on_next_ensure": null,
"acpx_keys": []
}
],
"fixture": [
{
"file": "c34e5c3e-c78f-4aaf-8575-966979005452.json",
"history": [
"after"
]
},
{
"file": "c772d0b2-c2c5-4d87-ae73-62c901e8ec05.json",
"history": [
"kept-before",
"kept-after"
]
}
]
}
}Reading that capture:
Committed tests on the same head: Missing-backend and missing-hook preparation still return. An invoked preparation failure is still raised. Owner-migration rejection is still rethrown. |
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
Drive handleAcpCommand through the session manager, then restart. The closed session starts a new backend conversation. An on-disk record without the reset marker still opens, and an untouched legacy record is not rewritten.
|
Live proof for head This run calls the shipped command Command: Stdout from the test (one JSON line), then the Vitest summary: What that stdout shows:
|
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
The close-restart proof imported extensions/acpx/src/runtime.js, which the core boundary rejects, and it called Array#sort(). Register the shipped acpx plugin instead and keep /acp close on handleAcpCommand.
|
Head
Quoted logs:
Fix: the proof no longer imports extension source. It loads the shipped acpx plugin through Local proof still passed: command reply CI for this head is still queued: https://github.com/openclaw/openclaw/actions/runs/38337132885 |
registerService can pass OpenClawPluginServiceV2. Keep the runtime guard on the v1 getRuntime service the shipped acpx plugin registers.
|
Shipped Gateway proof for head Isolated Gateway only. Temp state dir. Not the operator Gateway, not the live session store, not port 18789.
Command: The private user/mount namespace is only so the preparation-failure step can remount the temp acpx sessions directory read-only. The host mount table and the operator Gateway were not changed. 1. close/restartSpawned two persistent
After that command, the closed session's Stopped that Gateway and started the same The closed session did not resume 2. unsupported-close recoveryThe Recovery still closed it. That 3. preparation failure before metadata clearingSpawned another Before close, that row existed and the record was sha256 After that error the same |
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
What Problem This Solves
/acp closecleared the SQLiteacp_sessionsrow but left the acpx FileSessionStore record reusable. The next turn calledsession/resumewith the staleacp_session_idinstead ofsession/new.Why This Change Was Made
Manual close omitted
discardPersistentState. acpx treats that as release: it saves a closed record withoutreset_on_next_ensure, and its reuse policy accepts that record. The manager already forwards discard and already drops its handle cache. The missing piece was asking acpx to discard, and, when close recovery only has a persisted locator, running acpx's existing prepare-fresh path so that exact record gets the durable marker. In-memorymarkFreshdoes not survive restart. The write still goes through acpx and the existing physical-record fence. Unrelated session files are not touched. Owner-repair verdicts are unchanged. A missing backend stays best-effort; once fresh-session preparation actually runs, a failure is raised before metadata is cleared.User Impact
After
/acp close, the next message for that session starts a new ACP conversation, including after the runtime is recreated. Other sessions keep their stored identity and can still resume.Evidence
1608bcad00d6c84b2ff39fce8449bda1657a6e53.src/auto-reply/reply/commands-acp.close-restart.process.test.tscalls shippedhandleAcpCommandwith/acp close. That entersgetAcpSessionManager().closeSession. The command reply was✅ Closed ACP session agent:main:acp:closed. Removed 0 bindings.reset_on_next_ensure: true. Its fixture history file was removed. The unrelated session file was unchanged and had no marker.636ab8ae-ef3d-44a7-ab1b-848f675f24bewith history["after"].agent:main:acp:keptresumed833e8a49-1b90-4749-9b60-a6558cdb66f9with history["kept-before","kept-reopen","kept-after"].acpx.session.v1record with noacpxobject and no reset marker (agent:main:acp:kept, sha256803b9c922cd20ac5d12eec9ff661e7fcf1137e12538e77fc8c87a5a1daec8b4fbefore reopen) still opened through the manager and resumed that same backend session. Untouchedagent:main:acp:legacystayed sha2562ad1c8e260b2095ac320db0e09d009794cba3106ddf74ee898bcf2c7dfdb9998across reopen,/acp close, and restart.Fixes #107487