Skip to content

fix(gateway): preserve provider details on chat error events - #135102

Merged
steipete merged 2 commits into
mainfrom
steipete/chat-error-detail
Sep 1, 2026
Merged

steipete merged 2 commits into
mainfrom
steipete/chat-error-detail

Conversation

@steipete

@steipete steipete commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

What Problem This Solves

Chat clients could not distinguish a provider HTTP outage from other failed runs without Gateway logs, although the lifecycle producer already recorded sanitized diagnostic facts.

Why This Change Was Made

Preserve those facts at the lifecycle owner, including deferred command/auto-reply terminals, and expose one bounded, closed allowlist through errorDetail. Apply the same projection before lifecycle publication and at the chat builder so raw log diagnostics cannot escape through either stream. Reuse the existing credential redactor, including for provider error types.

Discovery source: NetEase Youdao's LobsterAI patch stack (github.com/netease-youdao/LobsterAI). Its arbitrary-key payload-spreading mechanism was not adopted.

User Impact

Clients can inspect optional provider/model, failure classifications, HTTP status, and a credential-redacted message preview on failed chat events. Existing coarse error kind/message behavior is unchanged. No configuration or protocol-version bump. The protocol reference documents the additive field; Control UI presentation remains a named follow-up.

Evidence

278 tests passed across eight existing files, covering the closed/all-optional schema, bounds, redaction, direct/command/reply lifecycle-to-Gateway delivery, clean-run omission, and retry cleanup. The protocol package build and built-entry-point smoke passed, as did focused lint, formatting, whitespace checks, and fresh scoped-clean Codex autoreview. The full pnpm check:changed gate passed with exit code 0. Production net +77 implements the requested closed protocol capability and lifecycle ownership handoff; tests net +246 and docs +11. No live provider outage was induced; proof uses synthetic provider failure through real lifecycle and Gateway handlers.

Expose a closed, bounded errorDetail object from sanitized provider
observations. Preserve the observation through direct and deferred
terminal ownership, and redact provider error types at the observation
boundary. Project before lifecycle publication as well as chat delivery
so raw bodies, previews, and hashes stay out of both event streams.

Document the additive protocol-v4 field and cover schema bounds, redaction,
clean runs, retry cleanup, and lifecycle-to-gateway delivery.

Discovery source: NetEase Youdao's LobsterAI patch stack
(https://github.com/netease-youdao/LobsterAI). The arbitrary-key payload
spreading mechanism was not adopted.
@clawsweeper

clawsweeper Bot commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

@steipete
steipete marked this pull request as ready for review September 1, 2026 10:21
@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 1, 2026
@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 1, 2026
@clawsweeper

clawsweeper Bot commented Sep 1, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 1, 2026, 6:42 AM ET / 10:42 UTC.

ClawSweeper review

What this changes

This PR adds an optional, bounded and redacted errorDetail object to failed Gateway chat events, updates generated Swift protocol models and docs, and tests direct and deferred terminal delivery.

Merge readiness

⚠️ Ready for maintainer review - 2 items remain

Keep open for explicit maintainer acceptance of the new public Gateway v4 diagnostic contract. The implementation is bounded and source-supported, with no actionable patch defect found.

Priority: P2
Reviewed head: b0618749895f179eb7996c0ee0a28521eec9fc12
Owner decision: Required. See Decision needed.

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A well-bounded implementation with focused owner-boundary coverage; remaining review is acceptance of the public protocol contract.
Proof confidence 🌊 off-meta tidepool Not applicable: The supplied test path injects a synthetic provider failure through lifecycle and Gateway handlers, but no live outage trace was examined; the external-contributor proof gate does not apply to this maintainer-associated PR.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The supplied test path injects a synthetic provider failure through lifecycle and Gateway handlers, but no live outage trace was examined; the external-contributor proof gate does not apply to this maintainer-associated PR.
Evidence reviewed 6 items Current-main gap: Current main defines failed chat events with coarse error fields only; it has no error-detail projection, so the requested capability is not already implemented.
Owner-boundary implementation: The lifecycle owner projects the selected provider facts before emitting the terminal lifecycle event, and Gateway applies the same closed projection immediately before publishing an error chat event.
Boundary coverage: The table-driven Gateway test exercises direct, command, and auto-reply terminal owners, validates the wire schema, and asserts that the synthetic credential does not reach either event stream.
Findings None None.
Security None None.

How this fits together

Agent lifecycle code records a failed provider attempt, then Gateway projects that terminal event into chat updates for subscribed clients. This change carries a small sanitized diagnostic subset across that boundary.

flowchart LR
A[Provider failure] --> B[Agent lifecycle]
B --> C[Sanitized observation]
C --> D[Terminal owner]
D --> E[Gateway chat event]
E --> F[Subscribed clients]
Loading

Decision needed

Question Recommendation
Should OpenClaw commit the documented optional errorDetail object as a stable Gateway v4 client contract? Accept the additive diagnostic contract: Merge the bounded optional field and let clients opt into rendering it when useful.

Why: The patch is technically coherent, but it deliberately expands the diagnostics exposed to every compatible chat-event client.

Before merge

  • Complete next step (P2) - No mechanical repair is indicated; the maintainer label and deliberate public protocol expansion require human contract approval.
Agent review details

Security

None.

PR surface

Source +77, Tests +246, Docs +11, Other +4. Total +338 across 14 files.

View PR surface stats
Area Files Added Removed Net
Source 7 82 5 +77
Tests 5 248 2 +246
Docs 1 11 0 +11
Config 0 0 0 0
Generated 0 0 0 0
Other 1 4 0 +4
Total 14 345 7 +338

Review metrics

Metric Value Why it matters
Production versus test delta production +77, tests +246, docs +11, generated Swift +4 The production growth implements one bounded public protocol capability; boundary coverage spans all three terminal owners.

Stored data model

Persistent data-model change detected: unknown-data-model-change: packages/gateway-protocol/src/schema/logs-chat.ts. Confirm migration or upgrade compatibility proof before merge.

Technical review

Best possible solution:

Accept the optional closed errorDetail object only as an intentional Gateway v4 client contract, retaining the lifecycle-owner projection, closed allowlist, and redaction tests.

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

Yes, at source level: current main's failed-chat schema and Gateway terminal builder omit this diagnostic object, while the PR exercises the proposed failure path. No live provider outage was run in this read-only review.

Is this the best way to solve the issue?

Yes, pending product acceptance: projecting one closed allowlist at the lifecycle owner and again at Gateway avoids reparsing user-facing text and covers direct and deferred terminal paths.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against d394da816e24.

Labels

Label justifications:

  • P2: This is a bounded diagnostic capability improvement for failed chat runs, without evidence of an urgent outage or data-loss regression.
  • 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 supplied test path injects a synthetic provider failure through lifecycle and Gateway handlers, but no live outage trace was examined; the external-contributor proof gate does not apply to this maintainer-associated PR.

Evidence

What I checked:

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • SunnyShu: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

Rank-up moves

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

  • Record protocol-owner acceptance of the optional v4 diagnostic field before merge.

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-01T10:28:52.849Z sha 59f57a9 :: needs maintainer review before merge. :: none

@steipete

steipete commented Sep 1, 2026

Copy link
Copy Markdown
Contributor Author

Protocol-contract acceptance note: the additive optional errorDetail object on chat error events was explicitly approved by the maintainer (@steipete) in the operator chat directing this adoption campaign (the reviewed proposal named this exact closed-schema addition). No version bump; additive only.

@steipete
steipete merged commit f085148 into main Sep 1, 2026
267 checks passed
@steipete
steipete deleted the steipete/chat-error-detail branch September 1, 2026 11:02
@steipete

steipete commented Sep 1, 2026

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 2, 2026
…w#135102)

* fix(gateway): preserve provider details on chat error events

Expose a closed, bounded errorDetail object from sanitized provider
observations. Preserve the observation through direct and deferred
terminal ownership, and redact provider error types at the observation
boundary. Project before lifecycle publication as well as chat delivery
so raw bodies, previews, and hashes stay out of both event streams.

Document the additive protocol-v4 field and cover schema bounds, redaction,
clean runs, retry cleanup, and lifecycle-to-gateway delivery.

Discovery source: NetEase Youdao's LobsterAI patch stack
(https://github.com/netease-youdao/LobsterAI). The arbitrary-key payload
spreading mechanism was not adopted.

* chore(protocol): regenerate Swift gateway models for errorDetail
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