Repository navigation
fix(sessions): recover startup only for newly created sessions - #858
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. |
|
Codex review: needs maintainer review before merge. Reviewed October 7, 2026, 1:21 AM ET / 05:21 UTC (Revision 3). ClawSweeper reviewWhat this changesThe PR records how sessions were created and permits first-prompt or control recovery after an internal ACP load error only for confirmed new sessions without earlier conversation activity. Merge readiness✅ Ready for maintainer review This PR remains necessary: current main still rejects the reported startup failure. The narrowed recovery preserves existing-session continuity, and no blocking correctness or security defect was found. Priority: P2 Review scores
Verification
How this fits togetheracpx manages persistent agent sessions for CLI callers and embedded runtimes. Its reconnect layer loads the saved backend session, restores preferences, and either continues execution or reports a resume failure. flowchart TD
A[Prompt or control] --> B[Saved session record]
B --> C[Load original backend]
C --> D[Internal load failure]
D --> E[Check creation and history]
E --> F[Create backend and restore preferences]
E --> G[Report resume required]
Before mergeNone. Agent review detailsSecurityNone. Review metrics
Technical reviewBest possible solution: Retain the provenance-gated startup exception while preserving original backend identity for every session with existing or uncertain context. Do we have a high-confidence way to reproduce the issue? Yes: current-main source deterministically rejects an internal load error under same-session-only policy, and the captured real-adapter transcript demonstrates the first-turn symptom on stock acpx. No current-main execution was performed during this review. Is this the best way to solve the issue? Yes: the exception reuses existing session creation and preference replay while adding conservative provenance and history checks, rather than weakening continuity for existing sessions. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 9f40f24d4e64. LabelsLabel changes: No label changes. Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
History |
|
Live proof for the first-turn recovery, with the official The scenario is the same in both runs:
Native session IDs are read from the session record before and after the turn. Home paths are trimmed, and the saved config catalog is shortened to the selected values. acpx 0.19.1: the first turn fails, and the native session is kept but unusable. This branch: the first turn completes on a replacement session. The saved preferences reach the replacement session. Codex's own rollout for thread The same check with a codex-acp build that returns a per-turn configuration receipt ( Cancelled first prompt, then restart and an offline control ( Codex kept a rollout for the cancelled turn, so it resumed and the native ID did not change. The refusal path, where a session with a recorded prompt fails to load with @superbiche · contributor · drafted with Claude Opus 5.5, reviewed before posting; the voice and decisions are mine. |
Co-authored-by: Michel Tomas <[email protected]>
aa1509c to
f4b6dbc
Compare
|
Landed in b3cd843. Thanks @superbiche; Michel Tomas's co-author credit is preserved. The baseline first-turn failure was reproduced. Additional regressions reproduced unsafe replacement attempts for Resume-only history and for an explicitly resumed backend after actual creation, disk save, and reload with no replay. The final same-session-only recovery requires persisted session/new provenance; explicit resumes, unknown legacy origins, imports, prior prompts, agent output, and Resume markers keep the original backend. State updates preserve that provenance, and the existing allow-fresh policy is unchanged. Proof: 214 focused compiled tests; full Linux check with 3,042 passes (15 skips); 210 coverage passes; documentation plus agent/skill-guide checks; and clean independent review through P2. Exact-head CI passed on f4b6dbc: https://github.com/openclaw/acpx/actions/runs/37575516301. |
What Problem This Solves
A newly created persistent runtime session can fail its first prompt or control with
SESSION_RESUME_REQUIREDwhen the adapter returns an ACP internal load/resume error for that empty session.User Impact
A session confirmed to originate from
session/newcan recover from that specific-32603load error with a fresh backend and restored preferences. Explicit native resumes, legacy records without creation provenance, imported sessions, and prior conversation activity keep requiring the original backend under same-session-only policy. The existing allow-fresh policy is unchanged. Thanks @superbiche.Why This Change Was Made
Empty local history does not prove that a backend is new: an explicit native resume can return no replay while remote context still exists. CLI and runtime creation therefore persist a small
session_originvalue, parsing preserves known values, and state cloning retains it through model/mode acknowledgements. Recovery also excludes earlier prompts (including cancelled turns), agent output, and legacy Resume markers. Prompt callers distinguish their newly recorded current message from prior history. Missing-session and unsupported-load refusals and settings restoration remain intact.Evidence
Baseline tests reproduced the first-turn failure. Maintainer tests also reproduced replacement attempts for legacy Resume markers and for an explicit native resume after actual creation, disk save, reload, and later load failure. The final candidate refuses those replacements; older records with unknown origin retain their prior strict behavior.
All 214 focused compiled reconnect, runtime-manager, persistence, identity, offline-control, and shared-runtime tests pass. Independent Codex review through P2 is clean after the provenance and state-cloning repairs. Final
pnpm run check && pnpm run check:docspassed on isolated Linux with Node 24.19.0: 3,042 main-suite tests passed (15 skipped), all 210 coverage tests passed, and every coverage threshold was met. The synchronized agent and skill guides also passed their targeted formatter and Markdown checks.The contributor's earlier real-adapter proof with the official Codex ACP adapter demonstrated the original recovery path and restoration of saved model/effort, plus native-ID preservation after cancellation. Current-head synthetic tests additionally validate creation provenance and the stricter history guards; no new hosted-provider run is claimed for those bookkeeping changes.