Skip to content

fix: Web UI turns still ask to try again after a stall - #162490

Merged
obviyus merged 6 commits into
mainfrom
fix/webui-stall-recovery
Oct 1, 2026
Merged

obviyus merged 6 commits into
mainfrom
fix/webui-stall-recovery

Conversation

@obviyus

@obviyus obviyus commented Oct 1, 2026 •

Copy link
Copy Markdown
Collaborator

What Problem This Solves

Fixes: Web UI (chat.send) turns that stall before replying still end with "⚠️ This turn was interrupted because it stopped making progress. Please try again." instead of the automatic recovery that channel DMs get since #161069.

User Impact

  • When a Web UI turn stalls before replying, the user now gets the recovered answer instead of the retry notice. The stalled run ends as aborted, and the answer arrives as its own run in the same chat, the same way any queued Web UI follow-up arrives. If the recovery also stalls, the existing notice is sent once.
  • The recovery keeps its normal tools, except that Skill Workshop can't write to the skill library during a recovery. It answers "send a fresh message" instead.
  • Group-thread participant turns keep the notice. That is now the only exception, and it's stated in the docs.

Why This Change Was Made

#161069 kept the notice for Web UI turns because the recovery run had no owner that would deliver its answer (maintainer decision). Provenance of that owner:

The fix:

  • The stalled turn hands its request to the recovery through the source's existing createSourceRetry. A pending source that hands off is settled, so the original can never deliver once the retry exists, and the recovery owns the only delivery. The relaxed pending case is reachable only through the stall continuation, which runs after the stale watchdog aborted the source before any output. createSourceRetry has two callers:
    • the follow-up source retry in followup-delivery.ts, which only sees owners that already queued (deliver/drop);
    • the stall continuation.
  • The fix: stalled chat turns ask users to retry instead of answering from gathered context #161069 early return is narrowed. Only a source that explicitly declares no owner (drop) keeps the notice.
  • Library authoring is not carried into the recovery. Every authenticated Web UI human turn mints a library-authoring grant (prepareGatewaySkillAuthoring), and every run binds it at admission. By design (feat(skills): add personal libraries for shared Gateways #134068) the grant refuses a replacement run, and the recovery is a new run, so it doesn't inherit the grant. Before this change the recovery failed with "Personal authoring cannot move to a replacement run" instead of answering.
    • Rule: a recovery run never inherits skill-library authoring. Whatever the original grant's target, the recovery gets an expired personal grant. The Workshop tool can't fall back to the workspace tool (createSkillWorkshopTool), and every call returns AUTHORITY_EXPIRED asking for a fresh message. All other tools stay available, and no access is widened.
    • Alternatives considered:

Group threads: left for a follow-up

Group-thread participant turns keep the notice. Participant reply options set onQueuedFollowupReplyBatch: undefined (#141411), which #116649's in check turns into a drop owner, so every queued participant reply is dropped. Omitting that key makes the recovery reach the group: in a qa-channel run the group got STALLED-TURN-RECOVERED-OK instead of the notice. The same run showed a second group message, arriving while the recovery ran, ending skipped:reply-operation-active with no reply. Participant reply options also clear turnAdoptionLifecycle, so a participant turn on a busy session never reaches queue policy (allowGatewayQueueResolution in dispatch-from-config.lifecycle.ts). Fixing that needs its own change to participant admission, so this PR doesn't enable group recovery.

Bounded cost

  • Recovery runs at most once per stalled turn. continueStalledTurn is armed only for direct turns and called once from the aborted-dispatch finisher. The recovery runs on the follow-up runner, which never arms it, so if the recovery also stalls the existing notice is sent and nothing else starts. Tested: "sends the Web UI notice, not a second recovery, when the recovery also stalls" (2 model turns total, empty queue).
  • One delivery per handed-off source. After createSourceRetry from pending, the original owner is settled and refuses both delivery and further retries. Tested: "gives a pending source's only delivery to the retry it hands off to".
  • No recovery where its answer would be dropped. Tested: "leaves the notice with a group-thread participant whose source declares no reply owner".
  • No wider tool access. Tested: "never lets a personal/workspace-target recovery author skills while keeping its other tools". No tools are disabled.

Evidence

  • Real Gateway chat.send. A QA Gateway child, mock-openai with the stalled-turn fixture, QA_DIAGNOSTIC_STUCK_SESSION_ABORT_MS=30000, and an operator GatewayClient (TUI pattern) recording chat broadcasts:
    • Before (f525f46): +56.4s state=error "⚠️ This turn was interrupted because it stopped making progress. Please try again.", then aborted. 5 mock requests, none guided.
    • After: +58.6s aborted for the stalled run, then +59.5s state=final under the recovery's own run id with the recovered answer. 6 mock requests: 5 stalled, 1 guided success. The answer is persisted in chat.history.
    • An intermediate run without the authoring change: the recovery was delivered through the new owner but failed with the authoring error. That run is what found the issue.
  • Unit tests:
    • The two Web UI tests in agent-runner.stalled-turn.test.ts fail on main (continueStalledTurn returned false) and pass now.
    • The owner, drop and authoring tests pass.
    • Wall times: agent-runner.stalled-turn.test.ts + followup-delivery.test.ts: 51 s (75 tests; plus skill-workshop-tool.test.ts 19 tests). chat-send-late-followup.test.ts: 2 s (6 tests).
  • node scripts/check-changed.mjs passes (typecheck, lint, guards).
  • Head c1bca05 (delivery path unchanged since): the stalled run ends aborted at +59.1s, then state=final with the recovered answer under the recovery's run id at +60.1s. 6 mock requests, 1 guided. The answer is persisted in chat.history.

LOC vs origin/main: production +36/−6, tests +130/−5, docs +1/−1.

@obviyus

obviyus commented Oct 1, 2026

Copy link
Copy Markdown
Collaborator Author

@clawsweeper review

@clawsweeper

clawsweeper Bot commented Oct 1, 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.

@clawsweeper

clawsweeper Bot commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation gateway Gateway runtime size: S labels Oct 1, 2026
@clawsweeper clawsweeper Bot added P1 High-priority user-facing bug, regression, or broken workflow. merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. proof: telegram-e2e This PR needs Telegram Test Server proof with the repository E2E skill. 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 Oct 1, 2026
@clawsweeper

clawsweeper Bot commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed October 1, 2026, 6:55 AM ET / 10:55 UTC (Revision 8).

ClawSweeper review

What this changes

The branch delivers stalled Web UI answers through the original request’s reply owner and prevents inherited skill-library authoring during recovery.

Merge readiness

✅ Ready for maintainer review

This PR remains useful: current main still excludes standalone Web UI recovery. The latest commit resolves the previous Workshop authority concern by removing its writable recovery path; no blocking defect remains.

Priority: P1
Reviewed head: d78bccb1475d7c911ff93b34cd2ed4bd7e3b4122

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused repair with relevant Gateway observations and no remaining actionable finding.
Proof confidence 🐚 platinum hermit (4/6) Sufficient (live_output): The recorded real Gateway chat.send stall exercises the production recovery and reply owners, showing a recovered final under its own run ID and persisted history. The latest commit preserves delivery and replaces both authoring targets with unconditional denial, eliminating the writable path behind the prior authority-proof request. No stored-data contract changes.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (live_output): The recorded real Gateway chat.send stall exercises the production recovery and reply owners, showing a recovered final under its own run ID and persisted history. The latest commit preserves delivery and replaces both authoring targets with unconditional denial, eliminating the writable path behind the prior authority-proof request. No stored-data contract changes.
Evidence reviewed 9 items Pinned introduction: Reviewed the merge-base dd41f8e to head d78bccb delta and original production blobs. The source retry now settles a pending original owner before creating the recovery owner. The supplied stale test merge was not used to infer removals from main.
Still necessary on main: At fetched main, continueStalledReplyTurn still returns false for any source-bound reply disposition, leaving standalone Web UI turns on the notice path. The existing retry owner is available, but main does not use it for stalled-turn recovery.
Latest release comparison: The v2026.9.7 runner contains none of the stalled-turn continuation symbols searched below; the requested recovery is not already supplied by that release.
Findings None None.
Security None None.

How this fits together

Gateway chat requests enter OpenClaw’s agent reply pipeline. After a stalled turn is aborted, the follow-up queue can recover an answer from its transcript and deliver it back to the originating chat.

flowchart TD
  A[Web UI request] --> B[Agent turn and transcript]
  B --> C[Stall watchdog abort]
  C --> D{Recovery can be delivered?}
  D -->|Yes| E[One queued recovery]
  D -->|No| F[Retry notice]
  E --> G[Source reply owner]
  G --> H[Chat answer and history]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source +30, Tests +125, Docs 0. Total +155 across 6 files.

View PR surface stats
Area Files Added Removed Net
Source 3 36 6 +30
Tests 2 130 5 +125
Docs 1 1 1 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 6 167 12 +155

Review metrics

Metric Value Why it matters
Production versus regression coverage production net +30 lines; tests net +125 lines Production growth implements source-owned recovery and explicit authoring denial; tests protect delivery and recovery bounds.

Technical review

Best possible solution:

Keep recovery on the existing source-owned follow-up lane, with fresh-message recovery for library authoring and group admission handled separately.

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

Yes: current main explicitly refuses standalone recovery for a source-owned Web UI turn, matching the recorded real Gateway stall. This review verified the source path without executing it.

Is this the best way to solve the issue?

Yes: reusing the existing source retry owner avoids a competing delivery mechanism, and the latest authoring denial removes the previously exposed workspace fallback.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

  • add proof: sufficient: Contributor real behavior proof is sufficient. The recorded real Gateway chat.send stall exercises the production recovery and reply owners, showing a recovered final under its own run ID and persisted history. The latest commit preserves delivery and replaces both authoring targets with unconditional denial, eliminating the writable path behind the prior authority-proof request. No stored-data contract changes.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (live_output): The recorded real Gateway chat.send stall exercises the production recovery and reply owners, showing a recovered final under its own run ID and persisted history. The latest commit preserves delivery and replaces both authoring targets with unconditional denial, eliminating the writable path behind the prior authority-proof request. No stored-data contract changes.
  • remove rating: 🦐 gold shrimp: Current PR rating is rating: 🐚 platinum hermit, so this older rating label is no longer current.
  • remove merge-risk: 🚨 security-boundary: Current PR review selected no merge-risk labels.
  • remove status: 📣 needs proof: Current PR status label is status: 👀 ready for maintainer look.

Label justifications:

  • P1: Stalled Web UI turns currently leave users without automatic recovery of their unanswered request.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (live_output): The recorded real Gateway chat.send stall exercises the production recovery and reply owners, showing a recovered final under its own run ID and persisted history. The latest commit preserves delivery and replaces both authoring targets with unconditional denial, eliminating the writable path behind the prior authority-proof request. No stored-data contract changes.
  • proof: sufficient: Contributor real behavior proof is sufficient. The recorded real Gateway chat.send stall exercises the production recovery and reply owners, showing a recovered final under its own run ID and persisted history. The latest commit preserves delivery and replaces both authoring targets with unconditional denial, eliminating the writable path behind the prior authority-proof request. No stored-data contract changes.

Evidence

What I checked:

  • Pinned introduction: Reviewed the merge-base dd41f8e to head d78bccb delta and original production blobs. The source retry now settles a pending original owner before creating the recovery owner. The supplied stale test merge was not used to infer removals from main. (src/gateway/server-methods/chat-send-late-followup.ts:100, d78bccb1475d)
  • Still necessary on main: At fetched main, continueStalledReplyTurn still returns false for any source-bound reply disposition, leaving standalone Web UI turns on the notice path. The existing retry owner is available, but main does not use it for stalled-turn recovery. (src/auto-reply/reply/agent-runner-execute.ts:74, d64730851269)
  • Latest release comparison: The v2026.9.7 runner contains none of the stalled-turn continuation symbols searched below; the requested recovery is not already supplied by that release. (src/auto-reply/reply/agent-runner-execute.ts, c074824a27c9)
  • Prior authority concern resolved: GitHub’s exact-head commit patch confirms that the workspace-target exception from c1bca05 was removed. Both grant targets now become a personal-only capability whose invoke always throws AUTHORITY_EXPIRED. The previous request for allowed workspace recovery writes and mixed-requester/revocation proof no longer applies to this removed writable path. (src/auto-reply/reply/stalled-turn-recovery.ts:64, d78bccb1475d)
  • Workshop final-effect boundary: The Workshop factory supplies a workspace tool only for defaultTarget workspace. Recovery sets personal, so no workspace fallback is constructed; valid personal operations reach the always-rejecting capability before library I/O. Run parameter preparation preserves this capability through tool construction. Other tools retain their existing admission contracts. (src/agents/tools/skill-workshop-tool.ts:140, d78bccb1475d)
  • Real Gateway recovery evidence: The captured PR body reports a real QA Gateway child and GatewayClient using chat.send with injected provider stalls. At c1bca05 the original run aborted at +59.1 seconds, the recovery produced a content-bearing final under its own run ID at +60.1 seconds, and chat.history retained the answer. The exact-head commit changes only authoring denial and its test, preserving that delivery path. This is production-boundary recovery evidence with a controlled provider, rather than an isolated mocked transport test. (src/auto-reply/reply/stalled-turn-recovery.ts:53, c1bca05fb2f7)

Likely related people:

  • obviyus: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • Finn763: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

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 (7 earlier review cycles)
  • reviewed 2026-10-01T06:59:39.265Z sha 35b84d3 :: needs real behavior proof before merge. :: [P1] Preserve the personal-only namespace when removing the expired grant
  • reviewed 2026-10-01T07:29:37.648Z sha a581c93 :: needs maintainer review before merge. :: none
  • reviewed 2026-10-01T08:16:24.096Z sha c1bca05 :: needs changes before merge. :: none
  • reviewed 2026-10-01T09:28:04.007Z sha c1bca05 :: needs changes before merge. :: none
  • reviewed 2026-10-01T10:21:43.458Z sha c1bca05 :: needs maintainer review before merge. :: none
  • reviewed 2026-10-01T10:29:09.588Z sha c1bca05 :: needs real behavior proof before merge. :: none
  • reviewed 2026-10-01T10:38:23.189Z sha c1bca05 :: needs real behavior proof before merge. :: none

@obviyus
obviyus force-pushed the fix/webui-stall-recovery branch from 35b84d3 to a581c93 Compare October 1, 2026 07:23
@obviyus obviyus changed the title fix: Web UI and group-thread turns still ask to try again after a stall fix: Web UI turns still ask to try again after a stall Oct 1, 2026
@obviyus

obviyus commented Oct 1, 2026

Copy link
Copy Markdown
Collaborator Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added 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 rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. proof: telegram-e2e This PR needs Telegram Test Server proof with the repository E2E skill. labels Oct 1, 2026
@obviyus

obviyus commented Oct 1, 2026

Copy link
Copy Markdown
Collaborator Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@obviyus
obviyus marked this pull request as ready for review October 1, 2026 10:17
@obviyus

obviyus commented Oct 1, 2026

Copy link
Copy Markdown
Collaborator Author

@clawsweeper approve

@obviyus

obviyus commented Oct 1, 2026

Copy link
Copy Markdown
Collaborator Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Oct 1, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Command router queued. I will update this comment with the next step.

@clawsweeper

clawsweeper Bot commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. and removed proof: sufficient ClawSweeper judged the real behavior proof convincing. 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. labels Oct 1, 2026
@obviyus

obviyus commented Oct 1, 2026

Copy link
Copy Markdown
Collaborator Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Oct 1, 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: 🐚 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 rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Oct 1, 2026
@obviyus
obviyus merged commit 5e2d8e3 into main Oct 1, 2026
135 of 139 checks passed
@obviyus
obviyus deleted the fix/webui-stall-recovery branch October 1, 2026 11:14
@obviyus

obviyus commented Oct 1, 2026

Copy link
Copy Markdown
Collaborator Author

Landed in 5e2d8e3.

  • Problem: Web UI (chat.send) turns that stalled before replying still ended with the "please try again" notice. The recovery run inherited the stalled turn's pending reply owner, so its answer was dropped.
  • Fix: the recovery run delivers through a fresh source retry owner, like any queued follow-up of that source. A recovery run never inherits skill-library authoring, so Skill Workshop asks for a fresh message instead of writing during recovery.
  • Proof: CI is green on d78bccb and the hosted review is ready. The real Gateway chat.send stall now ends aborted and the recovered answer is persisted in chat.history. Focused recovery tests cover the authoring cutoff.

obviyus added a commit that referenced this pull request Oct 1, 2026
## What Problem This Solves

Fixes: when a Web UI (`chat.send`) turn stalls, and the automatic recovery from #162490 also stalls, the user gets neither an answer nor the "stopped making progress" notice. The chat just shows the run as aborted.

## User Impact

In that double-stall case, Web UI users see the same "⚠️ This turn was interrupted because it stopped making progress. Please try again." error they got before #162490. A user's own cancel stays silent, and channel delivery is unchanged.

## Why This Change Was Made

#161069 and #162490 promise one last-resort notice if the recovery run also stalls. `followup-delivery.ts` builds that notice payload. The follow-up runner, though, reported the watchdog-aborted run to its source owner as `completion: aborted`, the same as a user cancel. The `chat.send` finalizer (`chat-send-source-finalization.ts`) correctly hides final payloads for aborted runs and emits a bare `aborted` event, so the notice was dropped. The #162490 test missed this because it mocked the finalizer as "delivered".

The follow-up runner owns the completion it reports, so the fix is there. A stall-recovery run whose operation the watchdog stalled before any output now completes as `failed`, with the notice as its error. The Gateway already sends that through its terminal error contract (`state: "error"`), the same way the original stalled turn did before #162490. Other aborted follow-ups, including user cancels (`aborted_by_user`), still classify as `aborted` and stay silent. This change adds no new message: it restores the existing notice on the one surface that lost it.

Hermes (sibling framework) handles an inactivity timeout the same way: it returns a failed run result with diagnostic text through the turn's own reply path, never a silent cancel.

## Bounded cost

No new model calls or runs. This only changes how an already-finished recovery run is classified. Recovery still happens at most once per stalled turn; the existing test covers this (2 model turns, empty queue).

## Evidence

- `agent-runner.stalled-turn.test.ts` "sends the Web UI notice, not a second recovery, when the recovery also stalls" now drives the real `createChatSendLateReplyFinalizer`, with a real Gateway request context, and asserts the `chat` event it broadcasts.
  - On `main` it fails: `state: "aborted"`, no notice.
  - With the fix it passes: one `state: "error"` event whose `errorMessage` is the notice.
- **Live model, real Gateway `chat.send` client.** A local proxy sits in front of the real OpenAI API (`gpt-6-astra`), and an operator WebSocket client (the TUI's `GatewayClient`) sends "What is 17*23? Reply with just the number." and records the `chat` events. A live model can't be made to stall, so the proxy reproduces the stall shape for the question's requests (4 failing requests, then held open until the abort) for both the original turn and its recovery. QA stuck-session bound: 30 s.
  - **Before (`origin/main` d06974d):** two stuck aborts (ages 48 s and 59 s). The client receives `aborted` for the original run at +56.7 s, then `aborted` for the recovery run at +116.8 s. No notice and no answer.
  - **After (head `823a966`):** same two stuck aborts (ages 49 s and 59 s). The client receives `aborted` for the original run at +56.7 s, then `state: "error"` with "⚠️ This turn was interrupted because it stopped making progress. Please try again." for the recovery run at +116.7 s.
  - Telegram isn't affected: channel follow-ups route the notice payload directly, and this change only alters the completion reported to a source owner.
- Wall time: `pnpm test src/auto-reply/reply/agent-runner.stalled-turn.test.ts --maxWorkers=1` takes 39.6 s real, 36.0 s Vitest duration (60% transform, 30% tests) for 12 tests. The file's whole suite runs the real `runReplyAgent` with a SQLite transcript. This defect only shows at the boundary between the follow-up runner's completion and the chat.send finalizer, so a cheaper unit test of either side alone (the old mocked finalizer) missed it.
- Sibling suites pass: `followup-runner`, `followup-delivery`, `chat-send-late-followup`, and `server.chat-queued-followup` (real Gateway WebSocket), 104 tests.
- `node scripts/check-changed.mjs` passes.

Optional cleanup of the expired-personal-grant stub was skipped; it would grow the diff.

No new user-visible messages: this restores the existing notice on the one surface that lost it, and user cancels stay silent.

LOC vs `origin/main`: production +11/−1, tests +26/−10.

No overlap with Pash/Sarah changes on the touched files.

Co-authored-by: Ayaan Zaidi <[email protected]>
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 2, 2026
## What Problem This Solves

Fixes: Web UI (`chat.send`) turns that stall before replying still end with "⚠️ This turn was interrupted because it stopped making progress. Please try again." instead of the automatic recovery that channel DMs get since openclaw#161069.

## User Impact

- When a Web UI turn stalls before replying, the user now gets the recovered answer instead of the retry notice. The stalled run ends as aborted, and the answer arrives as its own run in the same chat, the same way any queued Web UI follow-up arrives. If the recovery also stalls, the existing notice is sent once.
- The recovery keeps its normal tools, except that Skill Workshop can't write to the skill library during a recovery. It answers "send a fresh message" instead.
- Group-thread participant turns keep the notice. That is now the only exception, and it's stated in the docs.

## Why This Change Was Made

openclaw#161069 kept the notice for Web UI turns because the recovery run had no owner that would deliver its answer ([maintainer decision](openclaw#161069 (comment))). Provenance of that owner:

- openclaw#116649 binds every queued `chat.send` reply to its originating Gateway admission, so a late answer never goes out through a later same-session dispatcher.
- openclaw#129001 added `createSourceRetry`, which gives a front-requeued run of the same source a fresh owner, and the `pending` state: a source that never handed its request to the queue keeps its own terminal, so a finished run gets no duplicate or late reply.
- The recovery run inherited the stalled turn's still-`pending` owner, so its answer was dropped (`terminal-not-recorded`).

The fix:

- **The stalled turn hands its request to the recovery through the source's existing `createSourceRetry`.** A `pending` source that hands off is settled, so the original can never deliver once the retry exists, and the recovery owns the only delivery. The relaxed `pending` case is reachable only through the stall continuation, which runs after the stale watchdog aborted the source before any output. `createSourceRetry` has two callers:
  - the follow-up source retry in `followup-delivery.ts`, which only sees owners that already queued (`deliver`/`drop`);
  - the stall continuation.
- **The openclaw#161069 early return is narrowed.** Only a source that explicitly declares no owner (`drop`) keeps the notice.
- **Library authoring is not carried into the recovery.** Every authenticated Web UI human turn mints a library-authoring grant (`prepareGatewaySkillAuthoring`), and every run binds it at admission. By design (openclaw#134068) the grant refuses a replacement run, and the recovery is a new run, so it doesn't inherit the grant. Before this change the recovery failed with "Personal authoring cannot move to a replacement run" instead of answering.
  - Rule: a recovery run never inherits skill-library authoring. Whatever the original grant's target, the recovery gets an expired personal grant. The Workshop tool can't fall back to the workspace tool (`createSkillWorkshopTool`), and every call returns `AUTHORITY_EXPIRED` asking for a fresh message. All other tools stay available, and no access is widened.
  - Alternatives considered:
    - The existing per-run `conversationToolPolicy` replaces the configured group policy instead of adding to it, so using it as a deny list could widen access in group sessions.
    - Minting a fresh grant would relax openclaw#134068's replacement-run guard.

Hermes (sibling framework) returns its timeout result through each turn's own reply path on every surface. This PR follows that idea of one reply owner per source. Hermes has no auto-continuation to borrow.

### Group threads: left for a follow-up

Group-thread participant turns keep the notice. Participant reply options set `onQueuedFollowupReplyBatch: undefined` (openclaw#141411), which openclaw#116649's `in` check turns into a `drop` owner, so every queued participant reply is dropped. Omitting that key makes the recovery reach the group: in a qa-channel run the group got `STALLED-TURN-RECOVERED-OK` instead of the notice. The same run showed a second group message, arriving while the recovery ran, ending `skipped:reply-operation-active` with no reply. Participant reply options also clear `turnAdoptionLifecycle`, so a participant turn on a busy session never reaches queue policy (`allowGatewayQueueResolution` in `dispatch-from-config.lifecycle.ts`). Fixing that needs its own change to participant admission, so this PR doesn't enable group recovery.

## Bounded cost

- **Recovery runs at most once per stalled turn.** `continueStalledTurn` is armed only for direct turns and called once from the aborted-dispatch finisher. The recovery runs on the follow-up runner, which never arms it, so if the recovery also stalls the existing notice is sent and nothing else starts. Tested: "sends the Web UI notice, not a second recovery, when the recovery also stalls" (2 model turns total, empty queue).
- **One delivery per handed-off source.** After `createSourceRetry` from `pending`, the original owner is settled and refuses both delivery and further retries. Tested: "gives a pending source's only delivery to the retry it hands off to".
- **No recovery where its answer would be dropped.** Tested: "leaves the notice with a group-thread participant whose source declares no reply owner".
- **No wider tool access.** Tested: "never lets a personal/workspace-target recovery author skills while keeping its other tools". No tools are disabled.

## Evidence

- **Real Gateway `chat.send`.** A QA Gateway child, mock-openai with the stalled-turn fixture, `QA_DIAGNOSTIC_STUCK_SESSION_ABORT_MS=30000`, and an operator `GatewayClient` (TUI pattern) recording `chat` broadcasts:
  - Before (`80290b4`): `+56.4s state=error "⚠️ This turn was interrupted because it stopped making progress. Please try again."`, then `aborted`. 5 mock requests, none guided.
  - After: `+58.6s aborted` for the stalled run, then `+59.5s state=final` under the recovery's own run id with the recovered answer. 6 mock requests: 5 stalled, 1 guided success. The answer is persisted in `chat.history`.
  - An intermediate run without the authoring change: the recovery was delivered through the new owner but failed with the authoring error. That run is what found the issue.
- **Unit tests:**
  - The two Web UI tests in `agent-runner.stalled-turn.test.ts` fail on `main` (`continueStalledTurn` returned `false`) and pass now.
  - The owner, drop and authoring tests pass.
  - Wall times: `agent-runner.stalled-turn.test.ts` + `followup-delivery.test.ts`: 51 s (75 tests; plus `skill-workshop-tool.test.ts` 19 tests). `chat-send-late-followup.test.ts`: 2 s (6 tests).
- `node scripts/check-changed.mjs` passes (typecheck, lint, guards).
- **Head `c1bca05` (delivery path unchanged since):** the stalled run ends `aborted` at +59.1s, then `state=final` with the recovered answer under the recovery's run id at +60.1s. 6 mock requests, 1 guided. The answer is persisted in `chat.history`.

LOC vs `origin/main`: production +36/−6, tests +130/−5, docs +1/−1.

Co-authored-by: Ayaan Zaidi <[email protected]>
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 2, 2026
…#162713)

## What Problem This Solves

Fixes: when a Web UI (`chat.send`) turn stalls, and the automatic recovery from openclaw#162490 also stalls, the user gets neither an answer nor the "stopped making progress" notice. The chat just shows the run as aborted.

## User Impact

In that double-stall case, Web UI users see the same "⚠️ This turn was interrupted because it stopped making progress. Please try again." error they got before openclaw#162490. A user's own cancel stays silent, and channel delivery is unchanged.

## Why This Change Was Made

openclaw#161069 and openclaw#162490 promise one last-resort notice if the recovery run also stalls. `followup-delivery.ts` builds that notice payload. The follow-up runner, though, reported the watchdog-aborted run to its source owner as `completion: aborted`, the same as a user cancel. The `chat.send` finalizer (`chat-send-source-finalization.ts`) correctly hides final payloads for aborted runs and emits a bare `aborted` event, so the notice was dropped. The openclaw#162490 test missed this because it mocked the finalizer as "delivered".

The follow-up runner owns the completion it reports, so the fix is there. A stall-recovery run whose operation the watchdog stalled before any output now completes as `failed`, with the notice as its error. The Gateway already sends that through its terminal error contract (`state: "error"`), the same way the original stalled turn did before openclaw#162490. Other aborted follow-ups, including user cancels (`aborted_by_user`), still classify as `aborted` and stay silent. This change adds no new message: it restores the existing notice on the one surface that lost it.

Hermes (sibling framework) handles an inactivity timeout the same way: it returns a failed run result with diagnostic text through the turn's own reply path, never a silent cancel.

## Bounded cost

No new model calls or runs. This only changes how an already-finished recovery run is classified. Recovery still happens at most once per stalled turn; the existing test covers this (2 model turns, empty queue).

## Evidence

- `agent-runner.stalled-turn.test.ts` "sends the Web UI notice, not a second recovery, when the recovery also stalls" now drives the real `createChatSendLateReplyFinalizer`, with a real Gateway request context, and asserts the `chat` event it broadcasts.
  - On `main` it fails: `state: "aborted"`, no notice.
  - With the fix it passes: one `state: "error"` event whose `errorMessage` is the notice.
- **Live model, real Gateway `chat.send` client.** A local proxy sits in front of the real OpenAI API (`gpt-6-astra`), and an operator WebSocket client (the TUI's `GatewayClient`) sends "What is 17*23? Reply with just the number." and records the `chat` events. A live model can't be made to stall, so the proxy reproduces the stall shape for the question's requests (4 failing requests, then held open until the abort) for both the original turn and its recovery. QA stuck-session bound: 30 s.
  - **Before (`origin/main` 02f46a6):** two stuck aborts (ages 48 s and 59 s). The client receives `aborted` for the original run at +56.7 s, then `aborted` for the recovery run at +116.8 s. No notice and no answer.
  - **After (head `823a966`):** same two stuck aborts (ages 49 s and 59 s). The client receives `aborted` for the original run at +56.7 s, then `state: "error"` with "⚠️ This turn was interrupted because it stopped making progress. Please try again." for the recovery run at +116.7 s.
  - Telegram isn't affected: channel follow-ups route the notice payload directly, and this change only alters the completion reported to a source owner.
- Wall time: `pnpm test src/auto-reply/reply/agent-runner.stalled-turn.test.ts --maxWorkers=1` takes 39.6 s real, 36.0 s Vitest duration (60% transform, 30% tests) for 12 tests. The file's whole suite runs the real `runReplyAgent` with a SQLite transcript. This defect only shows at the boundary between the follow-up runner's completion and the chat.send finalizer, so a cheaper unit test of either side alone (the old mocked finalizer) missed it.
- Sibling suites pass: `followup-runner`, `followup-delivery`, `chat-send-late-followup`, and `server.chat-queued-followup` (real Gateway WebSocket), 104 tests.
- `node scripts/check-changed.mjs` passes.

Optional cleanup of the expired-personal-grant stub was skipped; it would grow the diff.

No new user-visible messages: this restores the existing notice on the one surface that lost it, and user cancels stay silent.

LOC vs `origin/main`: production +11/−1, tests +26/−10.

No overlap with Pash/Sarah changes on the touched files.

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

Labels

docs Improvements or additions to documentation gateway Gateway runtime P1 High-priority user-facing bug, regression, or broken workflow. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: S 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