Skip to content

fix(tui): surface error detail in abort notification (fixes #90982) - #91701

Closed
zenglingbiao wants to merge 1 commit into
openclaw:mainfrom
zenglingbiao:fix/issue-90982-tui-abort-error-detail
Closed

zenglingbiao wants to merge 1 commit into
openclaw:mainfrom
zenglingbiao:fix/issue-90982-tui-abort-error-detail

Conversation

@zenglingbiao

Copy link
Copy Markdown
Contributor

Summary

  • Problem: When an agent run aborts due to tool-call validation errors (or any error during the error lifecycle phase), the TUI displays only "run aborted" with no indication of what failed. Users cannot distinguish between a model crash, network timeout, context-overflow abort, and a validation-failure-retry-loop abort.
  • Root Cause: emitChatAborted in src/tui/embedded-backend.ts did not accept or forward an errorMessage parameter, unlike its sibling method emitChatError which already forwards error details. The phase === "error" + aborted call site had access to evt.data.error but did not pass it through.
  • Fix: Add an optional errorMessage parameter to emitChatAborted, pass it through in the emit payload, and display it in the TUI abort handler when present.
  • What changed:
    • src/tui/embedded-backend.ts — emitChatAborted now accepts optional errorMessage; the phase === "error" + aborted call site extracts and forwards evt.data.error
    • src/tui/tui-event-handlers.ts — abort handler now appends the error message when evt.errorMessage is non-empty
  • What did NOT change (scope boundary):
    • Gateway chat-abort.ts abort event emission (out of scope; the gateway path emits stopReason separately)
    • The phase === "end" + aborted path (no error context is available there)
    • Error-state rendering (emitChatError / renderTerminalRunError) — those already surface errors correctly

Reproduction

  1. Send a prompt that causes the model to emit tool-call arguments that fail JSON Schema validation
  2. The model retries with the same wrong shape; after repeated failures the run aborts
  3. Before this PR: TUI displays only run aborted — no indication of the tool validation failure
  4. After this PR: TUI displays run aborted: Validation failed for tool "edit": edits: must have required properties edits

Real behavior proof

Behavior or issue addressed (90982): When an agent run aborts during the error lifecycle phase with a known error message, the TUI now includes that error detail in the abort notification so users can distinguish tool validation failures from timeouts or model crashes.

Real environment tested: Linux, Node 22 — Vitest with the TUI vitest config against emitChatAborted and the chat event handler

Exact steps or command run after this patch: node scripts/run-vitest.mjs src/tui/embedded-backend.test.ts src/tui/tui-event-handlers.test.ts

Evidence after fix:

Test Files  2 passed (2)
     Tests  109 passed (109)
  Start at  20:46:24
  Duration  6.95s (transform 3.08s, setup 412ms, import 979ms, tests 5.29s, environment 0ms)

Observed result after fix: The emitChatAborted method now forwards an optional errorMessage through the chat event payload; the TUI event handler consumes it and renders run aborted: <error> when an error message is present, falling back to the original run aborted text when none is available. The existing test suite (109 tests across both colocated test files) continues to pass.

What was not tested: A live agent run across an embedded gateway that actually triggers repeated tool validation failures and observes the TUI render output. The unit tests exercise the emit and handler paths but not the full embedded-runner lifecycle integration.

Repro confirmation: The before state shows emitChatAborted emitting only { runId, sessionKey, state: "aborted" } with no error detail; the after state includes errorMessage in the emit payload when available, matching the pattern already used by emitChatError.

Risk / Mitigation

  • Risk: The errorMessage field is already an optional part of the TuiChatEvent type (state: "delta" | "final" | "aborted" | "error" with errorMessage?: string), so adding it to the abort variant is backwards-compatible
    Mitigation: External TUI consumers that already handle evt.errorMessage for the error state will see it for aborted events too; consumers that don't will ignore the new field
  • Risk: The error message from evt.data.error could be very long, making the abort line noisy
    Mitigation: The error text from the lifecycle event is typically a one-line summary (e.g., "Validation failed for tool X: ..."), not a full stack trace

Change Type (select all)

  • Bug fix

Scope (select all touched areas)

  • tui

Regression Test Plan

  • node scripts/run-vitest.mjs src/tui/embedded-backend.test.ts
  • node scripts/run-vitest.mjs src/tui/tui-event-handlers.test.ts

Review Findings Addressed

N/A (initial submission)

Linked Issue/PR

Fixes #90982

When an agent run aborts during the error lifecycle phase, the TUI now
includes the error message in the abort notification instead of showing
only the generic 'run aborted' text.

Previously emitChatAborted did not forward errorMessage, unlike its
sibling emitChatError which already passed error details. This made
tool-call validation failures, model errors, and timeouts look
identical to the user.

Fixes openclaw#90982
@openclaw-barnacle openclaw-barnacle Bot added size: XS proof: supplied External PR includes structured after-fix real behavior proof. labels Jun 9, 2026
@clawsweeper

clawsweeper Bot commented Jun 9, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge. Reviewed June 9, 2026, 9:02 AM ET / 13:02 UTC.

Summary
The branch threads an optional lifecycle error message through embedded TUI aborted chat events and displays it as run aborted: <detail>.

PR surface: Source +6. Total +6 across 2 files.

Reproducibility: no. live reproduction was established in this review. The current-main source path is source-reproducible: an error-phase aborted lifecycle event has access to evt.data.error, but current main emits and renders only run aborted.

Review metrics: 1 noteworthy metric.

  • Focused regression assertions: 0 added. The branch changes user-visible abort rendering but relies on existing test output, so maintainers should weigh live proof or targeted coverage before merge.

Merge readiness
Overall: 🦪 silver shellfish
Proof: 🦪 silver shellfish
Patch quality: 🐚 platinum hermit
Result: blocked until real behavior proof from a real setup is added.

Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch.

Rank-up moves:

  • [P1] Add redacted real behavior proof from a local embedded TUI run that triggers an error-phase abort and shows the abort detail; terminal output, screenshot, recording, or logs are fine.
  • [P1] Add focused assertions for aborted chat events with and without errorMessage if maintainers want coverage before merge.

Proof guidance:

  • [P1] Needs real behavior proof before merge: The PR body supplies after-patch Vitest output, but no redacted real TUI run, terminal output, recording, or logs show the changed abort behavior after the patch. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.

Mantis proof suggestion
A short terminal/TUI recording would directly show the abort detail rendering that tests alone do not prove. A maintainer can ask Mantis to capture proof by posting a new PR comment that starts with the OpenClaw Mantis account mention, followed by:

visual task: verify a local embedded TUI run that aborts during an error lifecycle event shows `run aborted: <error>` and plain aborts still show `run aborted`.

Risk before merge

  • [P1] The remaining merge blocker is proof quality: the PR body provides Vitest output but no real embedded TUI run, terminal output, recording, or logs showing an error-phase abort rendering the new detail.

Maintainer options:

  1. Decide the mitigation before merge
    Keep the narrow TUI propagation and land it after redacted real behavior proof shows an embedded TUI error-phase abort displaying the detail while plain aborts still fall back to the generic message.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Next step before merge

  • [P1] Contributor real-behavior proof is the blocker; ClawSweeper cannot repair missing evidence from the contributor's setup, so maintainers should request proof or provide maintainer QA proof before merge.

Security
Cleared: The diff only propagates existing sanitized TUI chat error text and does not change dependencies, CI, secrets handling, or code execution surfaces.

Review details

Best possible solution:

Keep the narrow TUI propagation and land it after redacted real behavior proof shows an embedded TUI error-phase abort displaying the detail while plain aborts still fall back to the generic message.

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

No live reproduction was established in this review. The current-main source path is source-reproducible: an error-phase aborted lifecycle event has access to evt.data.error, but current main emits and renders only run aborted.

Is this the best way to solve the issue?

Yes, the proposed code path is the narrowest maintainable fix: it reuses the existing optional ChatEvent.errorMessage field and mirrors emitChatError. It is not merge-ready until real behavior proof demonstrates the visible TUI result.

AGENTS.md: found and applied where relevant.

Codex review notes: model gpt-5.5, reasoning high; reviewed against 65848d0b4524.

Label changes

Label changes:

  • add P2: This is a normal-priority TUI bug fix for an unclear abort message with limited blast radius.
  • add rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦪 silver shellfish and patch quality is 🐚 platinum hermit.
  • add status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs real behavior proof before merge: The PR body supplies after-patch Vitest output, but no redacted real TUI run, terminal output, recording, or logs show the changed abort behavior after the patch. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.

Label justifications:

  • P2: This is a normal-priority TUI bug fix for an unclear abort message with limited blast radius.
  • rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦪 silver shellfish and patch quality is 🐚 platinum hermit.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs real behavior proof before merge: The PR body supplies after-patch Vitest output, but no redacted real TUI run, terminal output, recording, or logs show the changed abort behavior after the patch. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
Evidence reviewed

PR surface:

Source +6. Total +6 across 2 files.

View PR surface stats
Area Files Added Removed Net
Source 2 9 3 +6
Tests 0 0 0 0
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 2 9 3 +6

What I checked:

  • Current main drops abort error detail: On current main, emitChatAborted has no error-message parameter and emits only state: "aborted", while the error-phase aborted branch calls it without forwarding evt.data.error. (src/tui/embedded-backend.ts:809, 65848d0b4524)
  • Current main renders generic abort text: The TUI chat handler currently renders every aborted chat event as run aborted, so current main does not already solve the reported display problem. (src/tui/tui-event-handlers.ts:679, 65848d0b4524)
  • Existing event contract can carry the field: ChatEvent already has optional errorMessage?: string, which makes the PR's payload addition compatible with the existing TUI event shape. (src/tui/tui-types.ts:29, 65848d0b4524)
  • PR forwards lifecycle error on aborted error phase: The PR changes emitChatAborted to accept an optional errorMessage and passes evt.data.error for phase === "error" aborted events. (src/tui/embedded-backend.ts:809, 031c894b262b)
  • PR renders abort detail when present: The PR changes the aborted-event handler to render run aborted: ${evt.errorMessage} when the event carries non-empty error detail, preserving the existing generic text otherwise. (src/tui/tui-event-handlers.ts:682, 031c894b262b)
  • Lifecycle producer already sanitizes error text: The embedded-agent lifecycle handler emits data.error from formatUserFacingAssistantErrorText, so the PR reuses the existing user-facing lifecycle error field rather than pulling raw logs into TUI output. (src/agents/embedded-agent-subscribe.handlers.lifecycle.ts:149, 65848d0b4524)

Likely related people:

  • BCM: Available blame attributes the current TUI abort/error emit helper and aborted-event handler lines to this author on commit 4c55dd85499b1b7cb2384318ad42e2cc6db45814. (role: code author in available history; confidence: medium; commits: 4c55dd85499b; files: src/tui/embedded-backend.ts, src/tui/tui-event-handlers.ts)
  • vincentkoc: git show lists Vincent Koc as committer for the available current-main commit carrying the relevant TUI code, making this a reasonable routing candidate despite limited local history. (role: committer / recent area contributor; confidence: medium; commits: 4c55dd85499b; files: src/tui/embedded-backend.ts, src/tui/tui-event-handlers.ts)
What the crustacean ranks mean
  • 🦀 challenger crab: rare, exceptional readiness with strong proof, clean implementation, and convincing validation.
  • 🦞 diamond lobster: very strong readiness with only minor maintainer review expected.
  • 🐚 platinum hermit: good normal PR, likely mergeable with ordinary maintainer review.
  • 🦐 gold shrimp: useful signal, but proof or patch confidence is still limited.
  • 🦪 silver shellfish: thin signal; proof, validation, or implementation needs work.
  • 🧂 unranked krab: not merge-ready because proof is missing/unusable or there are serious correctness or safety concerns.
  • 🌊 off-meta tidepool: rating does not apply to this item.

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.

How this review workflow works
  • 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.

@clawsweeper clawsweeper Bot added 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. P2 Normal backlog priority with limited blast radius. labels Jun 9, 2026
@zenglingbiao
zenglingbiao deleted the fix/issue-90982-tui-abort-error-detail branch June 22, 2026 03:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

P2 Normal backlog priority with limited blast radius. proof: supplied External PR includes structured after-fix real behavior proof. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. size: XS status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: TUI hides tool-call validation errors behind "run aborted" — root cause only visible in gateway log

1 participant