Skip to content

fix(agents): name Gateway storage failures in run-failure copy - #139409

Merged
steipete merged 2 commits into
mainfrom
codex/team-db-locked-run-failure
Sep 5, 2026
Merged

steipete merged 2 commits into
mainfrom
codex/team-db-locked-run-failure

Conversation

@steipete

@steipete steipete commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

Problem

Chat runs ending with an internal SQLite error displayed only ⚠️ Agent run failed (model: …)., leaving operators without a cause or next step. The persisted assistant error could contain database is locked with empty content and no error code, while both the live failure copy and history projection hid that diagnosis.

Solution

Classify native SQLite codes before runtime errors are flattened, and recognize exact known SQLite messages in legacy assistant rows. Render fixed storage guidance through the shared failure-copy owner so the chat banner, persisted-row display projection, and lifecycle log name the same failure. Preserve the existing redacted raw-error preview and keep arbitrary provider bodies out of the user-facing copy.

Recognized storage failures terminate without automatic run replay or provider credential rotation. Consolidate the existing repetitive runtime-copy branches into a lookup without changing their wording or precedence. This PR does not change database schema, writer ownership, busy timeouts, or configuration.

Impact

Operators now see the storage cause and an actionable next step for busy/locked, full, read-only, I/O, and transcript writer ownership failures. The existing banner's Details control reveals the full guidance when the summary is truncated. Existing recorded error rows gain the same display guidance without rewriting transcript bytes.

Production LOC: +102 −73 (net +29). The +29 exception to the neutral-LOC budget is explicitly approved: this adds a new Gateway storage failure classification that reaches the banner, persisted-row projection, and lifecycle log. Consolidating the existing runtime-copy branches partially funds it (the formatter is net −38 lines); the remaining growth carries the classification and typed error through those boundaries. Tests: +121 −2 (net +119). Docs: +19 −0.

Evidence

  • Before the fix, the four new SQLite copy cases failed with the original generic model-failure text; 12 existing cases passed.
  • node scripts/run-vitest.mjs src/agents/failover src/agents/embedded-agent-runner/run/assistant-failure src/gateway/chat-display-projection ui/src/pages/chat/chat-gateway src/agents/embedded-agent-subscribe.handlers.lifecycle.test.ts src/agents/embedded-agent-helpers/error-text src/llm/stream.sync-host.test.ts — 345 passing test executions across six shards.
  • node scripts/run-vitest.mjs src/agents/failover/*.test.ts src/gateway/chat-display-projection.provider-owner.test.ts — 882 passing test executions across three shards. Explicit file expansion covers failover tests skipped by the directory filter above.
  • node scripts/check-changed.mjs — passed, including core/test typechecking, formatting, lint, and repository guards.
  • pnpm docs:list and git diff --check — passed.
  • Codex autoreview through P2 — scoped-clean, no accepted/actionable findings.
  • Synthetic mock chat error events, viewport 1100×720, light mode, device scale 2; inspected before/after captures below. No live Gateway validation was performed.
Before After (Details expanded)
Generic run failure before Specific Gateway storage failure after

Follow-up: reclamation lock cycle

An isolated probe reproduced a synchronous transcript append failing with database is locked at the existing 5000 ms busy timeout.
The owner chain is session-manager-persistence.ts → synchronous transcript append → canonical writer, competing with session-accessor.sqlite-archive.worker.ts → reclamation → session-accessor.sqlite-reclamation-commit.ts.
Reclamation holds BEGIN IMMEDIATE while waiting for main-thread commit authorization; the synchronous append blocks that main thread waiting for the same write lock.
The append failed, then reclamation reported expired commit authorization; this proves a reachable cycle, not attribution of historical runs or a large-database checkpoint failure.
Reclamation also performs separate post-commit truncating checkpoints and unbounded incremental vacuum, which need bounded maintenance ownership.
The proposed design keeps archive preparation off-thread but commits reclamation through the existing canonical writer with synchronous authority validation and bounded page maintenance.
That persistent-store concurrency change requires explicit maintainer approval, including a decision on bounded deletion latency, and is intentionally not implemented here.

Release-note: Show actionable Gateway storage failure reasons in chat run errors, recorded assistant error displays, and lifecycle logs without exposing provider response bodies.

@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.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation app: web-ui App: web-ui gateway Gateway runtime agents Agent runtime and tooling size: M maintainer Maintainer-authored PR labels Sep 5, 2026
@steipete

steipete commented Sep 5, 2026

Copy link
Copy Markdown
Contributor Author

@clawsweeper review

@clawsweeper

clawsweeper Bot commented Sep 5, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

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

clawsweeper Bot commented Sep 5, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 5, 2026, 6:48 PM ET / 22:48 UTC.

ClawSweeper review

What this changes

The PR adds specific Gateway storage-error guidance to live run failures, recorded chat errors, and logs, while preventing provider retries and credential rotation for recognized storage failures.

Merge readiness

✅ Ready for maintainer review

Keep open: the diagnostic gap remains on current main and the latest release, and the proposed repair has no identified blocking defect. The maintainer-authored PR is also protected from automated closure.

Priority: P2
Reviewed head: dcae326bbb70e883cb2a5d8e3ae086c2702a3da5

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused repair with useful regression coverage and no identified blocking correctness or security defect.
Proof confidence 🌊 off-meta tidepool Not applicable: The member-authored PR is exempt from the external-contributor proof gate. Its reported synthetic chat captures and inspected tests support presentation and classification, but do not establish an end-to-end Gateway storage-failure run.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The member-authored PR is exempt from the external-contributor proof gate. Its reported synthetic chat captures and inspected tests support presentation and classification, but do not establish an end-to-end Gateway storage-failure run.
Evidence reviewed 8 items Current main still lacks storage-specific copy: The fetched main revision retains generic unclassified run-failure text and has no storageFailure input in the shared copy renderer.
Latest release comparison: The same renderer in v2026.9.2 also lacks storage-specific guidance; the requested behavior is not established as shipped.
Bounded classification and fixed output: The classifier recognizes SQLite codes and exact known legacy messages. The shared renderer emits fixed guidance rather than interpolating arbitrary error bodies.
Findings None None.
Security None None.

How this fits together

OpenClaw converts agent runtime failures into operator-facing chat messages and lifecycle logs. This change carries recognized storage diagnostics through that conversion and uses the same guidance when displaying recorded assistant errors.

flowchart TD
  A[Runtime errors] --> C[Storage error classification]
  B[Recorded assistant errors] --> C
  C --> D{Recognized storage failure}
  D -->|Yes| E[Fixed recovery guidance]
  D -->|No| F[Existing error handling]
  E --> G[Chat display and lifecycle logs]
  D -->|Yes| H[Stop provider retries]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source +29, Tests +119, Docs +19. Total +167 across 15 files.

View PR surface stats
Area Files Added Removed Net
Source 7 102 73 +29
Tests 6 121 2 +119
Docs 2 19 0 +19
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 15 242 75 +167

Review metrics

None.

Technical review

Best possible solution:

Keep storage diagnosis in the shared failure-copy path, preserve transcript bytes and provider-body redaction, and handle the separate reclamation concurrency redesign independently.

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

Yes, from source: an empty assistant error containing database is locked reaches generic failure copy on main. The PR reports failing-before copy cases; this review did not execute a runtime reproduction.

Is this the best way to solve the issue?

Yes. Reusing the shared renderer and recognizing bounded storage facts repairs the diagnostic gap without adding configuration, rewriting stored transcripts, or redesigning database ownership.

AGENTS.md: found and applied where relevant.

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

Labels

Label justifications:

  • P2: This is a bounded improvement to diagnosing failed agent runs, without changing storage concurrency or schemas.
  • 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 member-authored PR is exempt from the external-contributor proof gate. Its reported synthetic chat captures and inspected tests support presentation and classification, but do not establish an end-to-end Gateway storage-failure run.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Raw commit a1e8a18 adds src/infra/sqlite-error-diagnostics.ts:6 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: a1e8a18bb197; files: src/infra/sqlite-error-diagnostics.ts)
  • Shakker: 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 (1 earlier review cycle)
  • reviewed 2026-09-05T21:41:23.127Z sha 48e387a :: needs maintainer review before merge. :: none

@steipete
steipete force-pushed the codex/team-db-locked-run-failure branch from 48e387a to dcae326 Compare September 5, 2026 22:29
@steipete

steipete commented Sep 5, 2026

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Sep 5, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@steipete
steipete merged commit c91b1ea into main Sep 5, 2026
183 checks passed
@steipete
steipete deleted the codex/team-db-locked-run-failure branch September 5, 2026 23:09
@steipete

steipete commented Sep 5, 2026

Copy link
Copy Markdown
Contributor Author

Merged via squash.

vincentkoc added a commit that referenced this pull request Sep 5, 2026
* origin/main: (95 commits)
  perf(build): avoid unrelated gateway artifact scans (#127757)
  fix(update): deliver terminal progress after long updates (#139289)
  fix(ui): show session hover cards for local chat URLs (#139384)
  perf(ui): reuse unchanged transcript key snapshots (#139400)
  fix(ui): make subagent sessions view-only (#139381)
  fix: open agent state on SQLite builds without extensions (#139487)
  perf(skills): detach cached metadata from source strings (#139478)
  fix(ui): show primary user in multi-agent profile hero (#136736)
  perf(sessions): stop decoding the session row four times per SQLite entry patch (#136361)
  refactor(exec): share package-manager option scans (#139482)
  fix(ci): authorize frozen mobile release candidates (#139441)
  fix: avoid session deletion slowdown in large session stores (#139467)
  perf(gateway): reuse node invocation idle timers (#139354)
  fix(auth): preserve selected profiles across plugin scopes (#139413)
  fix(discord): retain voice input until transcription completes (#139484)
  fix(agents): name Gateway storage failures in run-failure copy (#139409)
  fix: keep subagent checks responsive in large session stores (#139450)
  fix(memory): index notes when optional embeddings cannot start (#139463)
  fix: refresh pending approvals when reopening chat (#139457)
  fix(tooling): preserve Git hook choices during install (#139461)
  ...
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 6, 2026
…law#139409)

* fix(agents): name Gateway storage failures in run-failure copy

* test(agents): follow failover controller after rebase
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling 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: M status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant