Skip to content

fix(gateway): record a transcript notice when a run fails before replying - #139439

Merged
steipete merged 2 commits into
mainfrom
fix/durable-pre-reply-run-failure
Sep 6, 2026
Merged

steipete merged 2 commits into
mainfrom
fix/durable-pre-reply-run-failure

Conversation

@steipete

@steipete steipete commented Sep 5, 2026 •

Copy link
Copy Markdown
Contributor

Problem

Fixes an issue where a Control UI turn that fails before any assistant output leaves no durable outcome in the thread. A cloud runner rejection updates transient error state, but the thread can look unanswered after reload or later activity.

Root cause

Terminal session state and transcript history had separate coverage. Native lifecycle errors and fallback dispatch rejection updated the session row without a notice. Restart-safe dispatch settlement committed its diagnostic and claim state directly. Fallback finalization could also defer the failed user input until after terminal persistence.

Change

One report writer in the lifecycle persistence module records a displayed run-failed-before-reply custom message after an accepted failed terminal commit. Native lifecycle persistence and restart-safe settlement both call it. The latter retains its existing atomic diagnostic/claim write; it does not perform a competing lifecycle update. If notice persistence fails after restart-safe settlement, the failure is logged and the already-committed settlement remains successful.

Fallback dispatch finalization persists its deferred user input before lifecycle persistence, so history and subsequent model context receive the input before its failure notice. The active-run check still occurs after awaited work.

The report appender retains assistant run ownership during its existing traversal and suppresses the notice if any assistant message on the active branch already carries that run ID, including assistant error messages. Deduplication uses the latest report's details.runId in the same write transaction. The existing full traversal is explicitly accepted for qualifying errors only; no second transcript scan, schema, index, or retry policy is added.

Impact

Failed pre-reply turns leave This turn did not run: <error>. in the thread, with a sanitized/redacted error bounded to 512 characters. Aborts, existing assistant errors, lastRunError, and banners retain their prior behavior. The Control UI uses its existing neutral custom-report rendering, matching historical workspace recovery failures.

Custom reports intentionally retain existing model-history behavior: the embedded harness converts them to user-role context, making the bounded failure available on the next turn. This change does not set excludeFromContext or alter filtering. See packages/agent-core/src/harness/session/session.ts and packages/agent-core/src/harness/messages.ts.

Evidence

Rebased onto 984d417f807736a556aaf2299fcb379d084d5f3e after main introduced a documentation conflict. Both main's activity-row paragraph and this PR's failure-notice sentence were preserved. All eight production/test files are byte-identical to the previously CI-green repair. The required focused suites were rerun after rebase:

 Test Files  3 passed (3)
      Tests  63 passed (63)
   Start at  16:05:51
   Duration  178.43s (transform 83%, import 7%, tests 6%, worker 4%)

Fresh rebased-branch autoreview:

autoreview scoped-clean: no accepted/actionable findings in the selected Git scope and priority
overall: patch is correct (0.87)
No actionable P0–P2 defects were established from the supplied evidence. Fallback persistence now precedes failure reporting, restart-safe report errors preserve committed settlement success, and report writes retain lifecycle fencing and active-branch assistant suppression. Review was static; no project code was executed.

The initial owner regression failed because no report was persisted. Dispatch-level regressions then reproduced both ClawSweeper findings on head 473d4ba0ff08dd3e4e206618a9873692b0deac16: fallback history placed the report before its input, and restart-safe history omitted the report. Both findings are addressed in this revision.

Pre-rebase focused proof (exit 0; production/test files unchanged by rebase):

node scripts/run-vitest.mjs src/gateway/session-lifecycle-run-failure.test.ts src/gateway/session-lifecycle-state.test.ts src/gateway/server-methods/chat-send-dispatch-errors.test.ts
Test Files  3 passed (3)
      Tests  63 passed (63)
   Start at  15:26:17
   Duration  59.11s (transform 57%, tests 25%, import 13%, worker 4%)

[vitest-workers] verifying completed generation before cleanup

node scripts/check-changed.mjs exited 0 on the pre-rebase repair. Final output:

[check:changed] runtime sidecar loader guard
$ node --import ./scripts/tsx.mjs scripts/check-runtime-sidecar-loaders.mts
runtime-sidecar-loaders: local runtime sidecar loaders look OK.

[check:changed] runtime import cycles
$ node --import ./scripts/tsx.mjs scripts/check-import-cycles.ts
Import cycle check: 0 runtime value cycle(s).

[check:changed] webhook body guard
$ node --import ./scripts/tsx.mjs scripts/check-webhook-auth-body-order.mts

[check:changed] pairing store guard
$ node --import ./scripts/tsx.mjs scripts/check-no-pairing-store-group-auth.mts

[check:changed] pairing account guard
$ node --import ./scripts/tsx.mjs scripts/check-pairing-account-scope.mts

Fresh independent Codex autoreview, P0–P2 (exit 0):

autoreview scoped-clean: no accepted/actionable findings in the selected Git scope and priority
overall: patch is correct (0.88)
The provided patch addresses both dispatch paths: fallback input persistence precedes failure reporting, and restart-safe settlement uses the shared report writer after its atomic terminal commit while containing report failures. No remaining P0–P2 correctness or concrete security defects are established by the supplied evidence. Tests were reviewed but not executed.

The unchanged custom-report UI rendering was also verified with six mocked Control UI E2E tests and inspected synthetic before/after captures. The new backend regressions verify the actual SQLite transcript order through dispatch finalization, retry-identity retention/cleanup, duplicate suppression, and the committed-settlement result after report failure.

Screenshots

Captures remain local as requested; no upload was performed.

  • Before: /var/folders/gl/hry704r5567fbcvp_mzdpg3m0000gn/T/pr-b-durable-run-failure-6dXDF0/before-no-reply.png
  • After: /var/folders/gl/hry704r5567fbcvp_mzdpg3m0000gn/T/pr-b-durable-run-failure-6dXDF0/after-durable-notice.png

Docs

docs/web/control-ui.md states that a turn failing before any reply leaves a durable notice in the thread.

@clawsweeper

clawsweeper Bot commented Sep 5, 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 docs Improvements or additions to documentation app: web-ui App: web-ui gateway Gateway runtime size: M maintainer Maintainer-authored PR labels Sep 5, 2026
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Sep 5, 2026
@clawsweeper

clawsweeper Bot commented Sep 5, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge. Reviewed September 5, 2026, 9:41 PM ET / September 6, 2026, 01:41 UTC.

ClawSweeper review

What this changes

Records a bounded, redacted transcript notice when a run fails before replying, preserving the failed input’s order and covering restart-safe dispatch.

Merge readiness

⛔ Blocked before merge - 1 item remains

The fix remains useful: current main and v2026.9.2 lack this durable failure notice. Both earlier findings are addressed, and the supplied compatibility evidence is supported by the shipped readers. No blocking defect was established.

Priority: P2
Reviewed head: f8df3d56ed208a0cec57a961291ac8163a99a8a7

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused repair with meaningful persistence regressions, resolved prior findings, and supported shipped-reader compatibility.
Proof confidence 🌊 off-meta tidepool Not applicable: The supplied MEMBER author classification exempts this PR from the external-contributor proof gate. SQLite lifecycle/dispatch regressions and mocked UI reload checks support the changed path; no live Gateway run or local screenshot inspection is claimed.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The supplied MEMBER author classification exempts this PR from the external-contributor proof gate. SQLite lifecycle/dispatch regressions and mocked UI reload checks support the changed path; no live Gateway run or local screenshot inspection is claimed.
Evidence reviewed 8 items Pinned implementation: The shared writer bounds and redacts errors, deduplicates by run, and preserves the lifecycle commit assertion; accepted terminal failures pass the persisted session identity and lifecycle revision into the report append.
Earlier ordering finding resolved: Fallback finalization now awaits deferred user-input persistence before checking active runs and recording terminal failure. Restart-safe admission already persists its input in chat-send-handler.ts before dispatch.
Earlier restart-safe finding resolved: Restart-safe settlement invokes the shared notice writer after its existing terminal commit and catches notice failures without reporting the committed settlement as unsuccessful.
Findings None None.
Security None None.

How this fits together

The Gateway turns agent lifecycle and dispatch outcomes into session state and transcript history. These transcripts feed Control UI chat history and subsequent model context.

flowchart TD
  A[Chat input] --> B[Run or dispatch failure]
  B --> C[Commit terminal session state]
  C --> D[Check current transcript ownership]
  D --> E[Check assistant output and duplicate notice]
  E --> F[Append bounded failure notice]
  F --> G[Chat history and model 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 +104, Tests +379, Docs +2. Total +485 across 9 files.

View PR surface stats
Area Files Added Removed Net
Source 4 115 11 +104
Tests 4 412 33 +379
Docs 1 2 0 +2
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 9 529 44 +485

Review metrics

Metric Value Why it matters
Persisted-format compatibility 1 new custom report type; 3 shipped readers unchanged The existing extensible representation supports the notice without a schema migration or reader upgrade.

Stored data model

Persistent data-model change detected: serialized state: src/gateway/server-methods/chat-restart-recovery.ts, unknown-data-model-change: src/gateway/server-methods/chat-restart-recovery.ts. Confirm migration or upgrade compatibility proof before merge.

Technical review

Best possible solution:

Keep failure reporting in the lifecycle owners and reuse the existing fenced custom-report format, preserving input order and established model-history semantics.

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

Yes, from source: a pre-reply dispatch rejection updates terminal session state without appending a transcript outcome on current main. This review did not execute that path.

Is this the best way to solve the issue?

Yes. Reusing the existing report appender addresses both lifecycle owners without a parallel store, and the shipped-reader comparison resolves the earlier migration concern.

AGENTS.md: found and applied where relevant.

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

Labels

Label justifications:

  • P2: Repairs missing durable outcomes for failed chat turns with a bounded change to transcript persistence.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: The supplied MEMBER author classification exempts this PR from the external-contributor proof gate. SQLite lifecycle/dispatch regressions and mocked UI reload checks support the changed path; no live Gateway run or local screenshot inspection is claimed.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Raw commit 118ff47 adds src/config/sessions/session-accessor.sqlite-transcript-reports.ts:174 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 118ff477a198; files: src/config/sessions/session-accessor.sqlite-transcript-reports.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 (5 earlier review cycles)
  • reviewed 2026-09-05T22:09:32.051Z sha 473d4ba :: blocked before merge. :: [P2] Append the notice after the rejected run's user turn | [P2] Record notices for restart-safe dispatch failures too
  • reviewed 2026-09-05T22:50:04.670Z sha 0809b12 :: blocked before merge. :: none
  • reviewed 2026-09-05T23:15:49.407Z sha 159edd9 :: blocked before merge. :: none
  • reviewed 2026-09-05T23:22:37.888Z sha 159edd9 :: blocked before merge. :: none
  • reviewed 2026-09-06T00:54:55.514Z sha 84ea17c417487e7a1874055092dc82e7b596b509 :: blocked before merge. :: none

@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: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Sep 5, 2026
@steipete

steipete commented Sep 5, 2026

Copy link
Copy Markdown
Contributor Author

Compatibility evidence for the remaining data-model check on 0809b12df1ae2f3b16801c046e662222c0382c8b:

This PR adds a new value of the existing generic custom_message.customType string. It does not change the transcript version, schema/index definitions, or existing serialized session fields. In chat-restart-recovery.ts, the diagnostic/claim patch remains unchanged; the additional operation runs after that commit and appends the existing custom-message representation. No migration or backfill is required.

The relevant readers in this head are byte-identical to the shipped v2026.9.2 readers:

Reader Git blob in both versions
src/config/sessions/session-entry-codec.ts fa95be34eb4cf2a847cb617990fd0accb580f3d5
packages/agent-core/src/harness/session/session.ts 66829a70e76110d4d7faa273e5c98515940147fe
packages/agent-core/src/harness/messages.ts bd8fa1090c137c728e66da3011c4c5409e0602e9

I executed a synthetic run-failed-before-reply record through those readers. The codec accepted it without dropping display or details; the existing model projection converted it to the same user-role text context as other custom reports:

PASS: shipped-identical codec accepts the new custom type and preserves display/details.
PASS: shipped-identical context projection preserves existing user-role model-history semantics.

The PR-relative diff is empty for src/state, src/config/sessions/version.ts, and the three reader files above. The real-SQLite owner and dispatch tests also pass, including readback and deduplication of the report. This establishes compatibility of the added persisted record with the shipped reader; it is not a claim that a full cross-version live installation test was run. The automatic unknown-data-model-change flag does not require a schema migration for this change.

@steipete
steipete force-pushed the fix/durable-pre-reply-run-failure branch from 0809b12 to 159edd9 Compare September 5, 2026 23:09
@steipete
steipete force-pushed the fix/durable-pre-reply-run-failure branch from 159edd9 to 84ea17c Compare September 6, 2026 00:49
@steipete
steipete force-pushed the fix/durable-pre-reply-run-failure branch from 84ea17c to f8df3d5 Compare September 6, 2026 01:35
@steipete
steipete merged commit 2a77ac9 into main Sep 6, 2026
183 checks passed
@steipete
steipete deleted the fix/durable-pre-reply-run-failure branch September 6, 2026 02:00
@steipete

steipete commented Sep 6, 2026

Copy link
Copy Markdown
Contributor Author

Merged via squash.

vincentkoc added a commit that referenced this pull request Sep 6, 2026
* origin/main:
  fix(cli): keep note text with Windows and Unicode line endings (#139512)
  fix(agents): keep isolated completion context on its admitted generation (#139607)
  fix: avoid declaration builds during source-server updates (#139392)
  fix(models): keep discovered models after catalog refresh failures (#139357)
  fix(gateway): record a transcript notice when a run fails before replying (#139439)
  refactor(ios): reuse shared integer conversion (#139581)
  fix(sessions): prevent database lock failures during reclamation (#139469)
  perf(test): reuse transforms within owned scheduler slots (#139553)
  test(agents): share sparse transcript input fixtures (#139589)
  chore(ui): refresh control ui locales (#139481)
  fix(slack): keep prototype-named emoji shortcodes intact (#136374)
  fix(gateway): deliver upgrade rejection responses under Bun (#139516)
  refactor(test): simplify catalog guards and fix native report fixture (#139496)
  fix(macos): prevent dashboard fixture loopback timeouts (#139556)
  fix(matrix): preserve selected reply targets inside threads (#139479)
vincentkoc added a commit to ylcn91/openclaw that referenced this pull request Sep 6, 2026
* commit '6c55a99226ed0611ca088004c81b00fb296f1f71': (182 commits)
  test(ui): scope dashboard settings setup to the top frame (openclaw#139618)
  refactor(skills): share pending proposal creation (openclaw#139617)
  fix(release): accept frozen targets before worker bundles (openclaw#136699)
  fix(gateway): preserve percent sequences in media filenames (openclaw#139508)
  fix: preserve current update availability alongside update history (openclaw#139501)
  feat(diagnostics): expose garbage collection duration metrics (openclaw#139592)
  fix(ui): keep Logbook timestamps clear of the activity stripe (openclaw#139539)
  fix(ui): keep Swarm outcomes visible after completion (openclaw#139490)
  test: check file accessibility without runtime-specific return values (openclaw#139590)
  refactor(sdk): keep helper types private (openclaw#139601)
  fix(cron): preserve current-session delivery intent (openclaw#139491)
  fix: prevent browser profile permission hangs in Doctor (openclaw#139612)
  fix(agents): repair storage-failure test fixture after failover owner move (openclaw#139531)
  fix(cli): keep note text with Windows and Unicode line endings (openclaw#139512)
  fix(agents): keep isolated completion context on its admitted generation (openclaw#139607)
  fix: avoid declaration builds during source-server updates (openclaw#139392)
  fix(models): keep discovered models after catalog refresh failures (openclaw#139357)
  fix(gateway): record a transcript notice when a run fails before replying (openclaw#139439)
  refactor(ios): reuse shared integer conversion (openclaw#139581)
  fix(sessions): prevent database lock failures during reclamation (openclaw#139469)
  ...
vincentkoc added a commit that referenced this pull request Sep 6, 2026
* commit 'refs/openclaw/tasks/pr-135167-main-latest':
  test(ui): scope dashboard settings setup to the top frame (#139618)
  refactor(skills): share pending proposal creation (#139617)
  fix(release): accept frozen targets before worker bundles (#136699)
  fix(gateway): preserve percent sequences in media filenames (#139508)
  fix: preserve current update availability alongside update history (#139501)
  feat(diagnostics): expose garbage collection duration metrics (#139592)
  fix(ui): keep Logbook timestamps clear of the activity stripe (#139539)
  fix(ui): keep Swarm outcomes visible after completion (#139490)
  test: check file accessibility without runtime-specific return values (#139590)
  refactor(sdk): keep helper types private (#139601)
  fix(cron): preserve current-session delivery intent (#139491)
  fix: prevent browser profile permission hangs in Doctor (#139612)
  fix(agents): repair storage-failure test fixture after failover owner move (#139531)
  fix(cli): keep note text with Windows and Unicode line endings (#139512)
  fix(agents): keep isolated completion context on its admitted generation (#139607)
  fix: avoid declaration builds during source-server updates (#139392)
  fix(models): keep discovered models after catalog refresh failures (#139357)
  fix(gateway): record a transcript notice when a run fails before replying (#139439)
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 6, 2026
…ying (openclaw#139439)

* fix(gateway): record a transcript notice when a run fails before replying

* fix(gateway): cover dispatch settlement in failure notices
necromman pushed a commit to necromman/openclaw that referenced this pull request Sep 20, 2026
…ying (openclaw#139439)

* fix(gateway): record a transcript notice when a run fails before replying

* fix(gateway): cover dispatch settlement in failure notices

(cherry picked from commit 2a77ac9)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

app: web-ui App: web-ui docs Improvements or additions to documentation gateway Gateway runtime maintainer Maintainer-authored PR P2 Normal backlog priority with limited blast radius. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: L 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