Skip to content

fix(chat): show gateway reason beside failed turns - #2018

Draft
turutupa wants to merge 3 commits into
openclaw:mainfrom
turutupa:fix/show-gateway-agent-errors
Draft

turutupa wants to merge 3 commits into
openclaw:mainfrom
turutupa:fix/show-gateway-agent-errors

Conversation

@turutupa

@turutupa turutupa commented Nov 5, 2026 •

Copy link
Copy Markdown

What Problem This Solves

Fixes: Windows chat shows a generic “Agent error” status for a failed turn even when its Gateway event contains an explanation.

User Impact

User impact: Chat shows the Gateway’s explanation, such as a missing provider secret reference, so users can diagnose the failure. Newly displayed data.error text is redacted before display.

Why This Change Was Made

The mapper previously read summary or data.message and fell back to “Agent error”; the Gateway reports these failures in data.error. The existing fallback remains for events without a usable explanation.

Evidence

  • The reported NVIDIA missing-secret error passes for both lifecycle and job events in focused tests.
  • A provider timeline regression confirms lifecycle errors appear as error status entries.
  • A redaction regression confirms short credentials and URL query secrets are hidden.
  • The reported screenshot already has an earlier detailed assistant message. This change targets later error status entries; the screenshot alone does not establish their event payloads.
  • Reported current-app view (before): Chat with an earlier detailed assistant message and later generic Agent error statuses
  • Native WinUI and live Gateway behavior could not be checked on this host.

Change Type

  • Bug fix
  • Feature
  • Refactor
  • Docs or instructions
  • Tests or validation
  • Security hardening
  • Chore or infrastructure

Scope

  • Tray or WinUI UX
  • Windows node capability
  • Local MCP or winnode
  • Gateway, connection, or pairing
  • Setup or onboarding
  • Permissions, privacy, or security
  • Tests, CI, or docs

Required proof pools

  • windows-winui-interactive: confirm the explanation appears in the native chat UI on an interactive Windows host.

Validation

  • Focused dotnet test .\tests\OpenClaw.Tray.Tests\OpenClaw.Tray.Tests.csproj --no-restore --filter 'FullyQualifiedName~ChatEventMapperTests|FullyQualifiedName~AgentEvent_LifecycleError_AppendsErrorStatusEntry': 17 passed on commit 5c42800a.
  • dotnet test .\tests\OpenClaw.Shared.Tests\OpenClaw.Shared.Tests.csproj --no-restore with OPENCLAW_REPO_ROOT set to this checkout: 4,925 passed, 26 skipped, 1 failed on code commit 5c42800a. The remaining folder-admission test needs Windows symlink privilege unavailable on this host.
  • dotnet test .\tests\OpenClaw.Tray.Tests\OpenClaw.Tray.Tests.csproj --no-restore: 5,065 passed, 1 failed on commit 5c42800a. The prerequisite test failed because the Windows SDK is absent.
  • .\build.ps1: blocked by missing Windows SDK and Visual Studio C++ redistributable tooling. Documentation validation passed (72 Markdown files).
  • git diff --check: passed.
  • Independent final-diff review of commit 5c42800a: no required findings. Review noted that native UI proof remains pending.

Real Behavior Proof

  • Environment tested: Windows, .NET SDK 10.0.400; native WinUI prerequisites unavailable.
  • PR head: 1bcfaa51; code tested at 5c42800a. The later commit only adds the reported screenshot.
  • Exact steps or command run: focused dotnet test command above.
  • Evidence after fix: mapper tests assert the NVIDIA error reaches ChatErrorEvent; provider test asserts an error status entry.
  • Observed result: 17 focused tests passed.
  • Screenshot or artifact links verified? Yes for the reported before screenshot; after screenshot pending.
  • Not verified or blocked: native WinUI display and live Gateway behavior; interactive proof remains to be scheduled. The reported screenshot does not prove the later events carried data.error.

Security Impact

  • New permissions or capabilities? No
  • Secrets or tokens handling changed? Yes
  • New or changed network calls? No
  • Command or tool execution surface changed? No
  • Data access scope changed? No
  • If any answer is Yes, explain the risk and mitigation: Gateway error text is newly displayed. TokenSanitizer.SanitizeLogMessage removes common credentials, private keys, URL query strings and local identity details before rendering. Redaction is pattern based.

Compatibility and Migration

  • Backward compatible? Yes
  • Config or environment changes? No
  • Migration needed? No
  • If yes, list the exact upgrade steps: N/A

Review Conversations

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

@clawsweeper

clawsweeper Bot commented Nov 5, 2026 •

Copy link
Copy Markdown

🦞👀
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.

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. P2 Normal priority bug or improvement with limited blast radius. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Nov 5, 2026
@clawsweeper

clawsweeper Bot commented Nov 5, 2026

Copy link
Copy Markdown

Codex review: needs real behavior proof before merge.

What this changes

The PR displays sanitized Gateway error explanations in failed chat status entries.

Example: A lifecycle error contains data.error stating that provider:nvidia-inference has an unavailable secret reference.

  • Before: The failed turn displays “Agent error”.
  • After: The failed turn displays the Gateway explanation after redaction.

Review scores

Measure Result What it means
Overall readiness 🧂 unranked krab (1/6) The patch is narrow and source-consistent, but supplied after-fix evidence is test-only and full native validation remains incomplete.
Proof confidence 🧂 unranked krab (1/6) Real behavior proof is necessary before merge. See Before merge.
Patch quality 🦐 gold shrimp (3/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: Failed chat turns can hide an explanation already supplied by the Gateway behind a generic status.
Reason: Displaying available diagnostic detail has clear value and fits the existing error presentation contract without introducing settings or changing send behavior.

Merge readiness

⛔ Blocked before merge - 1 item remains

This PR addresses a concrete omission still present on main, with a focused change in the existing mapper and no actionable introduced defect found.

Priority: P2
Reviewed head: 1bcfaa51b48c7b4c71c28a406515c2fc517765fb

Before merge

  • Add real behavior proof - After-fix evidence exercises ChatEventMapper and provider timeline state with synthetic events, while the only screenshot shows the earlier application behavior. The contributor must show a current-head Gateway failure reaching the native chat status with its explanation visible and credentials redacted, preferably in a screenshot or recording with a corresponding redacted event trace; redact IPs, API keys, phone numbers, and non-public endpoints. After adding proof, update the PR body, then request a new review with @clawsweeper re-review. The PR author or someone with repository write access can request it.

Findings

None.

Tests

  • Missing end-to-end proof: Current-head native chat rendering through a Gateway error event and an executed base-fail/head-pass regression comparison have not been shown.
Agent review details

How this fits together

Gateway broadcasts become AgentEventInfo objects, which the chat mapper converts into timeline events; the reducer turns errors into status entries rendered by native chat.

flowchart LR
  A[Gateway broadcast] --> B[Gateway client]
  B --> C[ChatEventMapper]
  C --> D[ChatConversationState]
  D --> E[ChatTimelineReducer]
  E --> F[Native chat status]
Loading

Technical review

Best possible solution:

Keep error resolution in ChatEventMapper, preserve existing fallbacks, and sanitize newly displayed Gateway explanations.

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

An admitted lifecycle or job error with a string data.error and no summary demonstrably loses its explanation on main; the screenshot does not establish the payload of the reported later failures.

Is this the best way to solve the issue?

This is a proportionate fix at the authoritative mapping owner: it retains summary precedence and fallback behavior without adding state, transport changes, or another presentation path.

AGENTS.md: found and applied where relevant.

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

Provenance checked

  • Lifecycle and job error mapping keeps the original intent (f8a8825: The mapped lines were carried into the focused mapper by the behavior-preserving extraction in refactor(chat): extract runtime state owners #1096. The original omission predates that extraction; git show of the parent provider blob and scoped git log -G could not read older objects.)
  • Provider timeline regression keeps the original intent (02f2421: Fix queued chat message parity #935 protected terminal lifecycle errors within queued-chat behavior; the changed fixture retains the same terminal-status assertions using the newly supported payload field.)

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

Likely related people:

  • Karen: Raw commit 814e732 adds src/OpenClaw.Tray.WinUI/Chat/ChatEventMapper.cs:213 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 814e732e2e90; files: src/OpenClaw.Tray.WinUI/Chat/ChatEventMapper.cs)
  • Caleb Eden: Raw commit 02f2421 adds tests/OpenClaw.Tray.Tests/OpenClawChatDataProviderTests.cs:2558 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 02f2421a5e75; files: tests/OpenClaw.Tray.Tests/OpenClawChatDataProviderTests.cs)

Preflight source

Source unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified.

Review metrics

Metric Value Why it matters
Production and test delta Production +16/-6; tests +53/-1 The small shared resolver and focused payload, redaction, and timeline coverage are proportionate to the fix.

Labels

Label changes:

  • add P2: Missing failure details hinder diagnosis, but this patch does not repair the underlying provider failure or establish a blocked first-run recovery flow.
  • add rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🦐 gold shrimp.
  • add status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Label justifications:

  • P2: Missing failure details hinder diagnosis, but this patch does not repair the underlying provider failure or establish a blocked first-run recovery flow.
  • rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🦐 gold shrimp.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

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.

Reviewed November 5, 2026, 1:51 PM ET / 18:51 UTC.

@roboclaw-bot

Copy link
Copy Markdown
Contributor

PR cleanup review

Reviewed head: 1bcfaa51b48c7b4c71c28a406515c2fc517765fb. Main comparison: e59374c064f43d68f5c72d070d4c89ef2d20ec3b.

The underlying fix is still needed: current main does not read data.error for lifecycle or job failures, even after the recent chat work. The mapper change is small and the redaction regression is useful. The committed screenshot shows the old generic error, not the changed behavior. Please refresh this onto the current ChatEventMapper without replacing the newer thinking/tool mapping, and attach current-head visible proof plus focused and required test results. This looks like a good small follow-up, not a superseded PR.

Action in this cleanup pass: leaving this PR open. No branch changes or runtime-proof waiver. The findings above come from source, discussion and recorded-CI review; Windows validation was not rerun in this pass.

turutupa and others added 3 commits November 20, 2026 13:56
A failed run reports its reason twice: on the lifecycle (or job) error
event and again on the terminal chat frame. With the lifecycle reason now
shown, skip the chat frame's status when it repeats the same reason for
the same run. A different terminal error is still shown.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Lifecycle and job failure explanations now get the same display redaction
and length cap as the terminal chat frame's error text, on top of the log
redaction, so bare provider keys and hosts are hidden in either path.
Adds tests for a bare key, a redacted URL in both arrival orders.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@turutupa
turutupa force-pushed the fix/show-gateway-agent-errors branch from 1bcfaa5 to 273a9f4 Compare November 20, 2026 23:00

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

P2 Normal priority bug or improvement with limited blast radius. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. 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.

2 participants