Repository navigation
fix(agents): carry classified provider facts into assistant failure copy - #134103
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
Codex review: found issues before merge. Reviewed August 31, 2026, 9:56 AM ET / 13:56 UTC. ClawSweeper reviewWhat this changesThe PR adds a shared renderer for redacted provider/model/reason/status failure copy and applies it to assistant failover and external reply paths. Regression provenancePossible regression — suspected (reviewed change). No predecessor PR is attributed. Merge readinessKeep this PR open: current main does not contain its new rendering path, but the branch still loses structured failure classification, leaves a common external-reply fast path generic, and can label an observed 5xx response as a timeout. Priority: P2 Review scores
Verification
How this fits togetherProvider failures are classified during agent execution, then formatted for embedded-run payloads, lifecycle events, and channel replies. This change sits between the assistant error record and the user-visible failure text. flowchart LR
A[Provider failure] --> B[Assistant error record]
B --> C[Failure classification]
C --> D[Safe failure-copy renderer]
D --> E[Embedded-run payload]
D --> F[External channel reply]
E --> G[User-visible message]
F --> G
Before merge
Findings
Agent review detailsSecurityNone. PR surfaceSource +104, Tests +130. Total +234 across 11 files. View PR surface stats
Review metrics
Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Derive display facts from the complete assistant failover signal, separate retry classification from user-facing 5xx wording, and route provider-request replies through the same safe renderer without duplicating reason-copy policy. Do we have a high-confidence way to reproduce the issue? No current-main live execution was run in this read-only review; source establishes focused, reproducible branch cases for structured error types, opaque 5xx responses, and provider-request replies. Is this the best way to solve the issue? No. The rendering boundary is appropriate, but it must consume the complete existing signal and cover the provider-request fast path while avoiding false timeout wording. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 145d9ffafa55. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (2 earlier review cycles)
|
ddcb7c2 to
dd027bf
Compare
…dary The thrown fallback error message is now composed by the real formatUserFacingAssistantErrorText renderer, so the sibling integration assertions track the classified copy (provider/model named) instead of the mocked internal formatter output. Current-attempt attribution is proven directly by the composed message.
# Conflicts: # src/agents/embedded-agent-helpers/error-text.ts
|
Thanks @obviyus! Proof: live Telegram E2E against a mock provider returning persistent 503 — the user now receives the classified copy naming the failing provider/model and reason; plus the full embedded-runner error suites (101 tests) green on the exact head.
|
…er (#134281) Three uncoordinated retry layers replayed the same provider request on a transient failure: provider SDK client defaults, a per-request retry loop inside the ChatGPT transport, and an outer whole-turn replay in the reply runner. Stacked, one transient 429 could hold a turn silently for minutes, and the failover controller that owns provider/model fallback never saw the attempts it needed to budget. Transient retry now has one owner: the embedded runner's failover retry controller. `retry.provider.maxRetries` is its attempt budget (default 3), the retry window stays flat at 90s so time-to-failover stays bounded, and window truncation is recorded at the producer. SDK clients run with `maxRetries: 0`, the ChatGPT transport loop is deleted, and the outer overload replay plus `OverloadRetryState` and the obsolete `StreamOptions.maxRetries` knob are removed. User impact: a transient blip retries quickly and quietly, then succeeds or follows the existing failover chain; a persistent outage surfaces within 90s with curated, actionable copy instead of minutes of silence. An unprepared provider HTTP 500 now reads "provider internal error" instead of "request timed out". Not a breaking change: a saved `retry.provider.maxRetries` keeps a coherent meaning and needs no migration. Named tradeoffs: the 30s "still retrying" notice is gone, and worst-case transient patience drops from about 217s to 90s. Production LOC: +463 / -685 across 44 files, net -222. Follows #134103 and #134111 in the LLM error-UX series. Co-authored-by: Ayaan Zaidi <[email protected]>
…er (openclaw#134281) Three uncoordinated retry layers replayed the same provider request on a transient failure: provider SDK client defaults, a per-request retry loop inside the ChatGPT transport, and an outer whole-turn replay in the reply runner. Stacked, one transient 429 could hold a turn silently for minutes, and the failover controller that owns provider/model fallback never saw the attempts it needed to budget. Transient retry now has one owner: the embedded runner's failover retry controller. `retry.provider.maxRetries` is its attempt budget (default 3), the retry window stays flat at 90s so time-to-failover stays bounded, and window truncation is recorded at the producer. SDK clients run with `maxRetries: 0`, the ChatGPT transport loop is deleted, and the outer overload replay plus `OverloadRetryState` and the obsolete `StreamOptions.maxRetries` knob are removed. User impact: a transient blip retries quickly and quietly, then succeeds or follows the existing failover chain; a persistent outage surfaces within 90s with curated, actionable copy instead of minutes of silence. An unprepared provider HTTP 500 now reads "provider internal error" instead of "request timed out". Not a breaking change: a saved `retry.provider.maxRetries` keeps a coherent meaning and needs no migration. Named tradeoffs: the 30s "still retrying" notice is gone, and worst-case transient patience drops from about 217s to 90s. Production LOC: +463 / -685 across 44 files, net -222. Follows openclaw#134103 and openclaw#134111 in the LLM error-UX series. Co-authored-by: Ayaan Zaidi <[email protected]>
What Problem This Solves
When an LLM provider request fails on a chat channel, users usually see the bare string
LLM request failed.— even though provider id, model id, HTTP status, and a classified failure reason are all known at the emit site. Two independent layers erase these facts:src/agents/embedded-agent-helpers/error-text.ts— any error not matching the rich copy branches is treated as raw passthrough and collapsed to the generic constant, while theprovider/model/authModeoptions passed in byrun/payloads.tsgo unused on that branch.src/auto-reply/reply/agent-runner-failure-reply.ts— external replies substitute the generic external failure text unless the session verbose level ison/full.Real incident: a provider returned
service_unavailabletwice plus one internal error; the Telegram user saw three bareLLM request failed.posts with zero facts and no next step.Why This Change Was Made
Invariant established: classified, safe-by-construction facts — provider id, model id, classified failover reason, HTTP status when known — survive to every user surface. Only unclassified raw provider text is redacted. Redact, don't erase.
formatUserFacingAssistantErrorTextnow classifies once (classifyFailoverReason+extractErrorHttpStatus) and passes the facts into the formatter; the passthrough branch composes copy from those facts instead of returning the bare constant. The existing raw-passthrough detection still decides what to redact, no longer whether to erase everything.src/agents/failover/user-copy.tsowns the reason table (satisfies Record<FailoverReason, string>) and the composed renderer, so retry/failover/user copy consume one classification.buildExternalRunFailureReplydelivers composed classified copy regardless of verbose level (it is safe by construction); the verboseon/fullopt-in still gates forwarded sanitized detail for unclassified errors, and provider-specificuserMessagekeeps precedence with composed copy as fallback. GroupSILENT_REPLY_TOKENbehavior is untouched.run/assistant-failover.tsnow uses the one exported constant.New copy shapes:
⚠️ openai/gpt-5.6-luna request failed (provider overloaded). This is usually temporary — try again shortly.⚠️ openai/gpt-5.6-luna request failed (authentication failed, HTTP 401). Re-authenticate the provider and try again.⚠️ openai/test-model request failed.(no classified reason — parenthetical omitted, facts kept)User Impact
Chat users hitting a provider failure now learn which provider/model failed, why (when classified), and what to do next — without enabling verbose mode. No raw provider response bodies, URLs, or tokens ever reach the user.
Evidence
Unit/regression (fail-pre-fix proven):
node scripts/run-vitest.mjsacross the 5 touched suites — 308 tests green post-fix; pre-fix (source stashed) 4 tests failed withReceived: "LLM request failed."and the generic external text, proving the regression tests target the erasure paths.Live Telegram E2E (Test Server, TDLib userbot, mock provider fault injection): persistent HTTP 503 injected with raw-body canary
E2E_RAW_BODY_CANARY_7731.main@a9303f27e98: bot reply after 3 provider attempts (all 503) was the bareLLM request failed.(Bot API message 3713).ddcb7c2b32e(current headdd027bf7fdfdiffers only by a mechanical module extraction of the unchanged renderer to satisfy max-lines): bot reply⚠️ openai/gpt-5.5 request failed.— provider/model named, deterministic across two runs (3 provider requests each, 4× status=503 in gateway.log).E2E_RAW_BODY_CANARY_7731appears only ingateway.log(internal), 0× in any Telegram-visible event or reply — redaction holds.OPENCLAW_E2E_OK, 1 provider request.Named follow-ups (out of scope here):
Session transcript keyed user is outside the current turn, thrown atsrc/agents/sessions/session-manager-entries.ts:79) whose unclassified text supersedes the classified copy for the same run. Failure-path-only (control run: zero occurrences). Deserves its own issue/fix.Production LOC +107 (facts type, reason table, renderer, delivery wiring — new capability: fact-carrying copy), tests +130.