Repository navigation
feat(errors): contextual, deterministic error messages instead of generic "message failed" (ENG-15739) - #50
Conversation
…15739) Replace the single generic "message failed" string with class-specific, customer-safe copy on the run-failure path, wiring the previously schema-only ENG-15627 GatewayFailureCode taxonomy into the emit path. - New resolveGatewayFailureCode() maps a thrown FailoverError / FallbackSummaryError / raw error to a deterministic gateway-failure code by composing the existing failover classifiers (no new heuristics), so its verdict always agrees with the failover ladder. Same class in -> same copy out. - New boon_core_unreachable code + classifier for project-data connectivity failures, scoped so it never fires on a generic provider transport error. - Both twin failure paths (buildKnownAgentRunFailureReplyPayload and the inline runAgentTurnWithFallback loop) route coded copy through the existing resolveExternalRunFailureTextForConversation gate, so group/channel silence is byte-identical to before -- only DMs (and disallow-policy surfaces) get the improved copy. Verbose mode and control-UI keep their raw operator detail; the richer bespoke branches (billing cooldown, rate-limit, missing-key, oauth, cli-timeout, codex) run first and are unchanged. - Still-running / mid-stream / self-restart turns are unaffected: the abort, drain, lane-cleared and retry gates short-circuit before the failure path, so they never emit "failed". subagent_still_working is intentionally left unwired (no terminal signal should claim it will follow up). Tool/skill-specific naming was scoped out after confirming tool failures already surface through a dedicated, tool-name-aware warning path (buildEmbeddedRunPayloads -> resolveToolErrorWarningPolicy) and never reach the generic string. Tests: new gateway-failure-code.test.ts (per-class mapping, dominant-reason precedence, determinism, boon-core detection); message-origin.test.ts covers the new code; agent-runner-execution.test.ts flips the previously-generic assertions to coded copy while preserving non-direct silence, disallow-policy surfacing, and verbose raw-detail behavior. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
|
I'll analyze this and get back to you. |
There was a problem hiding this comment.
cubic analysis
All reported issues were addressed across 6 files
Linked issue analysis
Linked issue: ENG-15739: Contextual error messages (P0) — replace generic "message failed" with specific, deterministic error text
| Status | Acceptance criteria | Notes |
|---|---|---|
| ✅ | The generic "message failed" string is removed from the customer-facing path; every surfaced error maps to a specific class from the taxonomy above. | The PR adds resolveGatewayFailureCode and routes coded copy through the existing run-failure gates; tests assert deterministic mappings and replace previous generic-string assertions with coded outputs. |
| A still-running / mid-stream / self-restarting turn NEVER surfaces a "failed" notification (false-positive rate → 0 for the daily false-alarm case). | PR preserves the abort/drain/retry gates and leaves subagent_still_working unwired so it should not emit the terminal-failure path; however I don't see an explicit unit test in this diff that simulates a mid-stream/still-running turn and asserts no "failed" notification. | |
| Each real failure names the step (skill/tool) + a plain-language cause, deterministically (same failure → same message). | The PR provides deterministic, class-specific copy for gateway-level failure classes (rate-limit, quota, malformed history, upstream 5xx, boon-core unreachable). However tool/skill-specific naming is explicitly scoped out of this path (the PR documents that tool-name-aware warnings are handled on a different path), so this PR does not add step/tool naming for failures that would be expected to be surfaced by this generic-runner path. | |
| ✅ | Customer-facing copy is M-92-warm and leaks no architecture/model/provider internals. | The code adds customer-safe copy entries and tests explicitly check that the new 'boon_core_unreachable' message is scoped to project-data wording and does not leak internals. |
| ❌ | Verified on Arguijo's host: force one of each class (provider overload, quota, hard 502, still-running long turn) and confirm the correct distinct message — and that the still-running case is silent on 'failed'. | PR notes that live verification on Arguijo's host and copy review will be performed post-deploy; those manual acceptance checks are not yet present in the repository evidence. |
Reply with feedback, questions, or to request a fix.
Fix all with cubic | Re-trigger cubic
…atch (ENG-15739) The first pass also wired coded copy into buildKnownAgentRunFailureReplyPayload, whose generic fall-through returns undefined so agent-runner.ts rethrows. That is the OUTER catch for errors that escaped runAgentTurnWithFallback entirely (pre-run maintenance crashes, restart lifecycle, truly unexpected exceptions) — not the classified LLM-completion failures, which runAgentTurnWithFallback already converts to a coded kind:"final" payload. Swallowing the escaped error into a coded reply broke the "let unexpected exceptions propagate" contract (agent-runner-direct-runtime-config.test.ts expected runReplyAgent to reject). Revert that site to `return undefined`; ENG-15739 lives solely at the run-turn emitter (Site 2), which is the actual customer-facing generic-string path. Retarget the new coverage to drive runAgentTurnWithFallback with real FailoverErrors instead of calling the outer catch directly. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
There was a problem hiding this comment.
All reported issues were addressed across 2 files (changes from recent commits).
Reply with feedback, questions, or to request a fix.
Fix all with cubic | Re-trigger cubic
…ad-code, group-silence test (ENG-15739) Addresses cubic-dev-ai review on PR #50: - Terminal-safe copy: resolveCodedGenericFailureText runs only at exhausted failure, so any code whose affordance is will_auto_retry ("I'm retrying automatically") is downgraded to agent_failed_transient_after_retries ("automatic retries didn't recover. Please try again") — no stale retry claim. - boon_core_unreachable affordance corrected will_auto_retry -> user_can_retry so its scoped copy (which tells the user to retry) survives that downgrade. - isBoonCoreUnreachableError now includes econnaborted (+ epipe), so a timed-out/aborted boon-core request stays on the dedicated project-data path instead of being misclassified as a provider failure. - resolveGatewayFailureCode is total; its return type is now non-optional and the dead GENERIC_EXTERNAL_RUN_FAILURE_TEXT fallback in resolveCodedGenericFailureText is removed (dropped the now-unused resolveEmittableGatewayFailure import). - Re-added the group-chat silence coverage (dropped in the Site-1 -> Site-2 test migration) as a runAgentTurnWithFallback integration test asserting SILENT_REPLY_TOKEN. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
There was a problem hiding this comment.
Approve — this is a careful, well-scoped fix for the ENG-15739 P0 (Arguijo/Jon generic-error). Reviewed the full diff and traced the key claims against base.
What holds up:
- Composition over new heuristics.
resolveGatewayFailureCodereduces to a single code purely by composing the existing failover classifiers (FailoverError.reason,resolveDominantFailoverReason,isProviderConversationStateErrorMessage, allocation/context-overflow helpers) — so its verdict always agrees with the failover ladder. Deterministic, and the tests prove it. - Group silence is genuinely byte-identical.
resolveCodedGenericFailureTextroutes coded copy through the SAMEresolveExternalRunFailureTextForConversationgate withisGenericRunnerFailure: true, so non-direct chats returnSILENT_REPLY_TOKENunlessdisallowpolicy already surfaced failures. The follow-on outer gate call then passesisGenericRunnerFailure: falsewhen coded text is present — verified this avoids double-silencing in both the silent (group) and surfaced (DM) branches. Correct. - Terminal-safe downgrade. Any
will_auto_retrycode is downgraded toagent_failed_transient_after_retriesat the exhausted-failure emitter, so no stale 'retrying automatically' lie.boon_core_unreachableis correctly setuser_can_retryso its scoped copy survives that downgrade. - Scoped boon_core detection — keyed on the boon-core host + a connection-class signal, with a test asserting
ECONNABORTED api.anthropic.com-> false. Won't misfire on provider transport errors. - Site-1 revert (commit 2) correctly preserves the 'let unexpected exceptions propagate' contract at the outer catch; ENG-15739 lives solely at the run-turn emitter.
- Type-level completeness: the new
boon_core_unreachableis added to bothCODE_COPYandCODE_RETRY_AFFORDANCERecord<GatewayFailureCode,...>maps, so a missed entry would fail tsc. - Copy is customer-safe (no provider/model/architecture leaks) and warm. Tests cover per-class mapping, dominant-reason precedence, determinism, group silence, DM surfacing, disallow surfacing, and the terminal downgrade.
Non-blocking note (informational only): REASON_PRECEDENCE in the FallbackSummaryError reducer omits empty_response/no_error_details/unclassified/unknown, so a summary composed purely of those returns undefined -> falls through to the transient class. That's the correct outcome, just flagging it's intentional-by-omission.
Live per-class verification on Arguijo's host + copy review with Deepti/Arjun are explicitly deferred to post-deploy per the ticket ACs — reasonable, since forcing each class needs the live customer host. Ship it.
…rail (ENG-16330) (#62) * feat(errors): intelligent-messaging core — outcome-aware surfacing classifier + path trail (ENG-16330) Pure-logic core (no wiring yet) for extending #53's outcome-awareness to the recovered-non-zero-exec class: classifyToolSurfacing (passthrough | immediate | buffer-recoverable), a per-turn error buffer that on turn-SUCCESS hides the recovered⚠️ failed badges and emits a human-readable path trail, on turn-FAILURE flushes them as real failures (no #53/#47/#48/#50 regression), and sanitizeGeneratedSessionName (salty-shore → "a background command"). Model-facing isToolResultError untouched. 10/10 unit tests green. Handler/turn-close wiring (handleToolExecutionEnd buffer + handleMessageEnd flush) follows in the next commit. Co-Authored-By: Claude Opus 4.8 <[email protected]> * feat(errors): wire intelligent-messaging buffer into tool-end + turn-close (ENG-16330) Wires the tested core into the streaming path: - handlers.types: add per-turn `intelligentMessagingBuffer?: TurnErrorBuffer` to state (+ Pick). - handleToolExecutionEnd: classifyToolSurfacing → a "buffer-recoverable" exec/tmux/process error is recorded to the per-turn buffer instead of emitting the live⚠️ badge (terminal auth/quota/delivery errors + non-recoverable tools still emit immediately; model-facing isToolResultError unchanged). - handleMessageEnd (turn close): resolve the buffer — success (normal stopReason + non-empty reply, confabulation guard) → emit a neutral path-trail note; failure → flush honest failure badges (no #53/#47/#48/#50 regression); clear buffer to prevent double-emit. Verified: 107/107 tests green (10 new intelligent-messaging + 97 existing handler/media, no regression); tsc + oxlint clean on all changed files. Co-Authored-By: Claude Opus 4.8 <[email protected]> * fix(errors): don't skip after_tool_call hook when buffering a recoverable error (ENG-16330) The buffer branch early-returned before the after_tool_call plugin-hook fire + stream boundary, so a buffered recoverable exec/process error suppressed the hook (broke after-tool-call.fires-once + owned-tool-runtime-contract tests). Gate ONLY the emitToolResultOutput call on the buffering decision (if/else); the hook + stream boundary now run in all cases. Buffering defers the channel badge only, never plugin hooks. Verified: the 2 previously-failing agents-core tests + core + handler tests → 87/87 green. Co-Authored-By: Claude Opus 4.8 <[email protected]> * fix(errors): address cubic review on ENG-16330 turn-close buffer resolution (PR #62) - P1: only resolve the buffer on a TERMINAL assistant outcome (stop/end_turn); a toolUse (in-progress) turn leaves the buffer intact so continuing tool steps + the real final reply still reach it — no premature failure flush mid-turn. - P1: clear the buffer at the suppressVisibleAssistantOutput (commentary) early return so a commentary-phase turn's buffered errors can't leak into the next turn. - P2: gate both path-trail + failure-badge emissions on ctx.shouldEmitToolOutput() (respect non-full verbosity / output-disabled). - P2: success guard now accepts a media-only silent reply (cleanedText empty + hasMedia) as a valid successful turn, not a false failure. - P2: add a test for the looksTerminal branch (recoverable tool + terminal signal unauthorized/forbidden/quota/invalid_api_key → "immediate", not buffered). Verified: 88/88 green (core + the 2 prior-regression tests + handlers); tsc + oxlint clean. Co-Authored-By: Claude Opus 4.8 <[email protected]> * test(errors): cover tmux buffer-recoverable classification (cubic P2, PR #62) tmux is in RECOVERABLE_TOOL_NAMES alongside exec/process but was untested; add the missing classifyToolSurfacing case. 12/12 green. Co-Authored-By: Claude Opus 4.8 <[email protected]> * fix(errors): flush buffered failures on ALL terminal outcomes; keep buffer across commentary steps (cubic P1 round 2, PR #62) Two round-2 P1s from cubic, both my prior over-correction: - terminalOutcome was `stop || end_turn`, so error/abort/length/max_tokens turns silently DROPPED buffered non-zero tool failures. `toolUse` is the only CONTINUING outcome — flip to `stopReason !== "toolUse"` so every terminal result resolves the buffer; the turnSucceeded guard already picks success (path trail) vs. failure (honest badges). - clearing the buffer at the suppressVisibleAssistantOutput (commentary) early return dropped earlier-in-turn recoverable errors before the real terminal reply could surface them. A commentary step is mid-turn, not a boundary — leave the buffer intact (same as the non-assistant/transcript-only return); only the terminal outcome resolves/clears it. Verified: 89/89 green (core + handlers + the 2 prior-regression tests); tsc clean. Co-Authored-By: Claude Opus 4.8 <[email protected]> --------- Co-authored-by: Claude Opus 4.8 <[email protected]>
…inal status (ENG-16330) The user-facing "⚠️ 🧰 Process: <session> failed" badge is built at buildEmbeddedRunPayloads (payloads.ts) from ctx.state.lastToolError, NOT by emitToolResultOutput. A backgrounded exec/process/tmux session that exits non-zero but which the agent recovers from — the turn still produces a real reply — rendered a terminal "failed" badge, giving the user the wrong intuition ("the agent broke"). Widen shouldMarkNonTerminalToolErrorWarning from middlewareError-only to also treat a recovered exec/bash/process/tmux error as non-terminal. The caller already gates this on hasUserFacingAssistantReply, so the reframe only fires when the turn actually produced a reply; on a reply-less genuine failure the honest "⚠️ … failed" badge still surfaces (no #53/#47/#48/#50 regression). write/edit/message stay strict — a failed write with a "done" reply is still flagged as confabulation. Reuses the shipped ENG-15627 G4 continuation note ("↻ A step didn't complete, but I kept going"); no new copy, no raw generated session names. Supersedes the buffer approach in PR #62, which intercepted emitToolResultOutput (live streamed output) — a different sink from the badge, so the badge was never reached. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
…inal status (ENG-16330) (#64) * fix(errors): reframe recovered exec/process/tmux failures as non-terminal status (ENG-16330) The user-facing "⚠️ 🧰 Process: <session> failed" badge is built at buildEmbeddedRunPayloads (payloads.ts) from ctx.state.lastToolError, NOT by emitToolResultOutput. A backgrounded exec/process/tmux session that exits non-zero but which the agent recovers from — the turn still produces a real reply — rendered a terminal "failed" badge, giving the user the wrong intuition ("the agent broke"). Widen shouldMarkNonTerminalToolErrorWarning from middlewareError-only to also treat a recovered exec/bash/process/tmux error as non-terminal. The caller already gates this on hasUserFacingAssistantReply, so the reframe only fires when the turn actually produced a reply; on a reply-less genuine failure the honest "⚠️ … failed" badge still surfaces (no #53/#47/#48/#50 regression). write/edit/message stay strict — a failed write with a "done" reply is still flagged as confabulation. Reuses the shipped ENG-15627 G4 continuation note ("↻ A step didn't complete, but I kept going"); no new copy, no raw generated session names. Supersedes the buffer approach in PR #62, which intercepted emitToolResultOutput (live streamed output) — a different sink from the badge, so the badge was never reached. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]> * fix(errors): drop inert tmux from recoverable exec class (ENG-16330, cubic P2) tmux is neither in MUTATING_TOOL_NAMES nor exec-like, so resolveToolErrorWarningPolicy already sets showWarning=false (no badge at all) once a reply exists — it never reached shouldMarkNonTerminalToolErrorWarning. Listing it was dead code implying a path that never fires. Remove it and document why it's intentionally absent. Recovered exec/bash/process reframe unchanged; 60/60 tests green. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]> * revert(errors): unwind #62 buffer/path-trail; keep single payloads.ts reframe (ENG-16330) #62 (merged) buffered the emitToolResultOutput call and added a turn-close '🔧 Recovered…' path-trail note — but that is a DIFFERENT sink from the actual badge. The '⚠️ 🧰 Process: <session> failed' badge is built in buildEmbeddedRunPayloads (payloads.ts) from ctx.state.lastToolError, which handleToolExecutionEnd still sets unconditionally regardless of the buffer. So on boon today the badge STILL fires alongside #62's new note — the user gets both, and the headline symptom is unfixed. This PR's payloads.ts reframe fixes the real sink. Keeping #62's machinery on top would emit two redundant recovery notes (🔧 + ↻) and leaves two overlapping paths for one behavior. Per one-canonical-path policy, unwind #62: - delete src/agents/intelligent-messaging.ts + its test - restore the 3 handler files (messages/tools/types) to pre-#62 state Net result: one seam — shouldMarkNonTerminalToolErrorWarning reframes recovered exec/bash/process errors on a successful turn into the shipped G4 note; reply-less genuine failures keep the honest badge; write/edit/message stay strict. 60/60 payloads.errors + 69/69 handlers.tools green. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]> --------- Co-authored-by: Claude Opus 4.8 (1M context) <[email protected]>

Related: ENG-15739
What Problem This Solves
Fixes an issue where customers (Arguijo/Jon, reported on the 2026-07-14 call — Deepti flagged this a P0) see one identical generic error — "⚠️ Something went wrong while processing your request…" — for every kind of failure, and worse, see it fire even when the turn is still running. Jon can't tell a real failure from a keep-working state, so he re-checks manually and loses confidence in every skill. The affected surface is the customer chat channel (Slack / Teams / Google Chat) on the boon-agent gateway.
Why This Change Was Made
The single generic string is emitted on the run-failure path. ENG-15627 (G5) already landed a schema-only
GatewayFailureCodetaxonomy — per-code, customer-safe copy + retry affordance — but nothing was wired to it. This PR wires it in:resolveGatewayFailureCode()maps a thrownFailoverError/FallbackSummaryError/ raw error to a deterministic code by composing the existing failover classifiers (no new heuristics), so its verdict always agrees with the failover ladder — same failure class in → same copy out.boon_core_unreachableclass + a scoped classifier for project-data connectivity failures (never fires on a generic provider transport error).buildKnownAgentRunFailureReplyPayloadand the inlinerunAgentTurnWithFallbackloop) route coded copy through the existingresolveExternalRunFailureTextForConversationgate, so group/channel silence is byte-identical — only DMs (anddisallow-policy surfaces) get the improved copy. Verbose mode and control-UI keep their raw operator detail; the richer bespoke branches (billing cooldown, rate-limit, missing-key, oauth, cli-timeout, codex) run first and are unchanged.Boundaries / non-goals:
subagent_still_workingis intentionally left unwired — no terminal signal should claim it will follow up.buildEmbeddedRunPayloads→resolveToolErrorWarningPolicy) and never reach the generic string, so a second path would duplicate mature behavior.User Impact
Customers now get a specific, plain-language line per failure class — quota/allocation, provider overload (auto-retrying), upstream 5xx (auto-retrying), malformed session (start fresh), context too large, project-data unreachable, or a safe transient fallback — instead of one catch-all. A still-running turn stays silent on "failed". Copy is M-92-warm and leaks no provider/model/architecture internals. Group/channel behavior is unchanged.
Evidence
npx tsc --noEmit: 0 errors. oxlint + oxfmt clean.gateway-failure-code.test.ts(per-class mapping, dominant-reason precedence, determinism, boon-core detection),message-origin.test.ts(new code),agent-runner-execution.test.ts(previously-generic assertions flipped to coded copy; non-direct silence,disallowsurfacing, and verbose raw-detail all preserved).🤖 Generated with Claude Code
Summary by cubic
Replaces the generic “message failed” with deterministic, contextual error messages for agent run failures (ENG-15739). Preserves group/channel silence and avoids false “failed” notices while a turn is still running.
New Features
resolveGatewayFailureCode()to mapFailoverError/FallbackSummaryError/raw errors to stablemessage-origincodes; DMs show the canonical copy.boon_core_unreachablefor project-data connectivity issues, distinct from provider transport errors.runAgentTurnWithFallbackvia the existing conversation gate; verbose mode and control-UI keep raw detail.Bug Fixes
buildKnownAgentRunFailureReplyPayload’s generic fall-through now returnsundefinedagain so unexpected exceptions propagate.agent_failed_transient_after_retriesto avoid stale “retrying automatically” claims;boon_core_unreachableaffordance set touser_can_retry.ECONNABORTED/EPIPE; never fires on generic provider transport errors; group silence verified with an integration test.Written for commit 911ce93. Summary will update on new commits.