Skip to content

fix(gateway): identify interrupted work when a chat resumes - #205755

Merged
vincentkoc merged 4 commits into
mainfrom
fix/restart-original-run-evidence
Nov 26, 2026
Merged

vincentkoc merged 4 commits into
mainfrom
fix/restart-original-run-evidence

Conversation

@vincentkoc

@vincentkoc vincentkoc commented Nov 26, 2026 •

Copy link
Copy Markdown
Member

What Problem This Solves

A restarted chat could see an interrupted outer tool call without knowing which execution produced the nested scheduler results. An older reminder with the same name could lead it to confirm the wrong request. Leandro F. Chaves (@fonchaves) reported this in issue #187354. His contributor PR handles scheduler discovery and the extra CLI process.

User Impact

When recovery can identify the interrupted run, the assistant receives its ID and can verify a scheduled job by its returned ID, report a recorded error, or say that an interrupted action has an unknown outcome. It can continue independent work in the same request.

Why This Change Was Made

The session marker now carries the originating run through the existing restart event provenance. A unique live root supplies its own ID. A pending continuation can retain it within the same supervisor scope. A backend that observed execution start can supply it at shutdown even if the snapshot missed it. Starting a replacement attempt clears that observation. A client request interrupted before backend execution keeps its empty marker. When a different run takes writer ownership, the session store clears its predecessor’s retained marker in the same write. This also covers a failed startup cleanup followed by a fresh browser input. Capture reuses the pass over live runs and adds no startup transcript scans or scheduler reads. The persisted field is optional and uses the existing event shape.

Evidence

  • 3e97bba47d3b merges 0780dd62406b into the previously reviewed head. A workspace preparation failure retains its own error even after an observed backend start and competing restart and provider metadata. A genuine restart still attributes only the current executing attempt. The session writer still clears a predecessor’s marker on independent admission and preserves it while recovery is pending. 99/99 focused tests passed across six files on AWS. Scoped formatting and lint passed. Twelve unaffected PR files are byte-identical to the prior head, and main’s provider-summary change in the lifecycle projection merged cleanly. AWS test run · Previous green CI · Current CI

  • On baseline, 0/5 restart events supplied the originating run. On 98ccbc7, all 5/5 supplied the correct ID. A scripted model used real session history and the native scheduler to verify the saved job, report both typed errors, and leave both interrupted shell commands unretried. An older successful job of the same name was present in the invalid session. All five independent shell tasks completed. Baseline · Gateway and shell proof

  • 93/93 tests passed across eight restart, admission, terminal, and upgrade suites. The runtime build, scoped lint, formatting, and session-identity ratchet passed. The unchanged browser test verifies that a pre-runtime client request cannot supply the backend ID. The captured-start test failed before the terminal writer fix and passed after it. Failing test · Exact-tree validation · Hosted CI

  • A released 2026.11.10 Gateway wrote the old marker with operatorSource and queuedInputIds and no sourceRunId. The candidate started against that same database. It retained the session ID, user label, and original user message, produced one recovery reply, and supplied no invented run ID. Released-to-head upgrade

  • A one-shot failure while clearing a prior recovery marker let a fresh browser input retain the previous run’s ID after a pre-runtime abort on 98ccbc7. On de456c5, durable admission clears the prior marker. The later restart retains the fresh input with no attributed execution, and a second shutdown during pending recovery still preserves the predecessor. 36/36 focused tests passed across four files, with formatting, scoped lint and the session identity ratchet passing. Failing regression · Repaired transition

  • The issue stays open. In the counterexample on 98ccbc7, a model that ignored the evidence sent two success replies and repeated the already-committed CLI request. The number of jobs rose from 1 to 2. Enforcing truthful delivery and preventing retries of opaque shell effects in a mixed request need a separate product decision. The reported arm64 container OOM remains unverified. Counterexample

Carry the interrupted backend run into restart provenance. Use its recorded tool results to distinguish a saved operation from an error or missing acknowledgement, including when older results share the same chat.

Reported-by: Leandro F. Chaves <[email protected]>
@vincentkoc vincentkoc self-assigned this Nov 26, 2026
@clawsweeper

clawsweeper Bot commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@openclaw-barnacle openclaw-barnacle Bot added gateway Gateway runtime size: S labels Nov 26, 2026
@vincentkoc
vincentkoc marked this pull request as ready for review November 26, 2026 04:47
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. impact:session-state Session, memory, transcript, context, or agent state can drift or corrupt. clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Nov 26, 2026
@clawsweeper

clawsweeper Bot commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

This PR carries the interrupted execution’s identity into restart recovery and clears stale attribution when another run takes ownership.

Example: A reminder request from run current-execution is interrupted while an older reminder exists in the same conversation.

  • Before: Recovery receives generic instructions without identifying which run’s scheduler results belong to the request.
  • After: Recovery receives current-execution as provenance and instructions to inspect its returned identifiers or errors and leave unattributable effects uncertain.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) A focused, supported attribution repair with no actionable finding; overall remains capped at C because it addresses only part of the linked issue’s expected behavior.
Proof confidence 🦞 diamond lobster (5/6) ✨ media proof bonus Sufficient (linked_artifact): Public evidence maps the changed recovery owner to five isolated real-Gateway sessions using a scripted model, native scheduler, shell execution, and persisted history, including correct IDs, recorded errors, uncertainty, and independent work; it also records stable-to-candidate database compatibility and the repaired writer-transfer transition, although linked Crabbox artifacts are blocked from this review environment.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Partial
User problem: After a restart, the assistant can confuse an older scheduling result with the interrupted request and report the wrong outcome.
Reason: The maintainer-authored direction supplies missing evidence through existing recovery machinery and explicitly leaves strict confirmation and retry enforcement on the linked issue.

Merge readiness

✅ Ready for maintainer review

This PR provides useful recovery attribution, and the lifecycle conflict resolution preserves preparation failures without introducing a blocking regression.

Reviewed head: 3e97bba47d3bfae254efba39705fd72e8177efc3

Before merge

None.

Findings

None.

Agent review details

How this fits together

Gateway shutdown and lifecycle settlement persist session recovery markers; startup converts eligible markers into ordinary session events consumed by the resumed agent.

flowchart TD
  A[Live execution owners] --> B[Shutdown selection]
  C[Lifecycle terminal] --> D[Session writer]
  B --> D
  D --> E[SQLite restart marker]
  E --> F[Startup recovery]
  F --> G[Session event provenance]
  G --> H[Resumed agent]
Loading

Technical review

Best possible solution:

Keep attribution in the existing marker and session-event owners while tracking strict outcome enforcement separately on the linked issue.

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

Current main demonstrably omits the originating execution from restart admission, matching the maintainer’s public real-Gateway reproduction; this read-only review ran no target code.

Is this the best way to solve the issue?

The smallest complete attribution repair extends existing marker, lifecycle, and provenance owners without transcript scans or scheduler-specific machinery; it does not enforce model compliance.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 593dcf6b17c8.

Provenance checked

  • Ordinary restart continuation keeps the original intent (9344233: Replace competing reconstruction and replay machinery with one ordinary resume input that reconciles the saved transcript.)
  • Supervisor scope and private marker preservation keeps the original intent (f8727fd: Prevent work stopped under another supervisor token from returning after a crash while retaining private recovery facts across same-incarnation bookkeeping.)
  • Workspace failure precedence keeps the original intent (9f68c3f: Keep workspace preparation failures authoritative over earlier provider explanations and cancellation metadata.)

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Raw commit 86d7963 adds src/gateway/session-restart-resume.ts:232 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 86d7963b9099; files: src/gateway/session-restart-resume.ts)
  • Ayaan Zaidi: Raw commit 703c82d adds src/gateway/session-restart-resume.ts:252 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 703c82d20c5c; files: src/gateway/session-restart-resume.ts)
  • Free Wortley: Raw commit 2769799 adds src/config/sessions/session-restart-resume-scope.ts:22 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 27697998be7b; files: src/config/sessions/session-restart-resume-scope.ts)

PR surface

Source +83, Tests +124. Total +207 across 15 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 9 95 12 +83
Tests 6 208 84 +124
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 15 303 96 +207

Preflight source

Source unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified.

Root-cause cluster

Relationship: partial_overlap
Canonical: #187354
Summary: This PR repairs recovery attribution within the broader scheduling report, while the merged contributor PR addresses tool discovery.

Members:

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

Labels

Label changes:

No label changes.

Label justifications:

  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; 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.
  • proof: sufficient: Contributor real behavior proof is sufficient.

Rating scale

6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

History

Review history (3 earlier review cycles)
  • reviewed 2026-11-26T05:05:17.447Z sha 43d47b3 :: blocked before merge. :: [P2] Update sibling suites for the enriched restart marker | [P2] Resolve marker run identity inside the session-state owner
  • reviewed 2026-11-26T05:23:58.848Z sha 98ccbc7 :: needs maintainer review before merge. :: none
  • reviewed 2026-11-26T06:02:07.181Z sha de456c5 :: needs maintainer review before merge. :: none

Reviewed November 26, 2026, 1:43 AM ET / 06:43 UTC (Revision 4).

Resolve live and retained evidence in the session marker owner. Carry an observed backend start through its restart terminal and keep a client request interrupted before execution unattributed.
@vincentkoc

Copy link
Copy Markdown
Member Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Nov 26, 2026
Consume the predecessor's restart marker when a different run claims the session. A failed cleanup write can otherwise leave old scheduler receipts attached to a fresh input interrupted before backend execution. Keep the marker while the original continuation awaits admission.
@vincentkoc

Copy link
Copy Markdown
Member Author

@clawsweeper re-review

Please review corrected head de456c5489c85fa20a63b78e0ff354e14c7a6956. The durable session writer now clears a predecessor’s restart marker when fresh input takes ownership. A repeated shutdown before admission preserves the pending continuation. The regression failed on the preceding head and all 36 affected tests passed on the correction. Before · After

@clawsweeper

clawsweeper Bot commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

Merge the current lifecycle writer into the restart evidence branch. Apply terminal overrides and backend-start attribution only outside workspace preparation failures. Exercise the overlap with stale provider and shutdown data from an observed attempt.
@vincentkoc

Copy link
Copy Markdown
Member Author

@clawsweeper re-review

Please review the lifecycle conflict resolution at 3e97bba47d3b. The focused workspace-failure and writer-transfer checks are in the PR evidence.

@clawsweeper

clawsweeper Bot commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@vincentkoc
vincentkoc enabled auto-merge (squash) November 26, 2026 06:46
@vincentkoc

Copy link
Copy Markdown
Member Author

The remaining generated-validator failure is present on unchanged main. CI tested merge 14fc1f5f06e90053242adcf47cd9f634d7b95218, with main parent 22be06d7d2fd4025f94b6e8c20405e9f3b268a2c followed by PR head 3e97bba47d3bfae254efba39705fd72e8177efc3. Both that PR job and the scheduled job on the same main parent failed at Check generated schema validators because packages/gateway-protocol/src/compiled/protocol.generated/predicates.js was stale.

The schema, generator, checked-in predicates and lockfile have identical Git objects on the tested merge and parent. In an independent paired AWS run, regenerating the validators on each revision produced the same two-addition, one-deletion diff, SHA-256 e6ab697430c40bec17ec472df1254d1008b2f9dfb063db04bebec4f87ca9821e. It adds the optional revoke field from the recent model logout schema change. The 99 focused lifecycle, admission and writer tests passed on the corrected recovery tree. Scoped AWS proof

@vincentkoc
vincentkoc disabled auto-merge November 26, 2026 07:16
@vincentkoc
vincentkoc merged commit d63a7c9 into main Nov 26, 2026
130 of 133 checks passed
@vincentkoc
vincentkoc deleted the fix/restart-original-run-evidence branch November 26, 2026 07:29
@vincentkoc

Copy link
Copy Markdown
Member Author

Merged via explicitly authorized admin squash with attributed pre-existing CI failures.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 27, 2026
…#205755)

* fix(gateway): identify interrupted work when a chat resumes

Carry the interrupted backend run into restart provenance. Use its recorded tool results to distinguish a saved operation from an error or missing acknowledgement, including when older results share the same chat.

Reported-by: Leandro F. Chaves <[email protected]>

* fix(sessions): bind restart evidence to the executing attempt

Resolve live and retained evidence in the session marker owner. Carry an observed backend start through its restart terminal and keep a client request interrupted before execution unattributed.

* fix(sessions): clear stale restart evidence on writer transfer

Consume the predecessor's restart marker when a different run claims the session. A failed cleanup write can otherwise leave old scheduler receipts attached to a fresh input interrupted before backend execution. Keep the marker while the original continuation awaits admission.
tideclaw-bot pushed a commit that referenced this pull request Nov 30, 2026
* fix(gateway): identify interrupted work when a chat resumes

Carry the interrupted backend run into restart provenance. Use its recorded tool results to distinguish a saved operation from an error or missing acknowledgement, including when older results share the same chat.

Reported-by: Leandro F. Chaves <[email protected]>

* fix(sessions): bind restart evidence to the executing attempt

Resolve live and retained evidence in the session marker owner. Carry an observed backend start through its restart terminal and keep a client request interrupted before execution unattributed.

* fix(sessions): clear stale restart evidence on writer transfer

Consume the predecessor's restart marker when a different run claims the session. A failed cleanup write can otherwise leave old scheduler receipts attached to a fresh input interrupted before backend execution. Keep the marker while the original continuation awaits admission.

(cherry picked from commit d63a7c9)

Release adaptation: Retain the release workspace-preparation terminal message and keep failed preparation from inheriting execution metadata; only a confirmed backend start becomes restart provenance. No database schema change.

Co-authored-by: RomneyDa <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gateway Gateway runtime impact:session-state Session, memory, transcript, context, or agent state can drift or corrupt. P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. size: M 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.

1 participant