Skip to content

fix(gateway): retain timeout notices after chat reload - #142135

Merged
obviyus merged 5 commits into
openclaw:mainfrom
chelsealong:fix/141839-timeout-run-failure-notice
Sep 8, 2026
Merged

obviyus merged 5 commits into
openclaw:mainfrom
chelsealong:fix/141839-timeout-run-failure-notice

Conversation

@chelsealong

@chelsealong chelsealong commented Sep 8, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #141839.

What Problem This Solves

A Gateway deadline could end a turn before any reply without leaving a durable notice. History reload then hid the failed turn, and later context could contain consecutive user requests with no explanation.

Use the existing failure-report writer for normalized timeout/failure outcomes on both terminal phases. Preserve its explicitly displayed custom records through history pages, cursor updates, reset navigation and archives. The notice truthfully says the turn ended before a reply.

Carry the admitted CLI writer's existing account context through terminal persistence. Finish accepted writes before normal admission close, recheck exact current ownership at commit, and revoke the context before another fallback candidate. Same-account continuation and supported missing-native-session recovery retain saved history; changed accounts still cannot read the former account's history.

Evidence

A real source Gateway and matching Control UI ran with a deterministic loopback provider and the existing Gateway deadline. Pinned main omitted the notice. The repaired build persisted one notice across the aborted end and execution-settled error, retained it after history/UI reload and Gateway restart, and delivered it to a later turn.

Actual chat.history notice from the corrected build, with private identifiers, timestamps and transcript-position metadata removed:

{
  "role": "custom",
  "customType": "run-failed-before-reply",
  "content": "This turn ended before a reply: Run timed out",
  "display": true
}

A second real comparison addressed the accepted same-CLI history regression. Both builds first saved a successful native CLI session, then hit a real no-output Gateway deadline. Neither comparison changed the backend or account. After the fixture reported the resumed native session missing:

Public result Prior published revision Corrected build
Later resume request Saved timeout note absent Saved timeout note present
Supported fresh-session recovery Refused because history coverage was lost Prior conversation and saved notice restored
agent.wait status error: session not found ok
Durable timeout notice count One for the timed-out run One for the timed-out run

The actual successful recovery result, with private run identity and timestamp removed:

{
  "status": "ok",
  "terminalReply": {
    "disposition": "visible",
    "text": "The fixture produced this fixed response independently of input."
  }
}

Provider input was inspected directly; the fixed response is not evidence of model recall. An independent source-blind operator repeated continuation, missing-session recovery, history/UI reload, same-connection cancellation, stale/repeated abort and changed-account exclusion. All supplemental probes passed. Complete raw captures and fixtures are retained privately for exact-head review; these public excerpts omit credentials, request data and infrastructure metadata.

Validation and limits

  • Original proof: 79 lifecycle, 54 history-reader and 119 terminal/abort tests passed; changed regressions failed on pinned main for the intended missing-notice/history behavior.
  • Correction: 46 owner/history tests, 368 command/channel/event sibling tests, and all 21 project-session tests passed. Formatting, focused lint and the proof runtime/UI builds passed.
  • Real partial output followed by timeout added no extra failure notice. Explicit cancellation stayed killed and added no timeout notice. Stale ownership and cross-account controls remained enforced.
  • Automatic active-run startup recovery of the synthetic fixture backend was unavailable; that separate route is not claimed. Supported missing-native-session recovery passed. The partial-output control does not claim durable partial-text preservation.
  • No transcript schema, configuration, second writer, account policy or timeout change. Source-only and universal lifecycle clauses retain their component/source evidence rather than being claimed as fully source-blind observations.

AI-assisted. Original contributor implementation and credit retained.

A hard run-timeout is delivered through the same AbortSignal machinery
as an explicit user cancel, so its terminal lifecycle event carries
aborted:true and can also land on the "end" phase rather than "error".
The pre-reply failure-notice gate required phase === "error" and
aborted !== true, so a deadline-killed turn with no assistant output
left the transcript untouched: the next turn saw two consecutive user
messages and no evidence the previous turn had ever run.

Widen the gate to cover both terminal phases and drop the aborted
exclusion; it added no coverage beyond the existing status check,
since deliberate cancellations already classify to session status
"killed" rather than "failed"/"timeout" and remain excluded.

Fixes openclaw#141839.
@clawsweeper

clawsweeper Bot commented Sep 8, 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: XS labels Sep 8, 2026
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. 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 Sep 8, 2026
@clawsweeper

clawsweeper Bot commented Sep 8, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge. Reviewed September 8, 2026, 2:35 PM ET / 18:35 UTC (Revision 5).

ClawSweeper review

What this changes

Preserves no-reply timeout notices across chat reloads and history navigation while retaining the admitted CLI account’s context until terminal writes finish.

Merge readiness

⛔ Blocked before merge - 1 item remains

This PR remains useful: current main still excludes aborted timeout notices and displayed custom reports from history. No blocking patch defect was found, and the supplied runtime evidence supports the repair.

Priority: P2
Reviewed head: 8eeecd4902f43a45c2328e481b7be6229a49364e

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A coherent repair with useful runtime evidence and focused boundary coverage; no actionable correctness or security finding remains.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (live_output): The captured body supplies real Gateway deadline and CLI recovery observations with copied history and wait results: one notice survives reload/restart and reaches later context, while cancellation, stale aborts, and changed-account access remain excluded. This exercises the changed lifecycle and history owners; raw private captures were not independently inspected.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (live_output): The captured body supplies real Gateway deadline and CLI recovery observations with copied history and wait results: one notice survives reload/restart and reaches later context, while cancellation, stale aborts, and changed-account access remain excluded. This exercises the changed lifecycle and history owners; raw private captures were not independently inspected.
Evidence reviewed 12 items Current-main gap: Fetched main still requires a non-aborted error phase before recording a failure report, excluding the reported aborted timeout path.
Main and release history visibility: Both fetched main and the supplied latest-release commit exclude custom_message records from the visible-record predicate. The central history repair is therefore still necessary.
Existing product contract: The chat documentation already promises a durable notice for turns failing before any reply; this patch repairs that existing behavior.
Findings None None.
Security None None.

How this fits together

The Gateway records terminal agent outcomes in session transcripts. History readers turn those records into chat messages, while CLI history ownership controls which saved context a later run may read.

flowchart TD
  A[Agent terminal event] --> B[Normalize run outcome]
  B --> C[Check current run authority]
  C --> D[Existing transcript report writer]
  D --> E[Session transcript]
  E --> F[Chat history and reload]
  E --> G[Account-scoped later context]
Loading

Before merge

  • Add data-model compatibility proof - Confirm migration or upgrade compatibility proof before merge.
Agent review details

Security

None.

PR surface

Source +204, Tests +472. Total +676 across 24 files.

View PR surface stats
Area Files Added Removed Net
Source 17 283 79 +204
Tests 7 601 129 +472
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 24 884 208 +676

Review metrics

Metric Value Why it matters
Production versus test growth Production net +204 lines; tests net +472 lines Production growth supports terminal-write ownership and consistent history projection; most added coverage exercises persistence, visibility, and isolation boundaries.

Stored data model

Persistent data-model change detected: unknown-data-model-change: src/gateway/server-runtime-subscriptions.ts. Confirm migration or upgrade compatibility proof before merge.

Root-cause cluster

Relationship: fixed_by_candidate
Canonical: #141839
Summary: This PR is a candidate repair for the reported missing timeout record; related partial-output work has additional scope.

Members:

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

Technical review

Best possible solution:

Keep one fenced failure-report writer and consistently expose its displayed records through history while preserving account-scoped continuation.

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

Yes: current source excludes aborted timeout terminal events and custom reports from visible history, and the PR supplies a real Gateway deadline comparison. This review did not execute the reproduction.

Is this the best way to solve the issue?

Yes: the patch extends the existing report owner and readers rather than introducing competing persistence. The prior migration request is unnecessary for this repair of an established display contract.

AGENTS.md: found and applied where relevant.

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

Labels

Label justifications:

  • P2: Repairs a bounded timeout-history defect that hides failed turns after reload and weakens subsequent context.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; 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. Sufficient (live_output): The captured body supplies real Gateway deadline and CLI recovery observations with copied history and wait results: one notice survives reload/restart and reaches later context, while cancellation, stale aborts, and changed-account access remain excluded. This exercises the changed lifecycle and history owners; raw private captures were not independently inspected.
  • proof: sufficient: Contributor real behavior proof is sufficient. The captured body supplies real Gateway deadline and CLI recovery observations with copied history and wait results: one notice survives reload/restart and reaches later context, while cancellation, stale aborts, and changed-account access remain excluded. This exercises the changed lifecycle and history owners; raw private captures were not independently inspected.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Raw commit c8d84ec adds src/sessions/session-run-error.ts:33 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: c8d84ec1b653; files: src/sessions/session-run-error.ts)
  • Vito Cappello: Raw commit e20b56c adds src/agents/cli-runner/history-boundary.ts:172 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: e20b56c0b26e; files: src/agents/cli-runner/history-boundary.ts)

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 (4 earlier review cycles)
  • reviewed 2026-09-08T11:47:41.967Z sha ab66cd5 :: needs real behavior proof before merge. :: none
  • reviewed 2026-09-08T16:50:14.404Z sha c53fa31 :: needs real behavior proof before merge. :: none
  • reviewed 2026-09-08T18:02:37.235Z sha 870169f :: blocked before merge. :: none
  • reviewed 2026-09-08T18:15:24.253Z sha ccdfcfd :: blocked before merge. :: none

@chelsealong

Copy link
Copy Markdown
Contributor Author

ClawSweeper's ask is for real-Gateway proof (an actual run-timeout deadline elapsing through the live pipeline, then a chat-history reload showing the notice), beyond the existing unit test that feeds synthetic lifecycle events straight into persistGatewaySessionLifecycleEvent.

I searched this checkout for that harness rather than fabricate output: there is no existing test that boots a real Gateway, drives a run through an actual timeout deadline via the real agent pipeline, and reads the transcript back through the public chat.send/chat.history (or WS) surface. The closest precedent (src/gateway/server.sessions.create-worktree-spawn.test.ts) does real-Gateway RPC readback, but for a worktree-prep failure, not a run-timeout. Building that harness from scratch is new test authoring, not evidence-gathering, so it's out of scope for this reply, and I haven't touched any code.

The review's own "Mantis proof suggestion" (a live Gateway deadline + chat reload capture) is the right way to get that tier of proof — that needs a maintainer to trigger @openclaw-mantis, since it requires live credentials/session capture this checkout doesn't have. I'm leaving the PR as-is rather than fake that evidence.

Use the existing failure-report owner for no-reply timeouts and retain
explicitly displayed custom reports through history pages, deltas and
archives. Preserve report identity, display ordering and private-detail
sanitization without changing transcript storage or writer authority.
@obviyus obviyus changed the title fix(gateway): report run-timeout kills that never reached a reply fix(gateway): retain timeout notices after chat reload Sep 8, 2026
@clawsweeper clawsweeper Bot added rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. labels Sep 8, 2026
Carry the prepared CLI writer context through terminal persistence and
revalidate its exact operational owner before commit. Drain accepted
writes before normal admission close, while explicit revocation and
fallback selection invalidate stale captures. Preserve same-account
continuation and native-session recovery without weakening account guards.
@openclaw-barnacle openclaw-barnacle Bot added agents Agent runtime and tooling size: XL triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence. and removed size: L triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence. labels Sep 8, 2026
@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. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Sep 8, 2026
Await terminal persistence on both optional session-resolution paths and
express command completion with explicit async cleanup. Keep CLI history
regressions with the existing failure-report tests within the current
Gateway test-root limit.
@obviyus

obviyus commented Sep 8, 2026

Copy link
Copy Markdown
Collaborator

landpr-approve-unrelated-red
pr: 142135
head: 8eeecd4
run: 34263352919 attempt: 1
failed: checks-windows-node-test-2 job=102186895355 conclusion=failure
check: openclaw/ci-gate

@obviyus
obviyus merged commit c9342d6 into openclaw:main Sep 8, 2026
206 of 208 checks passed
@obviyus

obviyus commented Sep 8, 2026

Copy link
Copy Markdown
Collaborator

Thanks @chelsealong!

Proof: A real Gateway deadline before any reply now leaves one notice that survives chat-history and Control UI reload. Actual same-account CLI requests retain the notice and recover a missing native session; changed-account and explicit-cancellation controls preserve their boundaries.

  • Bug: Mechanically aborted timeouts were excluded from the failure-report writer, and history readers hid displayed custom reports.
  • Fix: Reuse the existing guarded writer and history projections, carrying the admitted CLI writer context through terminal settlement.
  • Validation: Focused lifecycle/history/ownership tests, independent live behavior validation, exact-head review, and CI.
Before After
No durable explanation after a no-reply deadline One truthful timeout notice after reload
The intermediate repair lost same-account CLI history coverage Saved notes and supported native-session recovery remain available

AI-assisted. Original contributor credit retained.

CI exception: The completed run has one unrelated failure: checks-windows-node-test-2, preserves checkout ownership and fixture isolation (Linux=false, timeouts-exhausted) in test/scripts/ci-platform-checkout.test.ts. Its own mock Git parent was still visible at the exit boundary; final fixture cleanup completed. The aggregate gate reflects that failure.

The actual tested merge was 4cf2ceaf19bc164427f060bc9fb726f029e965da, based on main a92c15a5dc3710c0799320d07c35df862b074b0d. The failing fixture, workflow, census, dependencies, and tooling setup are unchanged from that main parent. It runs synthetic Git/process fixtures without OpenClaw runtime setup; none of this PR's Gateway changes runs in that path. Main-parent CI was cancelled before jobs, so it is not a matching reproduction. Independence was established from the actual executed fixture and its unchanged inputs, not from a passing retry.

The precise Windows teardown/census race and its introducing commit remain unverified. This is a separate CI follow-up. The guarded landing uses the recorded standing approval for this exact completed run; full CI is not claimed green.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 9, 2026
Fixes openclaw#141839.

## What Problem This Solves

A Gateway deadline could end a turn before any reply without leaving a durable notice. History reload then hid the failed turn, and later context could contain consecutive user requests with no explanation.

Use the existing failure-report writer for normalized timeout/failure outcomes on both terminal phases. Preserve its explicitly displayed custom records through history pages, cursor updates, reset navigation and archives. The notice truthfully says the turn ended before a reply.

Carry the admitted CLI writer's existing account context through terminal persistence. Finish accepted writes before normal admission close, recheck exact current ownership at commit, and revoke the context before another fallback candidate. Same-account continuation and supported missing-native-session recovery retain saved history; changed accounts still cannot read the former account's history.

## Evidence

A real source Gateway and matching Control UI ran with a deterministic loopback provider and the existing Gateway deadline. Pinned main omitted the notice. The repaired build persisted one notice across the aborted `end` and execution-settled `error`, retained it after history/UI reload and Gateway restart, and delivered it to a later turn.

Actual `chat.history` notice from the corrected build, with private identifiers, timestamps and transcript-position metadata removed:

```json
{
  "role": "custom",
  "customType": "run-failed-before-reply",
  "content": "This turn ended before a reply: Run timed out",
  "display": true
}
```

A second real comparison addressed the accepted same-CLI history regression. Both builds first saved a successful native CLI session, then hit a real no-output Gateway deadline. Neither comparison changed the backend or account. After the fixture reported the resumed native session missing:

| Public result | Prior published revision | Corrected build |
| --- | --- | --- |
| Later resume request | Saved timeout note absent | Saved timeout note present |
| Supported fresh-session recovery | Refused because history coverage was lost | Prior conversation and saved notice restored |
| `agent.wait` status | `error`: session not found | `ok` |
| Durable timeout notice count | One for the timed-out run | One for the timed-out run |

The actual successful recovery result, with private run identity and timestamp removed:

```json
{
  "status": "ok",
  "terminalReply": {
    "disposition": "visible",
    "text": "The fixture produced this fixed response independently of input."
  }
}
```

Provider input was inspected directly; the fixed response is not evidence of model recall. An independent source-blind operator repeated continuation, missing-session recovery, history/UI reload, same-connection cancellation, stale/repeated abort and changed-account exclusion. All supplemental probes passed. Complete raw captures and fixtures are retained privately for exact-head review; these public excerpts omit credentials, request data and infrastructure metadata.

## Validation and limits

- Original proof: 79 lifecycle, 54 history-reader and 119 terminal/abort tests passed; changed regressions failed on pinned main for the intended missing-notice/history behavior.
- Correction: 46 owner/history tests, 368 command/channel/event sibling tests, and all 21 project-session tests passed. Formatting, focused lint and the proof runtime/UI builds passed.
- Real partial output followed by timeout added no extra failure notice. Explicit cancellation stayed killed and added no timeout notice. Stale ownership and cross-account controls remained enforced.
- Automatic active-run startup recovery of the synthetic fixture backend was unavailable; that separate route is not claimed. Supported missing-native-session recovery passed. The partial-output control does not claim durable partial-text preservation.
- No transcript schema, configuration, second writer, account policy or timeout change. Source-only and universal lifecycle clauses retain their component/source evidence rather than being claimed as fully source-blind observations.

AI-assisted. Original contributor implementation and credit retained.

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

agents Agent runtime and tooling gateway Gateway runtime P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: XL 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.

[Bug]: a turn killed by the run deadline leaves no assistant record in the session transcript

2 participants