Skip to content

fix: reconcile accepted session controls after reconnect - #519

Merged
steipete merged 1 commit into
openclaw:mainfrom
programmerlapar:fix/replay-config-options-after-resume
Aug 28, 2026
Merged

steipete merged 1 commit into
openclaw:mainfrom
programmerlapar:fix/replay-config-options-after-resume

Conversation

@programmerlapar

@programmerlapar programmerlapar commented Aug 24, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Switching models can change or remove reasoning-effort controls. ACPX saved the requested value instead of the adapter's accepted value, so a successful switch could leave a stale preference behind. A new ACP client also skipped saved model/config replay after session/load or session/resume, even when the adapter resumed the same conversation with different defaults.

This consolidates the reconnect repair from @programmerlapar with the accepted-selection repair, preserving contributor credit. Real Codex and Claude sessions reproduced the stale-selection behavior before the fix.

Why This Change Was Made

Session selection state now has one reconciliation path for explicit controls and replay: accept the complete config response, update only existing non-mode selections, and remove selections whose controls disappeared. Unselected backend defaults remain unpinned. Embedded AcpxRuntime.setConfigOption returns the complete accepted response after saving it; third-party implementations of the public runtime interface may still return void.

The reconnect owner restores the saved model before surviving config preferences on genuine new/load/resume connections. It reconciles stale values written by earlier versions against the model acknowledgement, including when the resumed model is already current. Warm reusable sessions do not replay. Explicit replacement controls can replace an obsolete saved selection without first replaying it.

The session owner also keeps notifications and acknowledgements in execution order and never pools a client whose preference replay failed. Initial, idle, active-turn, and reconnect paths share the repaired state ownership. Duplicate prompt-model replay, setter bookkeeping, and idle state mirrors were removed. Legacy session/set_mode replay policy is unchanged.

User Impact

Model switches preserve the conversation while accepted effort adjustments/removals survive reconnects. A failed replay stops visibly; a retry must reconnect and reapply preferences before prompting. No new operator configuration, environment variable, dependency, or storage schema is introduced.

Evidence

Verified source commit: af319d35bb8730b472c4525edc6d3a6c8a3fb39e. Its patch is byte-identical to the reviewed and tested candidate. Production: +368/-421 (net -53); tests: +877/-239 (net +638). Documentation and changelog are separate.

  • pnpm run check && pnpm run check:docs passed on clean Linux/AWS after a frozen dependency install: 965 tests, then 140 coverage tests. The configured coverage target passed at 95.06% lines/statements, 88.81% branches, and 96.63% functions; this is not whole-repository coverage. Crabbox run, lease cbx_f049840dc24d, verified released.
  • Local lint, typecheck, production/test builds, formatting, docs, and 139 focused tests passed. The earlier CLI model integration subset also passed all 14 cases and is covered by the final full suite.
  • Independent Codex autoreview completed with no findings on the frozen final patch. Review was static; execution proof is reported separately here.
  • Regression tests failed before their repairs: stale accepted effort, genuine load/resume replay, explicit replacement, retry after failed replay, earlier notifications overwriting later acknowledgements, initial-save ordering, and later controls invalidated by an earlier replay acknowledgement.

Real Codex ACP 1.6.0 and Claude ACP 0.60.0 ran against the built candidate (runtime.js SHA-256 e9c701679be30172cd623325d976e741deb068f08f4bd43762f963fde334146b). Independent, source-blind probes exercised model switching, complete accepted responses, saved state, untouched defaults, invalid values, and genuine reconnects. Six no-tool prompts completed; 52 control responses matched the complete real adapter response. Codex Sol → Luna adjusted selected ultra to accepted/saved medium; Claude Sonnet → Haiku removed effort and its saved preference. Fresh processes resumed the same backend identities and restored selected settings before prompting; marker recall confirmed conversation continuity. Higher efforts were selected only for control probes, never used for inference. Isolated state, native processes, and the credential task window were removed.

Earlier clean-machine attempts were blocked before tests by an undersized image disk and unsupported local Actions hydration. The final run used the same configured AWS provider with a supported disk size and an explicit frozen install. No assertions, deadlines, or test-cache settings were weakened. The existing ineffective dynamic import warning in output/render.ts remains unchanged.

Dependency inspection includes the real Codex and Claude ACP adapter control handlers and Codex rust-v0.149.1 codex-rs/app-server/src/request_processors/turn_processor.rs:776 (omitted effort is not an explicit clear).

Review Follow-through

The prior ClawSweeper review requested maintainer review and real resume proof; both are supplied above. This maintainer rewrite broadens the repair only within session selection/reconnect ownership. Diagnostics now say “ACP session” on both fresh and resumed paths; replay logs do not print arbitrary config values. Fresh ClawSweeper review is requested for the rewritten head, and exact-head CI remains a landing gate.

@programmerlapar
programmerlapar requested a review from a team as a code owner August 24, 2026 14:39
@clawsweeper

clawsweeper Bot commented Aug 24, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

@clawsweeper clawsweeper Bot added P2 Normal priority bug or improvement with limited blast radius. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Aug 24, 2026
@clawsweeper

clawsweeper Bot commented Aug 24, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 28, 2026, 2:31 PM ET / 18:31 UTC.

ClawSweeper review

What this changes

The PR restores accepted ACP model and configuration selections after reconnects and returns complete accepted control responses to embedded runtime callers.

Regression provenance

Possible regression — probable (reviewed change; reproduction). No predecessor PR is attributed.

Merge readiness

⚠️ Ready for maintainer review - 1 item remains

Keep open. This remains a necessary, focused repair: the current base lacks reconnect replay and accepted-selection reconciliation, while the rewritten head has targeted source changes, broad regression coverage, real-adapter evidence, and active maintainer involvement.

Priority: P2
Reviewed head: af319d35bb8730b472c4525edc6d3a6c8a3fb39e

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) Strong real-adapter evidence and focused regression coverage support a mergeable repair; exact-head required checks remain the normal landing gate.
Proof confidence 🦞 diamond lobster (5/6) ✨ media proof bonus Sufficient (linked_artifact): The supplied exact-head Crabbox evidence reports built-candidate Codex and Claude sessions exercising model switches, complete accepted responses, fresh-process reconnect before prompts, and preserved conversation continuity; those scenarios map to the changed reconnect owner and selection-reconciliation functions.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (linked_artifact): The supplied exact-head Crabbox evidence reports built-candidate Codex and Claude sessions exercising model switches, complete accepted responses, fresh-process reconnect before prompts, and preserved conversation continuity; those scenarios map to the changed reconnect owner and selection-reconciliation functions.
Evidence reviewed 6 items Base behavior missed reconnect reconciliation: The base replay path skipped a saved model when the resumed adapter already reported that model, so it could not use that acknowledgement to reconcile dependent saved controls; it also only replayed the preference bundle for fresh sessions.
Repaired reconnect owner: The PR replays a saved model on non-reused connections, applies its complete acknowledgement to persisted state, and replays surviving saved config controls before a prompt proceeds.
Acknowledgement reconciliation: The centralized selection helpers retain only existing explicitly saved non-mode selections and update them from the adapter's accepted values, avoiding pinning unrelated defaults.
Findings None None.
Security None None.

How this fits together

ACPX stores selected ACP controls with the conversation record. When a client reconnects, the session runtime resumes or loads the backend session, reapplies compatible saved choices, then runs the next prompt or serves an embedded caller.

flowchart LR
  A[Saved session record] --> B[Reconnect or resume]
  B --> C[ACP adapter controls]
  C --> D[Accepted control response]
  D --> E[Reconciled saved selections]
  E --> F[Prompt and runtime caller]
Loading

Before merge

  • Resolve merge risk (P1) - Several exact-head CI checks were still in progress in the supplied context; required checks should finish before landing.
Agent review details

Security

None.

Review metrics

Metric Value Why it matters
Patch surface 23 files, +1,259/-661 The repair spans reconnect ownership, CLI/runtime consumers, regression tests, and synchronized harness documentation.
Production versus tests production +368/-421; tests +877/-239 The broadened behavior has substantial focused regression coverage without net production growth.

Merge-risk options

Maintainer options:

  1. Decide the mitigation before merge
    Land the centralized reconnect and accepted-selection repair after the exact-head required checks complete.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Technical review

Best possible solution:

Land the centralized reconnect and accepted-selection repair after the exact-head required checks complete.

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

Yes. The supplied exact-head Codex and Claude adapter probes cover model switching, accepted sibling controls, fresh-process reconnection, and conversation continuity; source and regression tests map directly to those paths.

Is this the best way to solve the issue?

Yes. Centralizing accepted-response reconciliation and reconnect replay in the session owner avoids parallel state bookkeeping while preserving warm-session reuse.

AGENTS.md: found and applied where relevant.

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

Labels

Label justifications:

  • P2: The repair affects persisted session-control behavior across reconnects with bounded session-state impact.
  • 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. Sufficient (linked_artifact): The supplied exact-head Crabbox evidence reports built-candidate Codex and Claude sessions exercising model switches, complete accepted responses, fresh-process reconnect before prompts, and preserved conversation continuity; those scenarios map to the changed reconnect owner and selection-reconciliation functions.
  • proof: sufficient: Contributor real behavior proof is sufficient. The supplied exact-head Crabbox evidence reports built-candidate Codex and Claude sessions exercising model switches, complete accepted responses, fresh-process reconnect before prompts, and preserved conversation continuity; those scenarios map to the changed reconnect owner and selection-reconciliation functions.

Evidence

What I checked:

  • Base behavior missed reconnect reconciliation: The base replay path skipped a saved model when the resumed adapter already reported that model, so it could not use that acknowledgement to reconcile dependent saved controls; it also only replayed the preference bundle for fresh sessions. (src/runtime/engine/reconnect.ts:183, e13174878468)
  • Repaired reconnect owner: The PR replays a saved model on non-reused connections, applies its complete acknowledgement to persisted state, and replays surviving saved config controls before a prompt proceeds. (src/runtime/engine/reconnect.ts:173, af319d35bb87)
  • Acknowledgement reconciliation: The centralized selection helpers retain only existing explicitly saved non-mode selections and update them from the adapter's accepted values, avoiding pinning unrelated defaults. (src/session/config-options.ts:32, af319d35bb87)
  • Regression coverage: The parameterized reconnect tests cover fresh/load/resume paths, changed or omitted model metadata, replaced controls, stale values, and sibling controls removed or adjusted by earlier acknowledgements. (test/connect-load.test.ts:1086, af319d35bb87)
  • Exact-head real behavior evidence: The supplied PR body identifies this exact head and links a released Crabbox run reporting real Codex and Claude adapter control/reconnect probes, accepted effort adjustment/removal, preserved backend identity, and continued prompt history. (af319d35bb87)
  • Current feature provenance: The exact head is a single reconciliation commit by Peter Steinberger; local history also identifies earlier model-control and reconnect work in the same area. No release tag contains this unmerged head. (src/runtime/engine/reconnect.ts:386, af319d35bb87)

Likely related people:

  • Peter Steinberger: Authored the exact PR head and multiple recent merged runtime/session-control changes in local history. (role: recent session-control contributor; confidence: high; commits: af319d35bb87, 884395449f1a, 026544cd7550; files: src/runtime/engine/reconnect.ts, src/runtime/engine/manager.ts, src/session/config-options.ts)
  • Alex Knight: Local history attributes the prior ACP reconnect implementation to this contributor. (role: earlier reconnect contributor; confidence: medium; commits: f09933a837de; files: src/runtime/engine/reconnect.ts)

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 (2 earlier review cycles)
  • reviewed 2026-08-24T14:43:09.576Z sha 34ddb8d :: needs real behavior proof before merge. :: [P3] Label resumed-session replay accurately
  • reviewed 2026-08-24T15:09:57.399Z sha cc3543f :: needs maintainer review before merge. :: none

@programmerlapar

Copy link
Copy Markdown
Contributor Author

Added real OpenCode ACP resume evidence and corrected resumed-session diagnostics. @clawsweeper re-review

@clawsweeper clawsweeper Bot added proof: sufficient Contributor real behavior proof is sufficient. 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. and removed status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. labels Aug 24, 2026
@steipete steipete self-assigned this Aug 28, 2026
@steipete

Copy link
Copy Markdown
Contributor

Thanks @programmerlapar — I’m consolidating the reconnect repair here with the connected model/effort selection-state fix.

Real Codex and Claude testing reproduced stale saved effort after a model switch. Codex also resumed the same conversation with a different model and effort, so restoring ordinary config alone is not sufficient for that adapter. The repair will restore an advertised saved model before config replay, preserve warm-session reuse, and persist the adapter’s accepted selections without pinning unrelated defaults.

I’m validating an independently implemented rewrite against current main, with regression tests and real adapter sessions, before updating this branch. Your original resume-replay contribution and credit will be preserved.

Restore saved model and valid config selections on genuine reconnects,
reconcile complete acknowledgements, and preserve notification ordering
through initialization, idle controls, and active turns. Do not reuse a
client after failed preference restoration.

Consolidates the resume repair with accepted model/effort persistence and
returns the accepted snapshot to embedded consumers.

Co-authored-by: Firmansyah Otoluwa <[email protected]>
@steipete
steipete force-pushed the fix/replay-config-options-after-resume branch from cc3543f to af319d3 Compare August 28, 2026 18:28
@steipete steipete changed the title fix: replay config options after session resume fix: reconcile accepted session controls after reconnect Aug 28, 2026
@steipete

Copy link
Copy Markdown
Contributor

The credited maintainer rewrite is pushed as af319d3; the PR body now records the root cause, consolidation, and exact-candidate proof.

Clean AWS validation passed 965 tests plus the separate 140-test coverage run and docs checks. Final source-blind Codex/Claude validation passed all five behavior clauses: 52 complete adapter-matching control responses, six no-tool prompts, accepted effort adjustment/removal, real reconnect before prompting, unchanged session identity/history, unpinned defaults, and visible invalid-value rejection. Independent Codex autoreview is clean. All owned proof processes, isolated state, and leases are cleaned up.

Thanks @programmerlapar for the original resume repair; your contribution is credited in the commit and changelog. The earlier diagnostics concern is addressed without logging arbitrary config values. Exact-head CI is the remaining landing gate.

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Aug 28, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

@steipete
steipete merged commit 10a4cac into openclaw:main Aug 28, 2026
15 checks passed
@steipete

Copy link
Copy Markdown
Contributor

Landed in 10a4cac from reviewed source af319d3. Exact-head CI is fully green, including mutation testing; this resolves the latest ClawSweeper review's remaining CI requirement. The clean-machine and live Codex/Claude proof is recorded above.

The repair consolidates accepted-selection ownership and reconnect replay, removes 53 net production lines, and preserves the original resume contribution. Thanks @programmerlapar!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

P2 Normal priority bug or improvement with limited blast radius. proof: sufficient Contributor real behavior proof is sufficient. 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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants