Skip to content

[Bug]: Webchat abort loses session context — reroutes to new session after compaction #97457

Closed as not planned

Description

@hades0856-art

Bug type

Behavior bug (incorrect output/state without crash)

Beta release blocker

No

Summary

When user clicks Stop in webchat and compaction runs concurrently, the next message is routed to a brand-new session instead of the original, causing total context loss.

Steps to reproduce

  1. Have a long webchat conversation with an agent 2. Send a message that triggers a long tool call or generation 3. Click Stop to abort 4. Wait for compaction to run (generates .reset file) 5. Send the next message 6. Agent responds as if it's a brand new conversation — all prior context lost

Expected behavior

Aborting a generation should keep the user in the same session. The next message should load the full conversation history from before the abort.

Actual behavior

Framework creates a new session (1c9239d5) and remaps agent::main from the old session (7cb5dff5) to the new one. sessions.json confirms restartRecoveryRuns was populated despite this being a user-initiated RPC abort, not a Gateway restart.

OpenClaw version

2026.6.10

Operating system

Windows 11 (x64)

Install method

No response

Model

deepseek/deepseek-v4-pro

Provider / routing chain

DeepSeek API (direct)

Additional provider/model setup details

No response

Logs, screenshots, and evidence

Impact and severity

No response

Additional information

Confirmed against unmodified npm install (openclaw@2026.6.10).
All dist files timestamp 2026-06-25 22:40:28 — no source modifications.
Evidence: sessions.json shows restartRecoveryRuns populated on a user-initiated RPC abort.
Related: #70472, #14463

Activity

  1. clawsweeper commented on Jun 28, 2026

    @clawsweeper
    Contributor

    Codex review: keeping this open for maintainer follow-up; there is still a little grit to resolve. Reviewed June 28, 2026, 5:34 AM ET / 09:34 UTC.

    Summary
    Keep open: current main and v2026.6.10 include the older compaction-failure session-preservation fix, but the newer WebChat RPC Stop plus compaction path that leaves restartRecoveryRuns and remaps the active session is not proven fixed. The open Stop-recovery PR and restart-recovery PRs are adjacent, but none cleanly owns this exact report yet.

    Reproducibility: no. high-confidence end-to-end reproduction was run. The source path is clear enough to keep open: sessions.compact interrupts active runs through chat.abort, chat.abort records rpc cancellation, and restart recovery can still write restartRecoveryRuns.

    Ways to help us reproduce this

    • Add a screenshot or short recording showing the behavior.
    • Add expected vs actual behavior.

    Next step
    Manual review is safer because this session-state race overlaps open WebChat Stop and restart-recovery PRs and needs live reproduction before queueing another fix PR.

    Review details

    Best possible solution:

    Add focused coverage and a fix for the RPC Stop plus compaction path so user aborts do not leave restartRecoveryRuns or remap the active WebChat session, then validate with live WebChat proof.

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

    No high-confidence end-to-end reproduction was run. The source path is clear enough to keep open: sessions.compact interrupts active runs through chat.abort, chat.abort records rpc cancellation, and restart recovery can still write restartRecoveryRuns.

    Is this the best way to solve the issue?

    Unclear for implementation shape: the older compaction reset fix is already present, but this report likely needs either an extension of the open Stop-recovery work or a narrower restartRecoveryRuns guard with live proof.

    AGENTS.md: found and applied where relevant.

    Remaining risk / open question:

    • No live Windows/WebChat Stop plus compaction reproduction was run in this read-only review.
    • fix(webchat): recover session after stop #92003 overlaps the WebChat Stop surface, but its proof and linked issue do not establish coverage for this compaction/restartRecoveryRuns remap report.
    • The restart-recovery PRs found by search are adjacent to restartRecoveryRuns false positives and retry budgets, but not a clean canonical fix for this issue.

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

    Label changes

    Label justifications:

    • P1: The report describes a current-release WebChat workflow losing conversation continuity after Stop and compaction.
    • impact:session-state: The failure is drift between the active WebChat session key, session id, and restart-recovery lifecycle state.
    • impact:data-loss: The old transcript may remain on disk, but the active conversation is remapped so prior context appears lost to the user.
    • maturity:stable: The affected Gateway/WebChat RPC surface matches gateway-runtime, which the maturity shortlist reports as M4 Stable.
    Evidence reviewed

    What I checked:

    • Live issue state: The issue is open, externally reported against OpenClaw 2026.6.10, and says sessions.json contains restartRecoveryRuns after a user-initiated RPC abort rather than a gateway restart.
    • Manual compaction interrupts active runs through chat.abort: sessions.compact calls interruptSessionRunIfActive before running embedded compaction, so the reported compaction race reaches the same abort surface as WebChat Stop. (src/gateway/server-methods/sessions.ts:2437, d17b970bb50d)
    • RPC abort path remains distinct from restart recovery: chat.abort without a runId aborts matching session runs with abortOrigin and stopReason set to rpc, which matches the reporter's claim that this is a user abort path, not a gateway restart path. (src/gateway/server-methods/chat.ts:3219, d17b970bb50d)
    • Abort cleanup emits terminal lifecycle but does not prove session remap prevention: abortChatRunById aborts the controller, clears active run state, emits a lifecycle end event, and uses the supplied stopReason; this does not by itself prove restartRecoveryRuns cannot be written later for this race. (src/gateway/chat-abort.ts:454, d17b970bb50d)
    • Restart marker can still write restartRecoveryRuns: markRestartAbortedMainSessions sets abortedLastRun and rebuilds restartRecoveryRuns for matched active runs, matching the durable state the reporter says appeared after the RPC abort. (src/agents/main-session-restart-recovery.ts:254, d17b970bb50d)
    • Older compaction-failure fix is present in current release: v2026.6.10 contains the preserved-session compaction-failure text and tests from merged PR fix(auto-reply): preserve sessions after compaction failures #70479, so the older compaction reset bug is not the whole remaining report. (src/auto-reply/reply/agent-runner-execution.ts:1378, aa69b12d0086)

    Likely related people:

    • jalehman: Recent commits added embedded run session target, canonical transcript reader identity, and compact trim lifecycle seams in the central session/compaction area. (role: recent session lifecycle contributor; confidence: medium; commits: 0dfa22c6e0fc, d216f7c876dd, e442b575b986; files: src/gateway/server-methods/sessions.ts, src/gateway/session-lifecycle-state.ts, src/agents/main-session-restart-recovery.ts)
    • steipete: Recent history shows gateway abort expiry, deferred abort stop-reason, and async session transcript IO work in the same session-state surfaces. (role: feature-history contributor; confidence: medium; commits: ca4a12381a26, 5ed8bbc69468, 6147e1b91d3e; files: src/gateway/chat-abort.ts, src/gateway/server-methods/chat.ts, src/gateway/server-methods/sessions.ts)
    • joshavant: Merged history includes main-session startup recovery and interrupted-session restart marking adjacent to restartRecoveryRuns behavior. (role: restart recovery contributor; confidence: medium; commits: e1978cf73cbd, 99a269f8b4f3, 64b94daf92c4; files: src/agents/main-session-restart-recovery.ts, src/gateway/chat-abort.ts)
    • ooiuuii: Merged PR fix(gateway): mark active main sessions before restart shutdown aborts #91357 added active-main-session restart shutdown marking, which feeds the restart recovery marker path. (role: adjacent restart-shutdown contributor; confidence: medium; commits: d20fdf3b3842; files: src/agents/main-session-restart-recovery.ts, src/gateway/server-close.ts)
    • fuller-stack-dev: Authored merged PR fix(auto-reply): preserve sessions after compaction failures #70479, the prior compaction-failure fix that preserves sessions after overflow/compaction failure recovery. (role: adjacent fix contributor; confidence: medium; commits: cd1cae5be9ba; files: src/auto-reply/reply/agent-runner-execution.ts, src/auto-reply/reply/agent-runner-execution.test.ts)
    How this review workflow works
    • 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.
  2. added
    P1High-priority user-facing bug, regression, or broken workflow.
    impact:data-lossCan lose, corrupt, or silently drop user/session/config data.
    impact:session-stateSession, memory, transcript, context, or agent state can drift or corrupt.
    maturity:stableBroken existing behavior primarily owned by an M4/M5 scorecard surface.
    issue-rating: 🐚 platinum hermitGood issue quality with a plausible reproduction path needing some confirmation.
    clawsweeper:needs-live-reproClawSweeper needs live local, crabbox, or manual validation to confirm this issue.
    clawsweeper:no-new-fix-prClawSweeper does not recommend queueing a new automated fix PR for this issue.
    clawsweeper:needs-maintainer-reviewClawSweeper marked this issue as needing maintainer review before automation.
    on Jun 28, 2026
  3. keaideweiertuode commented on Jun 30, 2026

    @keaideweiertuode

    Confirmed — same behavior here

    Setup: OpenClaw 2026.6.10 + DeepSeek V4 Flash, WebChat UI on Ubuntu 24.04 (npm install).

    What happened

    In a long conversation, I clicked Stop to abort a lengthy generation. After that, compaction ran (likely triggered by the context overflow). The next message was routed to a brand new session — the agent had no memory of the prior conversation.

    Checked sessions.json afterward and confirmed restartRecoveryRuns was populated, even though this was a user-initiated RPC abort, not a Gateway restart.

    Additional context

    The session that aborted had accumulated ~800KB of context (largely due to tool output bloat described in #97651). The combination of Stop + compaction + context pressure seems to trigger the same recovery path as a Gateway restart.

    Workaround

    Avoid clicking Stop in WebChat on long sessions for now. Refreshing the page before sending the next message seems safer.

    Let me know if you need any more details from the session state.

  4. openclaw-barnacle commented on Jul 15, 2026

    @openclaw-barnacle

    This issue has been automatically marked as stale due to inactivity.
    Please add updates or it will be closed.

  5. barnacle-openclaw commented on Jul 22, 2026

    @barnacle-openclaw

    Closing due to inactivity.
    If this is still an issue, please retry on the latest OpenClaw release and share updated details.
    If you are absolutely sure it still happens on the latest release, open a new issue with fresh steps to reproduce.

  6. locked as resolved and limited conversation to collaborators on Sep 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P1High-priority user-facing bug, regression, or broken workflow.bugSomething isn't workingclawsweeper:needs-live-reproClawSweeper needs live local, crabbox, or manual validation to confirm this issue.clawsweeper:needs-maintainer-reviewClawSweeper marked this issue as needing maintainer review before automation.clawsweeper:no-new-fix-prClawSweeper does not recommend queueing a new automated fix PR for this issue.impact:data-lossCan lose, corrupt, or silently drop user/session/config data.impact:session-stateSession, memory, transcript, context, or agent state can drift or corrupt.issue-rating: 🐚 platinum hermitGood issue quality with a plausible reproduction path needing some confirmation.maturity:stableBroken existing behavior primarily owned by an M4/M5 scorecard surface.staleMarked as stale due to inactivity

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions