fix(auto-reply): preserve sessions after compaction failures#70479
Conversation
Greptile SummaryThis PR fixes session orphaning after compaction failures in the auto-reply agent. Instead of silently rotating the session key to a new session ID when overflow recovery or compaction fails, both failure paths now preserve the active session mapping and surface an explicit user message with actionable guidance ( Confidence Score: 5/5This PR is safe to merge — it correctly removes a session-rotation footgun and replaces it with session-preserving, user-visible guidance, with targeted regression coverage for both failure paths. All changes are narrowly scoped to the compaction-failure paths. The dead resetSessionAfterCompactionFailure parameter raised in the previous review is fully removed. Both new code paths are covered by regression tests that assert the exact user-facing text and the fail() call. No P0/P1 issues identified. No files require special attention. Reviews (2): Last reviewed commit: "fix(auto-reply): drop dead compaction re..." | Re-trigger Greptile |
|
Addressed the dead Current red CI on the previous run does not point at this branch’s diff:
This branch only changes:
|
|
@greptileai review again puhlez |
3befdda to
3367448
Compare
|
Rebased onto latest |
|
Static review. LGTM-shape on removing the silent session rotation — surfacing "please /compact or /new" is the right UX. Three checks:
Non-blocking: user-facing string change is a behavior regression for anyone grepping transcripts for "reset our conversation to start fresh". Worth a release-note mention. |
|
ProjectClownfish pushed a narrow repair to this branch so the original contributor path can stay canonical. Source PR: #70479 |
|
Codex review: passed. Workflow note: Future ClawSweeper reviews update this same comment in place. How this review workflow works
Summary Reproducibility: yes. at source level with high confidence. Current main routes both embedded overflow payloads and thrown compaction failures into resetSessionAfterCompactionFailure, and the PR body includes before/after terminal proof of those branches. PR rating Rank-up moves:
What the crustacean ranks mean
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. Real behavior proof Mantis proof suggestion Risk before merge
Maintainer options:
Next step before merge Security Review detailsBest possible solution: Land the session-preserving recovery path if maintainers accept the supplied before/after runtime proof, with CI and exact-head automerge gates handling normal merge safety. Do we have a high-confidence way to reproduce the issue? Yes, at source level with high confidence. Current main routes both embedded overflow payloads and thrown compaction failures into resetSessionAfterCompactionFailure, and the PR body includes before/after terminal proof of those branches. Is this the best way to solve the issue? Yes. Preserving the active mapping and returning explicit retry Label changes:
Label justifications:
What I checked:
Likely related people:
Codex review notes: model gpt-5.5, reasoning high; reviewed against 55cfe00a3a40. |
|
ClawSweeper PR egg ✨ Hatched: 🥚 common Gilded Lint Imp Hatch commandComment Hatchability rules:
Rarity: 🥚 common. What is this egg doing here?
|
74a145f to
9152393
Compare
|
🦞✅ Source: What merged:
Automerge notes:
The automerge loop is complete. Automerge progress:
|
|
🦞✅ Source: Why human review is needed: What the maintainer can do as a next step: I added |
|
@clawsweeper re-review |
|
🦞🧹 Reason: re-review requires an open issue or PR. |
|
Updated the PR body with supplemental maintainer before/after proof for the requested session-state and delivery-path evidence. The added proof shows pre-fix @clawsweeper re-review |
|
This assigned pull request has been automatically marked as stale after being open for 27 days. |
…red production Restoration commit bbecf06 reverted PR openclaw#70479 (preserve-session-on-compaction) and re-introduced session-system-events as a {text, forceSenderIsOwnerFalse} block, but left three test/production sites stale. - get-reply-run.media-only.test.ts: mock drainFormattedSystemEventBlock (replaces the string-returning legacy helper that get-reply-run no longer imports) and return the new block shape from each mockResolvedValueOnce. - agent-runner-execution.test.ts: override resetSessionAfterCompactionFailure to true in the two compaction-failure tests so the restored recovery branch is actually taken, and update expected reply text to match the restored 'I've reset our conversation to start fresh' copy. - sessions/store-cache.ts: stamp storedAt on serialized-cache entries and drop them from getSerializedSessionStore once they outlive the session store TTL, restoring the parity-with-object-cache assertion added in the restoration commit.
…red production Restoration commit bbecf06 reverted PR openclaw#70479 (preserve-session-on-compaction) and re-introduced session-system-events as a {text, forceSenderIsOwnerFalse} block, but left three test/production sites stale. - get-reply-run.media-only.test.ts: mock drainFormattedSystemEventBlock (replaces the string-returning legacy helper that get-reply-run no longer imports) and return the new block shape from each mockResolvedValueOnce. - agent-runner-execution.test.ts: override resetSessionAfterCompactionFailure to true in the two compaction-failure tests so the restored recovery branch is actually taken, and update expected reply text to match the restored 'I've reset our conversation to start fresh' copy. - sessions/store-cache.ts: stamp storedAt on serialized-cache entries and drop them from getSerializedSessionStore once they outlive the session store TTL, restoring the parity-with-object-cache assertion added in the restoration commit.
…w#70479) Summary: - The PR removes the auto-reply compaction-failure session reset hook, adds preserved-session recovery guidance for overflow/compaction failure paths, and updates focused tests, docs, and the changelog. - Reproducibility: yes. at source level with high confidence. Current main routes both embedded overflow paylo ... resetSessionAfterCompactionFailure, and the PR body includes before/after terminal proof of those branches. Automerge notes: - PR branch already contained follow-up commit before automerge: fix(auto-reply): drop dead compaction reset hook - PR branch already contained follow-up commit before automerge: fix(auto-reply): preserve sessions after compaction failures Validation: - ClawSweeper review passed for head 193d3c0. - Required merge gates passed before the squash merge. Prepared head SHA: 193d3c0 Review: openclaw#70479 (comment) Co-authored-by: FullerStackDev <263060202+fuller-stack-dev@users.noreply.github.com> Co-authored-by: vincentkoc <25068+vincentkoc@users.noreply.github.com> Co-authored-by: clawsweeper[bot] <274271284+clawsweeper[bot]@users.noreply.github.com> Approved-by: takhoffman Co-authored-by: takhoffman <781889+takhoffman@users.noreply.github.com>
…w#70479) Summary: - The PR removes the auto-reply compaction-failure session reset hook, adds preserved-session recovery guidance for overflow/compaction failure paths, and updates focused tests, docs, and the changelog. - Reproducibility: yes. at source level with high confidence. Current main routes both embedded overflow paylo ... resetSessionAfterCompactionFailure, and the PR body includes before/after terminal proof of those branches. Automerge notes: - PR branch already contained follow-up commit before automerge: fix(auto-reply): drop dead compaction reset hook - PR branch already contained follow-up commit before automerge: fix(auto-reply): preserve sessions after compaction failures Validation: - ClawSweeper review passed for head 193d3c0. - Required merge gates passed before the squash merge. Prepared head SHA: 193d3c0 Review: openclaw#70479 (comment) Co-authored-by: FullerStackDev <263060202+fuller-stack-dev@users.noreply.github.com> Co-authored-by: vincentkoc <25068+vincentkoc@users.noreply.github.com> Co-authored-by: clawsweeper[bot] <274271284+clawsweeper[bot]@users.noreply.github.com> Approved-by: takhoffman Co-authored-by: takhoffman <781889+takhoffman@users.noreply.github.com>
…w#70479) Summary: - The PR removes the auto-reply compaction-failure session reset hook, adds preserved-session recovery guidance for overflow/compaction failure paths, and updates focused tests, docs, and the changelog. - Reproducibility: yes. at source level with high confidence. Current main routes both embedded overflow paylo ... resetSessionAfterCompactionFailure, and the PR body includes before/after terminal proof of those branches. Automerge notes: - PR branch already contained follow-up commit before automerge: fix(auto-reply): drop dead compaction reset hook - PR branch already contained follow-up commit before automerge: fix(auto-reply): preserve sessions after compaction failures Validation: - ClawSweeper review passed for head 193d3c0. - Required merge gates passed before the squash merge. Prepared head SHA: 193d3c0 Review: openclaw#70479 (comment) Co-authored-by: FullerStackDev <263060202+fuller-stack-dev@users.noreply.github.com> Co-authored-by: vincentkoc <25068+vincentkoc@users.noreply.github.com> Co-authored-by: clawsweeper[bot] <274271284+clawsweeper[bot]@users.noreply.github.com> Approved-by: takhoffman Co-authored-by: takhoffman <781889+takhoffman@users.noreply.github.com>
…w#70479) Summary: - The PR removes the auto-reply compaction-failure session reset hook, adds preserved-session recovery guidance for overflow/compaction failure paths, and updates focused tests, docs, and the changelog. - Reproducibility: yes. at source level with high confidence. Current main routes both embedded overflow paylo ... resetSessionAfterCompactionFailure, and the PR body includes before/after terminal proof of those branches. Automerge notes: - PR branch already contained follow-up commit before automerge: fix(auto-reply): drop dead compaction reset hook - PR branch already contained follow-up commit before automerge: fix(auto-reply): preserve sessions after compaction failures Validation: - ClawSweeper review passed for head 193d3c0. - Required merge gates passed before the squash merge. Prepared head SHA: 193d3c0 Review: openclaw#70479 (comment) Co-authored-by: FullerStackDev <263060202+fuller-stack-dev@users.noreply.github.com> Co-authored-by: vincentkoc <25068+vincentkoc@users.noreply.github.com> Co-authored-by: clawsweeper[bot] <274271284+clawsweeper[bot]@users.noreply.github.com> Approved-by: takhoffman Co-authored-by: takhoffman <781889+takhoffman@users.noreply.github.com>
…w#70479) Summary: - The PR removes the auto-reply compaction-failure session reset hook, adds preserved-session recovery guidance for overflow/compaction failure paths, and updates focused tests, docs, and the changelog. - Reproducibility: yes. at source level with high confidence. Current main routes both embedded overflow paylo ... resetSessionAfterCompactionFailure, and the PR body includes before/after terminal proof of those branches. Automerge notes: - PR branch already contained follow-up commit before automerge: fix(auto-reply): drop dead compaction reset hook - PR branch already contained follow-up commit before automerge: fix(auto-reply): preserve sessions after compaction failures Validation: - ClawSweeper review passed for head 193d3c0. - Required merge gates passed before the squash merge. Prepared head SHA: 193d3c0 Review: openclaw#70479 (comment) Co-authored-by: FullerStackDev <263060202+fuller-stack-dev@users.noreply.github.com> Co-authored-by: vincentkoc <25068+vincentkoc@users.noreply.github.com> Co-authored-by: clawsweeper[bot] <274271284+clawsweeper[bot]@users.noreply.github.com> Approved-by: takhoffman Co-authored-by: takhoffman <781889+takhoffman@users.noreply.github.com>
…w#70479) Summary: - The PR removes the auto-reply compaction-failure session reset hook, adds preserved-session recovery guidance for overflow/compaction failure paths, and updates focused tests, docs, and the changelog. - Reproducibility: yes. at source level with high confidence. Current main routes both embedded overflow paylo ... resetSessionAfterCompactionFailure, and the PR body includes before/after terminal proof of those branches. Automerge notes: - PR branch already contained follow-up commit before automerge: fix(auto-reply): drop dead compaction reset hook - PR branch already contained follow-up commit before automerge: fix(auto-reply): preserve sessions after compaction failures Validation: - ClawSweeper review passed for head 193d3c0. - Required merge gates passed before the squash merge. Prepared head SHA: 193d3c0 Review: openclaw#70479 (comment) Co-authored-by: FullerStackDev <263060202+fuller-stack-dev@users.noreply.github.com> Co-authored-by: vincentkoc <25068+vincentkoc@users.noreply.github.com> Co-authored-by: clawsweeper[bot] <274271284+clawsweeper[bot]@users.noreply.github.com> Approved-by: takhoffman Co-authored-by: takhoffman <781889+takhoffman@users.noreply.github.com>
…w#70479) Summary: - The PR removes the auto-reply compaction-failure session reset hook, adds preserved-session recovery guidance for overflow/compaction failure paths, and updates focused tests, docs, and the changelog. - Reproducibility: yes. at source level with high confidence. Current main routes both embedded overflow paylo ... resetSessionAfterCompactionFailure, and the PR body includes before/after terminal proof of those branches. Automerge notes: - PR branch already contained follow-up commit before automerge: fix(auto-reply): drop dead compaction reset hook - PR branch already contained follow-up commit before automerge: fix(auto-reply): preserve sessions after compaction failures Validation: - ClawSweeper review passed for head 193d3c0. - Required merge gates passed before the squash merge. Prepared head SHA: 193d3c0 Review: openclaw#70479 (comment) Co-authored-by: FullerStackDev <263060202+fuller-stack-dev@users.noreply.github.com> Co-authored-by: vincentkoc <25068+vincentkoc@users.noreply.github.com> Co-authored-by: clawsweeper[bot] <274271284+clawsweeper[bot]@users.noreply.github.com> Approved-by: takhoffman Co-authored-by: takhoffman <781889+takhoffman@users.noreply.github.com>
…w#70479) Summary: - The PR removes the auto-reply compaction-failure session reset hook, adds preserved-session recovery guidance for overflow/compaction failure paths, and updates focused tests, docs, and the changelog. - Reproducibility: yes. at source level with high confidence. Current main routes both embedded overflow paylo ... resetSessionAfterCompactionFailure, and the PR body includes before/after terminal proof of those branches. Automerge notes: - PR branch already contained follow-up commit before automerge: fix(auto-reply): drop dead compaction reset hook - PR branch already contained follow-up commit before automerge: fix(auto-reply): preserve sessions after compaction failures Validation: - ClawSweeper review passed for head 193d3c0. - Required merge gates passed before the squash merge. Prepared head SHA: 193d3c0 Review: openclaw#70479 (comment) Co-authored-by: FullerStackDev <263060202+fuller-stack-dev@users.noreply.github.com> Co-authored-by: vincentkoc <25068+vincentkoc@users.noreply.github.com> Co-authored-by: clawsweeper[bot] <274271284+clawsweeper[bot]@users.noreply.github.com> Approved-by: takhoffman Co-authored-by: takhoffman <781889+takhoffman@users.noreply.github.com>
…w#70479) Summary: - The PR removes the auto-reply compaction-failure session reset hook, adds preserved-session recovery guidance for overflow/compaction failure paths, and updates focused tests, docs, and the changelog. - Reproducibility: yes. at source level with high confidence. Current main routes both embedded overflow paylo ... resetSessionAfterCompactionFailure, and the PR body includes before/after terminal proof of those branches. Automerge notes: - PR branch already contained follow-up commit before automerge: fix(auto-reply): drop dead compaction reset hook - PR branch already contained follow-up commit before automerge: fix(auto-reply): preserve sessions after compaction failures Validation: - ClawSweeper review passed for head 193d3c0. - Required merge gates passed before the squash merge. Prepared head SHA: 193d3c0 Review: openclaw#70479 (comment) Co-authored-by: FullerStackDev <263060202+fuller-stack-dev@users.noreply.github.com> Co-authored-by: vincentkoc <25068+vincentkoc@users.noreply.github.com> Co-authored-by: clawsweeper[bot] <274271284+clawsweeper[bot]@users.noreply.github.com> Approved-by: takhoffman Co-authored-by: takhoffman <781889+takhoffman@users.noreply.github.com>
…w#70479) Summary: - The PR removes the auto-reply compaction-failure session reset hook, adds preserved-session recovery guidance for overflow/compaction failure paths, and updates focused tests, docs, and the changelog. - Reproducibility: yes. at source level with high confidence. Current main routes both embedded overflow paylo ... resetSessionAfterCompactionFailure, and the PR body includes before/after terminal proof of those branches. Automerge notes: - PR branch already contained follow-up commit before automerge: fix(auto-reply): drop dead compaction reset hook - PR branch already contained follow-up commit before automerge: fix(auto-reply): preserve sessions after compaction failures Validation: - ClawSweeper review passed for head 193d3c0. - Required merge gates passed before the squash merge. Prepared head SHA: 193d3c0 Review: openclaw#70479 (comment) Co-authored-by: FullerStackDev <263060202+fuller-stack-dev@users.noreply.github.com> Co-authored-by: vincentkoc <25068+vincentkoc@users.noreply.github.com> Co-authored-by: clawsweeper[bot] <274271284+clawsweeper[bot]@users.noreply.github.com> Approved-by: takhoffman Co-authored-by: takhoffman <781889+takhoffman@users.noreply.github.com>
…w#70479) Summary: - The PR removes the auto-reply compaction-failure session reset hook, adds preserved-session recovery guidance for overflow/compaction failure paths, and updates focused tests, docs, and the changelog. - Reproducibility: yes. at source level with high confidence. Current main routes both embedded overflow paylo ... resetSessionAfterCompactionFailure, and the PR body includes before/after terminal proof of those branches. Automerge notes: - PR branch already contained follow-up commit before automerge: fix(auto-reply): drop dead compaction reset hook - PR branch already contained follow-up commit before automerge: fix(auto-reply): preserve sessions after compaction failures Validation: - ClawSweeper review passed for head 193d3c0. - Required merge gates passed before the squash merge. Prepared head SHA: 193d3c0 Review: openclaw#70479 (comment) Co-authored-by: FullerStackDev <263060202+fuller-stack-dev@users.noreply.github.com> Co-authored-by: vincentkoc <25068+vincentkoc@users.noreply.github.com> Co-authored-by: clawsweeper[bot] <274271284+clawsweeper[bot]@users.noreply.github.com> Approved-by: takhoffman Co-authored-by: takhoffman <781889+takhoffman@users.noreply.github.com>
Summary
/compact, or/newFixes #70472.
Real behavior proof
Behavior addressed: auto-reply no longer rotates/orphans the active session mapping when compaction or overflow recovery fails; the user gets a delivered failure reply that keeps dynamic overflow hints.
Real environment tested: local OpenClaw source checkout in an isolated PR worktree after rebasing onto current
upstream/mainb8e9ab9385(fix(codex): surface native compaction failures (#85160));pnpm openclaw --versionbuilt and ran the pushed head193d3c0. No live WebChat/model run.Exact steps or command run after this patch:
git fetch upstream main && git fetch origin fix/preserve-session-on-compaction-failuregit rebase upstream/main(clean rebase; no textual conflicts)git grep -n "resetSessionAfterCompactionFailure" upstream/main -- src/auto-reply/reply src/agentsconfirmed currentupstream/mainstill has the reset path, so this PR is still relevant after fix(codex): surface native compaction failures #85160.pnpm docs:listpnpm openclaw --versionnode --import tsx --input-type=moduleproduction-helper probe importingbuildContextOverflowRecoveryText,markReplyPayloadForSourceSuppressionDelivery, andgetReplyPayloadMetadatafromsrc/auto-reply.pnpm exec oxfmt --check --threads=1 src/auto-reply/reply/agent-runner-execution.ts src/auto-reply/reply/agent-runner.ts src/auto-reply/reply/agent-runner-execution.test.ts CHANGELOG.md docs/reference/session-management-compaction.mdscripts/run-vitest.mjsexports, because local Node 23 did not execute that script'simport.meta.mainbranch:node --input-type=modulewithspawnWatchedVitestProcess({ pnpmArgs: ['exec', 'node', ...resolveVitestNodeArgs(process.env), resolveVitestCliEntry(), 'run', 'src/auto-reply/reply/agent-runner-execution.test.ts', '--reporter=dot'] })src/agents/command/cli-compaction.test.ts,src/agents/command/session-store.test.ts,extensions/codex/src/app-server/compact.test.tsgit diff --check upstream/main...HEAD--mode branch --base upstream/mainEvidence after fix: terminal output from the local OpenClaw source setup and production-helper probe after rebasing on #85160:
Supplemental focused runtime coverage:
src/auto-reply/reply/agent-runner-execution.test.tspassed111tests. The compaction-adjacent selection from #85160 passed100tests acrosssrc/agents/command/cli-compaction.test.ts,src/agents/command/session-store.test.ts, andextensions/codex/src/app-server/compact.test.ts. The new regression tests assert the preserved active session remainssession,replyOperation.updateSessionIdis not called,updateSessionStoreis not called, the failure payload hasdeliverDespiteSourceReplySuppression: true, and the reply includes both the preserved-session guidance and the existing dynamicreserveTokensFloorhint.Observed result after fix: the pushed head is rebased on
b8e9ab9385, the local OpenClaw source build reports193d3c0, the production-helper probe keeps the session id unchanged, marks the failure reply for suppressed-source delivery, and keeps the dynamic overflow hint. Autoreview reported no actionable regressions against the newupstream/main.Maintainer supplemental before/after proof (May 22, 2026): I ran the same deterministic failure-path probe against clean archive copies of pre-fix
origin/mainand this PR head193d3c0fdd5a42cc5291f4f279e80f872fdd1051. The probe exercises the actualrunAgentTurnWithFallbackbranches for both embedded context-overflow error payloads and thrown compaction failures, with the realresetReplyRunSessionhelper wired on the pre-fix side.Exact commands run for the before/after proof:
env OPENCLAW_PR70479_EXPECT=broken OPENCLAW_VITEST_MAX_WORKERS=1 OPENCLAW_VITEST_NO_OUTPUT_TIMEOUT_MS=120000 node scripts/run-vitest.mjs src/auto-reply/reply/pr70479-live-proof.test.ts --reporter=verbosein agit archive origin/maincheckout.env OPENCLAW_PR70479_EXPECT=fixed OPENCLAW_VITEST_MAX_WORKERS=1 OPENCLAW_VITEST_NO_OUTPUT_TIMEOUT_MS=120000 node scripts/run-vitest.mjs src/auto-reply/reply/pr70479-live-proof.test.ts --reporter=verbosein agit archive 193d3c0fdd5a42cc5291f4f279e80f872fdd1051checkout.env OPENCLAW_VITEST_MAX_WORKERS=1 OPENCLAW_VITEST_NO_OUTPUT_TIMEOUT_MS=120000 node scripts/run-vitest.mjs src/auto-reply/reply/agent-runner-execution.test.ts -t "preserves the active session" --reporter=verbose.Before fix evidence from
origin/main:After fix evidence from PR head:
Observed result from the before/after proof: pre-fix
origin/mainrewrites the activeagent:main:mainsession fromsession-beforetosession-afterand calls bothupdateSessionStoreandreplyOperation.updateSessionId. The PR head keeps the active session atsession-beforein both failure modes, makes zero session-store/updateSessionId calls, and returns a failure payload markeddeliverDespiteSourceReplySuppression: truewith retry,/compact, and/newguidance. The committed focused regression slice passed:2 passed | 109 skippedfor the twopreserves the active sessiontests.What was not tested: live WebChat UI overflow with a real model; the compaction/overflow failure behavior was exercised with a local OpenClaw source runtime probe plus focused runtime-unit coverage.
Notes