Repository navigation
fix(errors): intelligent messaging — outcome-aware surfacing + path trail (ENG-16330) - #62
Conversation
…assifier + 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]>
…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]>
|
Claude encountered an error —— View job I'll analyze this and get back to you. |
There was a problem hiding this comment.
cubic analysis
All reported issues were addressed across 5 files
Linked issue analysis
Linked issue: ENG-16330: Intelligent Messaging — outcome-aware status (improve on error guardrails)
| Status | Acceptance criteria | Notes |
|---|---|---|
| ✅ | Successful turn with recovered non-terminal sub-failure shows success to the user (no |
Code buffers recoverable exec/process/tmux errors (classifyToolSurfacing → "buffer-recoverable"), records them per-turn, and at turn close emits a synthesized path-trail when the turnSucceeded guard is true. Unit tests exercise the buffer → success path. |
| ✅ | A genuinely failed turn still shows an honest, coded failure message (no regression of prior guardrails). | Buffered entries are flushed as failure badges when resolve({turnSucceeded: false}) is used; the handler emits those badges on failure, preserving honest failure surfacing. |
| Confabulated success (agent claims success but expected tool never ran/errored) remains flagged (confabulation guard preserved). | The PR includes a confabulation guard at turn-close (requires a non-empty final reply and stopReason) and states model-facing error semantics are unchanged. However, this change focuses on buffering/re-surfacing of recoverable errors; there is no new explicit confabulation-detection logic in the added module — it appears to rely on existing guardrails. Evidence for preservation is present but indirect, so this is partly verified here. | |
| ✅ | No internal generated session names or raw filesystem/tool error strings leak into the user-facing reply. | Synthesized path-trail sanitizes generated session names (replaces adjective-noun names with a generic phrase) and reduces step summaries to user-friendly phrases; tests assert sanitized output and absence of raw session names. |
Tip: instead of fixing issues one by one fix them all with cubic
Re-trigger cubic
…able 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]>
There was a problem hiding this comment.
Approved — traces cleanly to ENG-16330 and fulfills the outcome-aware-suppression goal.
Correctness
classifyToolSurfacingbuffers only recoverable exec/tmux/process errors; terminal signals (allocation_exhausted/unauthorized/quota/…) correctly short-circuit toimmediate, so auth/quota/delivery failures are never silenced.handleMessageEndresolution has a sound confabulation guard (normal stopReason and non-empty final reply), and clears the buffer to prevent double-emit on a later message_end.cleanedText/assistantMessageare in scope at the insertion point.- Model-facing
isToolResultErrorleft unchanged — the model still sees the true non-zero exit; only the channel badge defers.
Regression safety
- Only the
emitToolResultOutputcall is gated; the after_tool_call hook + stream boundary still fire in both branches (the 3rd commit specifically fixes the hook-suppression regression, restoring after-tool-call.fires-once + owned-tool-runtime-contract). - No #53/#47/#48/#50 regression: failed turns flush honest failure badges.
Tests / quality
- 10 new pure-logic unit tests cover classifier, buffer success/failure/empty, name sanitization, trail synthesis; 107/107 green, tsc + oxlint clean. No secrets in diff or commit history, no migrations, no breaking API changes.
Minor (non-blocking): in message_end mode the path-trail note emits just before onBlockReplyFlush completes the final chunk — cosmetic ordering only since it's a tool-status surface, not the block reply.
Good code — ship it.
…lution (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]>
… 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]>
There was a problem hiding this comment.
All reported issues were addressed across 2 files (changes from recent commits).
Tip: Review your code locally with the cubic CLI to iterate faster.
Fix all with cubic | Re-trigger cubic
…uffer 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]>
✅ End-to-end tested live on a Boon trial hostBuilt this branch as ReproPrompt to the agent in Slack:
Result (verbatim from the channel)The agent backgrounded the exec (auto-named session
Notes
Unrelated CI note
|
insomnius
left a comment
There was a problem hiding this comment.
Approved. End-to-end tested live on a Boon trial host (boon.6): recovered non-zero backgrounded exec surfaces the 🔧 path-trail note instead of a false
…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]>
… 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]>
…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]>
What
Extends the error-guardrails work (#53/ENG-15627 §5b + #47/#48 + #50) to the recovered-non-zero-exec class: a backgrounded
exec/tmux/processsession that exits non-zero but which the agent recovers from (the turn continues and produces a real answer) no longer renders a misleading⚠️ 🧰 Process: <session-name> failedto the channel. Instead the user sees an accurate path-trail note ("🔧 Recovered from a file lookup and continued").Why
Observed live post-boon.5 (error-guardrails active): gandalf
⚠️ Process: salty-shore failed, power-solutions triagefind … failed.salty-*are auto-generated bg-exec session names. The user gets the wrong intuition ("the agent broke") when the truth is "a sub-step hit a recoverable error; the agent handled it and is on-path." #53 already suppressed this for theprocesskill/remove case; this reaches the class it didn't.How
New
src/agents/intelligent-messaging.ts(pure, unit-tested):classifyToolSurfacing→passthrough | immediate | buffer-recoverable. Recoverable = exec/tmux/process error that is not terminal; terminal signals (auth/quota/delivery:allocation_exhausted,unauthorized, …) surface immediately, never buffered.createTurnErrorBuffer— per-turn buffer;.resolve({turnSucceeded})→ on success hides the badges + returns a path trail, on failure flushes them as honest failure badges.sanitizeGeneratedSessionName—salty-shore→ "a background command" (no raw generated names in user-facing text).Wiring:
handleToolExecutionEnd— abuffer-recoverableresult is recorded toctx.state.intelligentMessagingBufferinstead of emitting the livehandleMessageEnd(turn close) — resolve the buffer: success = normalstopReason(stop/end_turn) and a non-empty final reply (confabulation guard) → emit the path-trail note; failure → flush honest failure badges (no fix(errors): report true operation outcome, not false terminal failure — kill/remove + non-terminal tool errors (ENG-15627 §5b/G4) #53/fix(errors): stop leaking raw provider errors to users — allocation_exhausted + unclassified passthrough (ENG-15627 G1+G2) #47/feat(errors): add MessageOrigin gateway-failure code schema (ENG-15627 G5) #48/feat(errors): contextual, deterministic error messages instead of generic "message failed" (ENG-15739) #50 regression); clear the buffer.Model-facing
isToolResultErroris unchanged — the model still sees the true non-zero exit; only the channel-surfacing layer changes.Tests
intelligent-messaging.test.ts: 10 unit tests (classifier, buffer success/failure/empty, name sanitization, trail synthesis).handlers.tools+handlers.tools.media— no regression). tsc + oxlint clean on all changed files.Follow-ups
docs/superpowers/specs/2026-07-20-intelligent-messaging-design.md.🤖 Generated with Claude Code
Summary by cubic
Outcome-aware intelligent messaging: recovered non‑zero
exec/tmux/processerrors are buffered and, on a successful turn, shown as a short path‑trail note instead of a⚠️ … failedbadge. Terminal errors still surface immediately; model-facing error semantics are unchanged.New Features
handleToolExecutionEnd; resolve inhandleMessageEndon all terminal outcomes (anything excepttoolUse), count non-empty text or media‑only replies as success, and gate emissions viactx.shouldEmitToolOutput().Bug Fixes
after_tool_callhooks or the stream boundary.toolUsemessage_end events; keep the buffer across suppressed‑output commentary steps; resolve on all terminal outcomes (including error/abort/length/max_tokens) and clear after resolution.Written for commit 3488c91. Summary will update on new commits.