Skip to content

fix(ui): show failed tool results as errors#85786

Merged
altaywtf merged 7 commits into
openclaw:mainfrom
chengjiew:fix/nemoclaw-2621-tool-error-status
May 26, 2026
Merged

fix(ui): show failed tool results as errors#85786
altaywtf merged 7 commits into
openclaw:mainfrom
chengjiew:fix/nemoclaw-2621-tool-error-status

Conversation

@chengjiew

@chengjiew chengjiew commented May 23, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Problem: failed tool results in chat could look like successful tool output with a checkmark.
  • Solution: propagate explicit isError / is_error flags into tool cards and add bounded fallback detection for common error payloads.
  • What changed: tool cards, standalone tool-result summaries, sidebar content, and expanded output labels now render failed tool results with error styling and copy.
  • What did NOT change (scope boundary): no agent execution, gateway protocol, tool runtime, or NemoClaw code paths were changed.

Motivation

Change Type (select all)

  • Bug fix
  • Feature
  • Refactor required for the fix
  • Docs
  • Security hardening
  • Chore/infra

Scope (select all touched areas)

  • Gateway / orchestration
  • Skills / tool execution
  • Auth / tokens
  • Memory / storage
  • Integrations
  • API / contracts
  • UI / DX
  • CI/CD / infra

Linked Issue/PR

Real behavior proof (required for external PRs)

  • Behavior or issue addressed: chat tool cards and standalone tool-result summaries now show failed tool results as Tool error with error styling instead of Tool output / View with a success checkmark.
  • Real environment tested: macOS local OpenClaw worktree; Vite UI harness with system Chrome; focused Vitest UI tests.
  • Exact steps or command run after this patch:
    • node scripts/run-vitest.mjs ui/src/ui/chat/tool-cards.test.ts ui/src/ui/chat/tool-cards.node.test.ts ui/src/ui/chat/grouped-render.test.ts
    • pnpm exec oxfmt --check --threads=1 ui/src/ui/chat/tool-cards.ts ui/src/ui/chat/tool-cards.test.ts ui/src/ui/chat/tool-cards.node.test.ts ui/src/ui/types/chat-types.ts ui/src/styles/chat/tool-cards.css ui/src/ui/chat/grouped-render.ts ui/src/ui/chat/grouped-render.test.ts
    • git diff --check
    • codex review --base refs/remotes/tmp/openclaw-main-2621
    • Temporary Vite proof page rendered renderToolCardSidebar in Chrome with one JSON error result and one successful result.
  • Evidence after fix (screenshot, recording, terminal capture, console output, redacted runtime log, linked artifact, or copied live output):
    • Vitest: Test Files 3 passed (3), Tests 66 passed (66).
    • Format: All matched files use the correct format.
    • Whitespace: git diff --check exited 0.
    • Codex review: I did not find a discrete regression in the modified surfaces.
    • Console output from the Chrome/Vite browser harness after the patch: cardCount=2, errorCards=1, errorActionText="View error", success card kept View.
  • Observed result after fix: error payloads such as {"error":"missing_brave_api_key"} and exact Tool not found output render as failed tool UI, while normal outputs continue to render as successful output.
  • What was not tested: full live OpenClaw agent plus Brave or NemoClaw sandbox end-to-end; earlier Linux latest-image repro was blocked by no space left on device while pulling the image.
  • Before evidence (optional but encouraged): existing behavior treated top-level JSON error output as normal Tool output in grouped rendering and successful sidebar action copy.

Root Cause (if applicable)

  • Root cause: the chat UI treated tool output text as successful unless the local rendering path explicitly knew otherwise, so common error payloads and standalone tool-result summaries were not consistently mapped to failed UI state.
  • Missing detection / guardrail: focused UI tests did not assert that explicit error flags, JSON error payloads, Tool not found, and standalone collapsed tool results all render as errors.
  • Contributing context (if known): OpenClaw has both explicit error flags (isError, is_error) and textual/JSON tool output surfaces, so the UI needs to respect both.

Regression Test Plan (if applicable)

  • Coverage level that should have caught this:
    • Unit test
    • Seam / integration test
    • End-to-end test
    • Existing coverage already sufficient
  • Target test or file:
    • ui/src/ui/chat/tool-cards.test.ts
    • ui/src/ui/chat/tool-cards.node.test.ts
    • ui/src/ui/chat/grouped-render.test.ts
  • Scenario the test should lock in: explicit isError / is_error flags and fallback error outputs must render as Tool error with error styling in card, sidebar, expanded, and collapsed standalone summary paths.
  • Why this is the smallest reliable guardrail: these tests cover the UI normalization/rendering functions that decide the visible state, without requiring a live tool provider.
  • Existing test that already covers this (if any): existing tool card tests covered successful rendering; this PR extends them for failed rendering.
  • If no new test is added, why not: N/A.

User-visible / Behavior Changes

Failed tool results now show error labels, error badges, failed empty-output copy, and View error actions in the chat UI.

Diagram (if applicable)

Before:
[tool result with error payload] -> [tool card] -> [Tool output / success checkmark]

After:
[tool result with error payload or isError flag] -> [tool card] -> [Tool error / error badge]

Security Impact (required)

  • New permissions/capabilities? (Yes/No): No
  • Secrets/tokens handling changed? (Yes/No): No
  • New/changed network calls? (Yes/No): No
  • Command/tool execution surface changed? (Yes/No): No
  • Data access scope changed? (Yes/No): No
  • If any Yes, explain risk + mitigation: N/A

Repro + Verification

Environment

  • OS: macOS local development machine
  • Runtime/container: local Node/pnpm UI workspace
  • Model/provider: N/A
  • Integration/channel (if any): OpenClaw chat UI rendering
  • Relevant config (redacted): no secrets required

Steps

  1. Render tool cards with a JSON error payload, an explicit error flag, and a successful output.
  2. Render grouped standalone tool-result messages in collapsed and expanded states.
  3. Run focused chat rendering tests, formatting, whitespace check, and Codex review.

Expected

  • Failed tool results are visually and textually marked as errors.
  • Successful tool results keep existing success copy and styling.

Actual

  • Failed results render as Tool error, include error styling/badges, and use View error in the sidebar card action.
  • Successful results still render as Tool output / View.

Evidence

Attach at least one:

  • Failing test/log before + passing after
  • Trace/log snippets
  • Screenshot/recording
  • Perf numbers (if relevant)

Human Verification (required)

What you personally verified (not just CI), and how:

  • Verified scenarios:
    • JSON error payloads.
    • exact Tool not found output.
    • explicit isError and is_error flags.
    • isError: false combined with an error payload.
    • collapsed standalone tool-result summaries.
    • empty failed output sidebar copy.
    • successful outputs remain successful.
  • Edge cases checked:
    • blank output is not treated as an error unless an explicit error flag is present.
    • non-JSON and JSON arrays are not treated as error payloads.
    • very large output skips fallback JSON parsing.
  • What you did not verify:
    • full live OpenClaw agent plus external web-search provider end-to-end.
    • Linux latest-image repro after the local Linux host ran out of disk space while pulling the latest image.

Review Conversations

  • I replied to or resolved every bot review conversation I addressed in this PR.
  • I left unresolved only the conversations that still need reviewer or maintainer judgment.

Compatibility / Migration

  • Backward compatible? (Yes/No): Yes
  • Config/env changes? (Yes/No): No
  • Migration needed? (Yes/No): No
  • If yes, exact upgrade steps: N/A

Risks and Mitigations

  • Risk: fallback JSON error detection could overclassify a successful tool output that intentionally returns a top-level truthy error field as data.
    • Mitigation: explicit isError / is_error flags are preferred, fallback parsing is bounded to top-level JSON objects and common known error shapes, and tests cover success outputs remaining unchanged.

AI-assisted: yes, implemented with Codex and reviewed with codex review.

@openclaw-barnacle openclaw-barnacle Bot added app: web-ui App: web-ui size: L triage: mock-only-proof Candidate: PR proof only shows tests, mocks, snapshots, lint, typecheck, or CI. labels May 23, 2026
@clawsweeper

clawsweeper Bot commented May 23, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed May 26, 2026, 4:26 PM ET / 20:26 UTC.

Summary
The PR threads isError/is_error and bounded error-output detection through Control UI tool-card extraction, rendering, CSS, types, and focused tests.

PR surface: Source +268, Tests +461. Total +729 across 8 files.

Reproducibility: yes. at source level: current main labels the sidebar and grouped standalone tool-result paths as Tool output without checking explicit error flags or common error-shaped payloads.

Review metrics: 1 noteworthy metric.

  • Fallback error heuristics: 3 added. Top-level JSON error, failure status, and literal Tool not found can change how existing tool-result payloads are classified in the UI.

Merge readiness
Overall: 🦐 gold shrimp
Proof: 🦞 diamond lobster
Patch quality: 🦐 gold shrimp
Result: needs maintainer review before merge.

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

Rank-up moves:

  • Resolve or explain the current check-guards failure and pending checks before merge.
  • Get maintainer acceptance on keeping or narrowing the fallback error heuristics.

Mantis proof suggestion
A short visible Control UI proof would materially help reviewers confirm the error card and successful card render differently in the browser. 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 Control UI tool cards show Tool error/View error for failed tool results while successful results still show View.

Risk before merge

  • Fallback heuristics can reclassify existing successful-looking tool outputs as errors when a top-level error, failure status, or literal Tool not found appears without an explicit success flag.
  • Current-head validation is not fully settled: check-guards is failing and several checks were still in progress at review time.

Maintainer options:

  1. Accept bounded fallback classification
    Keep the fallback behavior if maintainers want common error-shaped payloads to show failed UI even when producers omit explicit error flags.
  2. Narrow fallback detection
    Limit classification to explicit isError / is_error or a smaller documented fallback set if ambiguous JSON data should keep successful-output UI.
  3. Wait for green validation
    Pause merge until check-guards and the remaining current-head checks are green or proven unrelated to this PR.

Next step before merge
The remaining action is maintainer acceptance of fallback classification plus validation status, not a narrow mechanical repair to queue.

Security
Cleared: The diff changes Control UI rendering, CSS, types, and tests only; I found no new dependency, permission, network, secret-handling, or code-execution surface.

Review details

Best possible solution:

Land the focused UI error-rendering fix after checks pass and maintainers explicitly accept or narrow the fallback heuristics, with explicit error flags kept as the source of truth.

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

Yes, at source level: current main labels the sidebar and grouped standalone tool-result paths as Tool output without checking explicit error flags or common error-shaped payloads.

Is this the best way to solve the issue?

Yes for the explicit isError / is_error path; the fallback heuristics are plausible but compatibility-sensitive, so maintainers should accept or narrow them before merge.

AGENTS.md: found and applied where relevant.

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

Label changes

Label changes:

  • add proof: sufficient: Contributor real behavior proof is sufficient. The PR body includes after-fix Chrome/Vite harness live output showing one error card, View error, and unchanged success-card copy, plus focused test and formatting results.

Label justifications:

  • P2: This is a focused user-visible Control UI bug fix with limited blast radius and no evidence of data loss, security impact, or runtime outage.
  • merge-risk: 🚨 compatibility: The PR changes fallback display semantics for existing tool-result payloads that contain error-shaped JSON or status text.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦞 diamond lobster and patch quality is 🦐 gold shrimp.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (live_output): The PR body includes after-fix Chrome/Vite harness live output showing one error card, View error, and unchanged success-card copy, plus focused test and formatting results.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR body includes after-fix Chrome/Vite harness live output showing one error card, View error, and unchanged success-card copy, plus focused test and formatting results.
Evidence reviewed

PR surface:

Source +268, Tests +461. Total +729 across 8 files.

View PR surface stats
Area Files Added Removed Net
Source 4 296 28 +268
Tests 4 465 4 +461
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 8 761 32 +729

What I checked:

  • Root and scoped policy read: Read the root and ui/AGENTS.md; the compatibility-risk guidance applies because fallback classification changes existing UI semantics for tool-result payloads. (AGENTS.md:1, f7e2d9bb4708)
  • Current main sidebar behavior: Current main always emits Tool output or completed empty-output copy in sidebar content without checking a tool error flag or error-shaped output. (ui/src/ui/chat/tool-cards.ts:253, f7e2d9bb4708)
  • Current main grouped-summary behavior: Current main computes standalone tool-result labels from display detail/name and falls back to Tool output; it has no error-state check in that summary path. (ui/src/ui/chat/grouped-render.ts:1558, f7e2d9bb4708)
  • PR error classification: The PR head adds explicit flag handling plus bounded fallback detection for literal Tool not found, top-level JSON error, and failure-like status values. (ui/src/ui/chat/tool-cards.ts:81, 8839bbff0164)
  • PR rendered error state: The PR head routes isToolCardError into sidebar content and visible card rendering so failed results get Tool error, failed empty-output copy, and error styling. (ui/src/ui/chat/tool-cards.ts:315, 8839bbff0164)
  • PR grouped summaries: The PR head computes toolMessageHasError and applies the error label, class, and badge to grouped standalone tool-result summaries. (ui/src/ui/chat/grouped-render.ts:1538, 8839bbff0164)

Likely related people:

  • steipete: Recent main history shows repeated Control UI tool-card and grouped-render work, including compact tool progress display and text-block tool result rendering. (role: recent area contributor; confidence: high; commits: 11dc5cb94e9e, a4df85e55f3a, 330ba1fa3194; files: ui/src/ui/chat/tool-cards.ts, ui/src/ui/chat/grouped-render.ts, ui/src/styles/chat/tool-cards.css)
  • Takhoffman: Recent merged history includes interleaved tool-card pairing and assistant directive rendering in the same chat rendering surface. (role: recent tool-card contributor; confidence: high; commits: d9812b85c41d, cc5c691f0069; files: ui/src/ui/chat/tool-cards.ts, ui/src/ui/chat/grouped-render.ts)
  • Val Alexander: Recent file history shows substantial Control UI chat renderer and tool-card styling changes near the touched files. (role: UI area contributor; confidence: medium; commits: ab910f88adb6, 098b72910dea, 52370c59980b; files: ui/src/ui/chat/tool-cards.ts, ui/src/ui/chat/grouped-render.ts, ui/src/styles/chat/tool-cards.css)
  • altaywtf: The live PR timeline shows maintainer-side force-pushes on the current branch, including status-only classification and final styling refinements. (role: likely follow-up owner; confidence: medium; commits: b9ed990181a3, 8839bbff0164; files: ui/src/ui/chat/tool-cards.ts, ui/src/styles/chat/tool-cards.css)
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 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. P2 Normal backlog priority with limited blast radius. labels May 23, 2026
@clawsweeper

clawsweeper Bot commented May 23, 2026

Copy link
Copy Markdown
Contributor

ClawSweeper PR egg

✨ Hatched: 🥚 common Velvet Lint Imp

Hatch command

Comment @clawsweeper hatch when this PR is hatchable.

Hatchability rules:

  • Merged PRs are hatchable.
  • Open PRs are hatchable when they are status: 👀 ready for maintainer look, status: 🚀 automerge armed, or labeled clawsweeper:automerge.
  • Closed unmerged PRs are hatchable only when one of those hatchable labels is still present in the durable record.

Rarity: 🥚 common.
Trait: sleeps inside passing CI.
Image traits: location release reef; accessory miniature diff map; palette charcoal, cyan, and signal green; mood sleepy but ready; pose holding its accessory up for inspection; shell woven fiber shell; lighting golden review-room light; background quiet workflow signs.
Share on X: post this hatch
Copy: My PR egg hatched a 🥚 common Velvet Lint Imp in ClawSweeper.

What is this egg doing here?
  • Eggs appear after the PR passes real-behavior proof. It is here for vibes, not verdicts: it does not change labels, ratings, merge decisions, or automation.
  • The shell reacts to review momentum: open follow-up work warms it up, re-review makes it wobble, and a clean final review lets it hatch.
  • Hatchability usually comes from sufficient real-behavior proof, no blocking P0/P1/P2 findings, no security attention needed, and clean correctness. A merged PR is already final, so merge makes the egg hatchable independently.
  • The hatch is seeded from this repository and PR number, so the same PR keeps the same creature; the reviewed head SHA can only change safe visual details.
  • Rarity is just collectible sparkle: 🥚 common, 🌱 uncommon, 💎 rare, ✨ glimmer, and 🌈 legendary.

@openclaw-barnacle openclaw-barnacle Bot removed the triage: mock-only-proof Candidate: PR proof only shows tests, mocks, snapshots, lint, typecheck, or CI. label May 23, 2026
@clawsweeper clawsweeper Bot added the merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. label May 23, 2026
@chengjiew
chengjiew force-pushed the fix/nemoclaw-2621-tool-error-status branch from 69916a7 to 9482d3a Compare May 24, 2026 03:52
@openclaw-barnacle openclaw-barnacle Bot added triage: mock-only-proof Candidate: PR proof only shows tests, mocks, snapshots, lint, typecheck, or CI. and removed proof: sufficient ClawSweeper judged the real behavior proof convincing. labels May 24, 2026
@clawsweeper clawsweeper Bot added the proof: sufficient ClawSweeper judged the real behavior proof convincing. label May 24, 2026
@openclaw-barnacle openclaw-barnacle Bot added proof: supplied External PR includes structured after-fix real behavior proof. and removed triage: mock-only-proof Candidate: PR proof only shows tests, mocks, snapshots, lint, typecheck, or CI. proof: sufficient ClawSweeper judged the real behavior proof convincing. labels May 24, 2026
@clawsweeper clawsweeper Bot added the proof: sufficient ClawSweeper judged the real behavior proof convincing. label May 24, 2026
@chengjiew
chengjiew force-pushed the fix/nemoclaw-2621-tool-error-status branch from 9482d3a to 1136ae8 Compare May 25, 2026 02:07
@openclaw-barnacle openclaw-barnacle Bot removed the proof: sufficient ClawSweeper judged the real behavior proof convincing. label May 25, 2026
@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. 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. and removed 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 May 25, 2026
@openclaw-barnacle openclaw-barnacle Bot removed the proof: sufficient ClawSweeper judged the real behavior proof convincing. label May 25, 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. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. labels May 25, 2026
@altaywtf

Copy link
Copy Markdown
Member

Merged via squash.

Thanks @chengjiew!

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 merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P2 Normal backlog priority with limited blast radius. proof: supplied External PR includes structured after-fix real behavior proof. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. 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.

2 participants