Skip to content

fix(webchat): retain failed-turn diagnostics for debugging - #155378

Draft
freeqaz-openai wants to merge 4 commits into
mainfrom
fix/run-failure-diagnostics
Draft

freeqaz-openai wants to merge 4 commits into
mainfrom
fix/run-failure-diagnostics

Conversation

@freeqaz-openai

@freeqaz-openai freeqaz-openai commented Sep 22, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

A turn can fail before replying and save only the first 512 characters of its error, cutting off the cause. Expanding the UI cannot recover that discarded text. Sandbox startup failures also resolve through the agent runner's error-reply path, so logging only rejected chat.send calls misses their original exceptions.

User Impact

Failed turns retain up to 10,000 characters of redacted, multiline detail across history refreshes. The notice starts compact; Details expands it, Copy error copies the retained text, and Copy run ID provides the reference for operator log lookup.

Identical failures from different runs remain separate so each log reference stays accessible. Duplicate receipts from the same run retain their accessible ×N count. Card and context-menu copy actions use the same redacted display text.

Why This Change Was Made

One logging helper captures original errors at chat setup/dispatch catches and at terminal agent failure settlement. It preserves available native stacks and nested causes in the existing rotating logs, with a 100,000-character cap after redaction. Disabled logging skips the capture; logging failure cannot change turn settlement. Retry attempts and cancellation behavior are unchanged.

The existing Run ID correlates the notice with these records; it is separate from an OpenTelemetry trace ID. Logs follow existing access and retention settings, so retrieval is best effort. The 160-character session summary, history privacy filters, and explicit history request limits remain in place.

This improves failure diagnosis. It does not repair the underlying container/network failure or recover text discarded by an older version.

Evidence

  • Pinned formatter and git diff --check: passed.
  • Focused coverage now includes the actual executeAgentTurn sandbox failure path: a resolved failure reply, startup and cleanup causes, more than 10k of retained log detail, Run ID correlation, and redaction read back from the file logger. Serializer edge cases live in focused logging tests instead of being repeated across the settlement matrix.
  • UI regressions cover grouped duplicate counts, separate references for different runs, redacted clipboard output, disclosure, and the retained diagnostic after history refresh.
  • Consolidating repeated fixtures and assertions reduces net test growth from 411 to 347 lines and removes four redundant test-case executions; runtime savings are unmeasured.
  • Independent source review completed. The test-cleanup review's proposed missing Run ID assertion already exists in the history/live loop (session-transcript-message.test.ts:98); source readback resolved it without changes. Reviews did not execute tests or render the UI.

Executable validation remains blocked. A fresh pnpm install --frozen-lockfile still receives HTTP 403 for @openclaw/[email protected] from the configured dependency firewall. Focused tests and the changed-check planner stop at missing-dependency bootstrap. The tests above are authored coverage, not passing results. Typecheck, build, i18n verification, measured test timings, and inspected before/after UI screenshots remain outstanding. Main CI is skipped while this PR is a draft. The PR remains a draft until that evidence is available.

@clawsweeper

clawsweeper Bot commented Sep 22, 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: L maintainer Maintainer-authored PR labels Sep 22, 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: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Sep 22, 2026
@clawsweeper

clawsweeper Bot commented Sep 22, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge.

What this changes

The branch retains longer redacted failed-turn details, adds run-correlated error logging, and gives WebChat failure notices expandable details and copy actions.

Review scores

Measure Result What it means
Overall readiness 🦪 silver shellfish (2/6) The implementation is coherent and no discrete defect was found, but its disclosed execution and visual-proof gaps prevent merge readiness.
Proof confidence 🦪 silver shellfish (2/6) Real behavior proof is not required for maintainer- or bot-authored pull requests.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Merge readiness

⛔ Blocked before merge - 5 items remain

The central diagnostic-retention gap remains on current main, and this protected PR contains useful work. No definite introduced bug was found, but integration and required validation remain incomplete.

Priority: P2
Reviewed head: 5a4a5923953a2c8bfd8206dfdb988c9f4214bf73

Before merge

  • Resolve merge risk - Resolve the confirmed merge conflicts and review the integrated result while preserving current-main state-contention notices and failure-settlement safeguards.
  • Resolve merge risk - Verify existing stored failure receipts and newly retained multiline receipts across restart, history refresh, and continued session use before clearing persistence compatibility.
  • Resolve merge risk - Complete the disclosed focused checks, typecheck, build, i18n verification, and measured test-cost reporting on the integrated head.
  • Complete next step - Resolve the confirmed conflicts and submit the integrated head for review.
  • Add data-model compatibility proof - The review found that existing stored data may not work after upgrade. Show that existing data still loads and works with this change.

Findings

None.

Agent review details

How this fits together

Gateway failure settlement writes diagnostic receipts into session history and records errors in rotating logs. WebChat displays those receipts and exposes run IDs for operator log lookup.

flowchart TD
 A[Failed agent turn] --> B[Gateway failure settlement]
 B --> C[Redacted session receipt]
 B --> D[Redacted rotating logs]
 C --> E[History display projection]
 E --> F[WebChat error details]
 F --> G[Copy diagnostic or run ID]
Loading

Technical review

Best possible solution:

Extend the existing failure-receipt and logging owners while preserving current-main settlement safeguards, bounded history responses, and redacted copy output.

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

Yes, by source: current main truncates saved failure details at 512 characters, so a longer diagnostic loses its tail before WebChat can display it. No runtime reproduction was executed.

Is this the best way to solve the issue?

Yes, the existing receipt, display-projection, and logging owners are appropriate boundaries; integration and executed validation are still needed to establish the final result.

AGENTS.md: found and applied where relevant.

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

Merge-risk options

Maintainer options:

  1. Verify retained-receipt compatibility (recommended)
    Demonstrate that existing receipts and new longer receipts remain readable after restart without rewriting earlier transcript data.

Security

None.

Evidence

What I checked:

  • Introduced change identity: Reviewed the pinned merge-base-to-head production hunks; endpoint drift was not attributed to this PR. The origin remote identifies the target repository. (5a4a5923953a)
  • Current main still truncates diagnostics: Current main flattens whitespace and caps the saved failure error at 512 characters. Its newer state-contention presentation and write-assertion plumbing must be retained during conflict resolution. (src/sessions/session-run-error.ts:38, 27ba9720f2c5)
  • Persisted receipt boundary: The branch preserves the custom receipt type and runId/error fields while expanding retained text to 10,000 characters. Authored tests cover persistence, redaction, history projection, SSE, and explicit display limits, but do not establish executed existing-state compatibility. (src/sessions/session-run-error.ts:32, 5a4a5923953a)
  • Security and logging boundary: The logging helper uses the repository-owned diagnostic projector and file-log redactor before clipping, skips disabled logging, and catches logging failures. It introduces no new dependency source, permission, or authorization mechanism. (src/logging/run-error.ts:83, 5a4a5923953a)
  • Prior duplicate-count finding resolved: Historical failure cards now render the accessible duplicate badge outside the details disclosure; grouping distinguishes different run IDs. The corresponding authored regression checks two cards and one ×2 badge. (ui/src/pages/chat/components/chat-message-bubble.ts:229, 5a4a5923953a)
  • Live integration state: GitHub still reports the pinned head as draft, mergeable false, and mergeable_state dirty. No pinned test merge is available, so removal of current-main behavior was not inferred from branch differences. (5a4a5923953a)

PR surface

Source +221, Tests +347, Docs +18. Total +586 across 36 files.

View PR surface stats
Area Files Added Removed Net
Source 21 307 86 +221
Tests 14 408 61 +347
Docs 1 18 0 +18
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 36 733 147 +586

Review metrics

Metric Value Why it matters
Production versus test growth production +307/-86; tests +408/-61 Production growth supports shared logging and error-card owners; the net 347 added test lines still lack measured execution cost.

Labels

Label changes:

No label changes.

Label justifications:

  • P2: This improves diagnosis of failed turns without repairing an urgent runtime outage.
  • merge-risk: 🚨 compatibility: The persisted diagnostic-size change still lacks executed existing-state compatibility evidence.
  • rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦪 silver shellfish and patch quality is 🐚 platinum hermit.
  • status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action.

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Resolve conflicts while preserving current-main failure presentation and settlement safeguards.
  • Run focused failure, logging, history, and UI checks, including existing receipts after restart, and report measured test cost.
  • Attach inspected, sanitized before/after WebChat screenshots in the originating chat and PR.

Rating scale

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

Workflow

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

History

Review history (9 earlier review cycles; latest 8 shown)
  • reviewed 2026-09-22T03:09:56.228Z sha cf290a2 :: needs changes before merge. :: [P2] Preserve the count for collapsed failure notices
  • reviewed 2026-09-22T04:28:59.726Z sha 14e1450 :: needs changes before merge. :: none
  • reviewed 2026-09-22T04:49:31.724Z sha 07a1f53 :: needs changes before merge. :: none
  • reviewed 2026-09-22T04:57:53.907Z sha 5a4a592 :: needs changes before merge. :: none
  • reviewed 2026-09-26T02:03:44.265Z sha 5a4a592 :: blocked before merge. :: none
  • reviewed September 27, 2026, 6:22 AM ET / 10:22 UTC (Revision 7) sha unknown :: blocked before merge. :: none
  • reviewed September 27, 2026, 6:57 AM ET / 10:57 UTC (Revision 8) sha unknown :: blocked before merge. :: none
  • reviewed September 27, 2026, 6:57 AM ET / 10:57 UTC (Revision 9) sha unknown :: blocked before merge. :: none

Reviewed October 6, 2026, 10:50 PM ET / October 7, 2026, 02:50 UTC (Revision 10).

@clawsweeper clawsweeper Bot added rating: 🦞 diamond lobster Very strong PR readiness with only minor 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. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Sep 22, 2026
@clawsweeper clawsweeper Bot added rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. and removed rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. labels Sep 22, 2026
@clawsweeper clawsweeper Bot added rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. 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. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. labels Sep 27, 2026
@clawsweeper clawsweeper Bot added rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. 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. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. labels Oct 7, 2026
@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. and removed status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Oct 9, 2026

This branch has not been deployed

No deployments
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 merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P2 Normal backlog priority with limited blast radius. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. size: L status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant