Skip to content

Queued RPC replies lose restart recovery before final delivery #138564

Closed

Description

@steipete

Bug type

Regression (worked before, now fails)

Beta release blocker

No

Summary

A queued reply started through Gateway RPC can lose restart recovery after its original chat.send run finishes but before final delivery completes.

Steps to reproduce

  1. Start an isolated Gateway with a loopback mock OpenAI Responses provider.
  2. Send two authenticated chat.send requests to the same session with queueMode: "followup", holding the first provider response until the second request is queued.
  3. Allow both model turns to complete, and hold the queued turn at the existing final-delivery boundary.
  4. Close the Gateway with a restart expected and drainTimeoutMs: 0.
  5. Inspect the session's restart-recovery state.

The reproduction uses the actual Gateway, WebSocket requests, reply pipeline, session admissions and SQLite store. It does not construct synthetic reply operations or admissions.

Expected behavior

The still-undelivered queued reply remains eligible for the documented Gateway restart recovery.

Actual behavior

Before close, the real queued reply remains active and the original chat-run registrations are gone. The session remains done without a restart-recovery marker after close.

OpenClaw version

Source build d58c93f334ce5f867707a07591c0d032f6d1f641. The affected producer files remain unchanged at main e449371c3b157d59292cbdee1aa9a9112fb1c7b6.

Operating system

macOS 27.0

Install method

Isolated source worktree with pinned workspace dependencies; repository Vitest Gateway harness.

Model

Synthetic OpenAI Responses text fixture; no public model call.

Provider / routing chain

Authenticated WebSocket client → actual Gateway → loopback HTTP SSE provider fixture → queued final-delivery boundary.

Logs

Before close: status=done, operation=queued_followup, activeChatRuns=0, queued=1
Admission selected by closing host resolver=false
Admission selected by retained RPC resolver=true
After close: restart marker=false, safe recovery tools=false, status=done

Screenshots, recordings, and evidence

The failure is covered by an executable Gateway regression test in the accompanying repair. No GUI recording or second-process resumed-delivery observation is claimed.

Impact and severity

Affected workflow: queued RPC replies, including webchat followups, when restart interrupts final delivery after the original client run has finished. The deterministic reproduction loses the recovery marker. Production frequency is unknown.

Additional information

Follow-up to #138071. Its exact-host shutdown filtering matches the bootstrap resolver, while the RPC and scheduled lifetime wrappers do not record that host binding. Binding the wrappers at their producers changes the same reproduction to restart marker=true, safe recovery tools=true, status=running while preserving execution availability checks.

Activity

  1. added
    bug
    on Sep 4, 2026
  2. added
    maintainer
    on Sep 4, 2026
  3. added
    P1
    clawsweeper:linked-pr-open
    clawsweeper:no-new-fix-pr
    clawsweeper:source-repro
    impact:message-loss
    impact:session-state
    issue-rating: 🦞 diamond lobster
    maturity:stable
    on Sep 4, 2026
  4. clawsweeper commented on Sep 4, 2026

    @clawsweeper
    Contributor

    Codex review: keeping this open for maintainer follow-up; there is still a little grit to resolve. Reviewed September 4, 2026, 4:00 PM ET / 20:00 UTC.

    Summary
    Keep open: this is a current Gateway lifecycle regression with a formally linked open repair PR, and its maintainer label prevents automated cleanup.

    Reproducibility: yes. —source-reproducible, though not executed in this read-only review. The report supplies an authenticated two-request Gateway scenario, and current source shows the exact owner-filtered shutdown path and queued-operation resolver binding involved.

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

    Root-cause cluster
    Relationship: canonical
    Canonical: #138564
    Summary: This issue is the canonical record for the remaining queued-RPC restart-recovery gap; an open PR is its candidate repair.

    Members:

    Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

    Next step
    A formally linked open PR already owns the bounded repair, and the protected maintainer label requires normal maintainer handling rather than duplicate fix dispatch.

    Review details

    Best possible solution:

    Review and land the linked repair if it binds queued RPC and scheduled lifetime resolvers to the canonical Gateway host while preserving the existing execution-liveness fences and regression scenario.

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

    Yes—source-reproducible, though not executed in this read-only review. The report supplies an authenticated two-request Gateway scenario, and current source shows the exact owner-filtered shutdown path and queued-operation resolver binding involved.

    Is this the best way to solve the issue?

    Yes—the linked PR's producer-side canonical-host binding is the right repair direction, subject to exact-head review; a downstream recovery fallback would weaken the existing instance-ownership boundary.

    AGENTS.md: found and applied where relevant.

    Remaining risk / open question:

    • The linked repair must receive its own exact-head review before merge; this issue review establishes the current owner-boundary gap, not correctness of the proposed branch.

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

    Label changes

    Label changes:

    • add P1: An interrupted queued follow-up can lose its documented automatic recovery path and leave users without the expected final reply.
    • add impact:message-loss: Without the recovery marker, an otherwise queued final reply can be abandoned after a restart.
    • add impact:session-state: The failure is the absence of durable restart-recovery state for an admitted session turn.
    • add maturity:stable: The documented broken contract is primarily Gateway Lifecycle, whose Gateway runtime owner is M4 Stable.
    • add issue-rating: 🦞 diamond lobster: Current issue advisory state selects this label.
    • add clawsweeper:source-repro: Current issue advisory state selects this label.
    • add clawsweeper:linked-pr-open: Current issue advisory state selects this label.
    • add clawsweeper:no-new-fix-pr: Current issue advisory state selects this label.

    Label justifications:

    • P1: An interrupted queued follow-up can lose its documented automatic recovery path and leave users without the expected final reply.
    • impact:session-state: The failure is the absence of durable restart-recovery state for an admitted session turn.
    • impact:message-loss: Without the recovery marker, an otherwise queued final reply can be abandoned after a restart.
    • maturity:stable: The documented broken contract is primarily Gateway Lifecycle, whose Gateway runtime owner is M4 Stable.
    Evidence reviewed

    What I checked:

    Likely related people:

    • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
    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.
  5. added a commit that references this issue on Sep 4, 2026
    27c48d6
  6. added a commit that references this issue on Sep 5, 2026
    b7158ef
  7. added a commit that references this issue on Sep 29, 2026
    6b7a73d
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

    P1bugclawsweeper:linked-pr-openclawsweeper:no-new-fix-prclawsweeper:source-reproimpact:message-lossimpact:session-stateissue-rating: 🦞 diamond lobstermaintainermaturity:stable

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions