Repository navigation
fix(errors): report true operation outcome, not false terminal failure — kill/remove + non-terminal tool errors (ENG-15627 §5b/G4) - #53
Conversation
… (ENG-15627 §5b) The process tool's `kill` and `remove` success paths returned details.status:"failed", and the SIGKILL fallback recorded the session as "failed". isToolResultError treats "failed" as an error, so a deliberate, successful agent-requested teardown rendered "⚠️ 🧰 Process failed" in the channel — reporting the mechanical outcome with no knowledge of the agent's intent (the operation-outcome-vs-session-state problem in the ENG-15627 spec §5b). - kill success → details.status:"completed" (was "failed"); a genuine inability to terminate still returns via failText earlier. - remove success → details.status:"completed" (was "failed"). - SIGKILL fallback records the session as "killed" (agent-requested), not "failed", on both paths. Tests assert isToolResultError(result) === false for successful kill/remove (the exact predicate that drives the⚠️ banner) and that the fallback records status:"killed". The genuine-failure paths (no pid, not backgrounded) still return failed. Co-Authored-By: Claude Opus 4.8 <[email protected]>
…s, not "⚠️ … failed" (ENG-15627 G4) When a tool errored but the turn kept going — the assistant already produced a reply and prior tools completed — buildEmbeddedRunPayloads still emitted a terminal "⚠️ ✉️ Message failed" banner, even though core marked it nonTerminalToolErrorWarning=true. That is the over-eager lie: it reads as a hard failure while work actually continued (the "message failed while the agent is still working" report). Reframe the non-terminal case as a progress step that names what completed: "↻ ✉️ Message didn't complete — continued (2 steps completed)". No⚠️ , no "failed". The non-terminal decision is computed once and drives both the visible text and the payload metadata (previously the metadata said non-terminal while the text said failed). Terminal failures (no reply, or non-middleware mutating failures) keep the existing "⚠️ <tool> failed" banner unchanged. Reports the operation outcome as an intermediate status instead of a false terminal error — the G4 half of the ENG-15627 error-conveying guardrails. Co-Authored-By: Claude Opus 4.8 <[email protected]>
…-15627 G4)
The intermediate-status line named the internal tool ('↻ ✉️ Message didn't
complete') — but the tool identity (esp. the 'message' delivery tool) is
plumbing, meaningless and misleading to a user. Replace with a tool-name-free
continuation marker: '↻ A step didn't complete, but I kept going (N steps
completed)'. The real intermediate content is the assistant reply already
emitted alongside it.
Co-Authored-By: Claude Opus 4.8 <[email protected]>
|
I'll analyze this and get back to you. |
There was a problem hiding this comment.
All reported issues were addressed across 5 files
Reply with feedback, questions, or to request a fix.
Fix all with cubic | Re-trigger cubic
🔍 PR Review Summary (Claude superpowers + Codex adversarial)Reviewed at commit 🟡 Findings posted inline
Cross-checked against existing review (not re-raised — both valid, worth addressing before merge)
Methodology
Strengths
— Generated with Claude Code |
…bose detail (ENG-15627 §5b/G4) Three review findings from the adversarial review of #53: - cubic P1: a killed session polled/logged after the kill still rendered as "failed". Add mapFinishedStatusToResultStatus() so both the poll and log finished-session paths map registry status "killed" → result "completed" (agent-requested termination is not a terminal failure). "killed" is produced only by the agent-requested kill/remove paths in this registry, so this can't mask an unexpected kill. - cubic P2: the "N steps completed" count used toolMetas.length, which includes the failing call (pushed unconditionally). Count completed prior steps as max(0, length - 1). - review (verbose): the non-terminal reframe dropped the tool identity + error detail even in /verbose full. Append "<tool>: <error>" to the continuation line when warningPolicy.includeDetails is set, so operators keep the detail while the default user copy stays tool-name-free. Co-Authored-By: Claude Opus 4.8 <[email protected]>
There was a problem hiding this comment.
All reported issues were addressed across 4 files (changes from recent commits).
Reply with feedback, questions, or to request a fix.
Fix all with cubic | Re-trigger cubic
There was a problem hiding this comment.
Approved. Reviewed the full diff against ENG-15627 §5b/G4.
§5b (process kill/remove): kill/remove success now returns details.status:"completed", so isToolResultError (the exact status==='failed'|...|'killed', so mapping to completed is the correct defuse. Genuine failures (no pid / not backgrounded) still return failed via failText before these paths. SIGKILL fallback records the finished-session as killed (agent-requested), and mapFinishedStatusToResultStatus collapses that to completed on later poll/log — so the registry's killed never leaks out as a tool-result status that would re-trip the banner. The killed-poll/log test locks that in.
G4 (non-terminal tool errors): the non-terminal decision (hasUserFacingAssistantReply && middlewareError) is computed once and drives both the visible text and the metadata flag — fixes the prior text/metadata disagreement. Continuation copy is tool-name-free (no leaked message/✉️ plumbing), no toolMetas.length - 1). Verbose retains tool+error detail for operator debug.
Well-scoped, TDD RED→GREEN asserted against the real predicates, no secrets in history, no migrations/API-contract/backward-compat risk, tests green (989/1536/1174 shards + 96 combined), oxlint clean. The full OperationOutcome type + subagent-still-working case are correctly deferred as stated follow-ups. Ship it.
…(ENG-15627 G4 review) Follow-up to the PR #53 review: the "(N steps completed)" count used `toolMetas.length - 1`, which assumes exactly one failure. With more than one transient/middleware error in a turn (e.g. bash ok, read errored, message errored) it overcounted (said 2, only 1 completed). Tag each pushed toolMeta with its `errored` outcome (handlers.tools.ts, from the already-computed `isToolError`) and count only non-errored tools in payloads.ts. Falls back to the previous `length - 1` only when no entry carries an `errored` flag (legacy callers). Threaded `errored?` through the state, attempt, and payload toolMeta types. Test: three tools with two errored → asserts "1 step completed". Co-Authored-By: Claude Opus 4.8 <[email protected]>
…alization boundary (ENG-15627 G4 review) The prior commit tagged each toolMeta with its `errored` outcome and counted completed tools by it — but `runEmbeddedAttempt` re-normalizes toolMetas before they reach `buildEmbeddedRunPayloads`, and that inline map dropped `errored`. So in the real streaming flow the flag never survived and the payload builder always hit the `length - 1` fallback (the very bug the flag was meant to fix). Extract the normalization into `normalize-tool-metas.ts` (so the carried field set is unit-tested) and carry `errored` forward. Behavior otherwise identical: same tool-name filter, replaySafe default, async-task passthrough. Test: normalizeToolMetas preserves `errored` for multi-failure turns, omits it for legacy untagged entries, drops nameless entries, carries async fields. Co-Authored-By: Claude Opus 4.8 <[email protected]>
Bump version to capture on top of boon.3: - #53 (ENG-15627 §5b/G4): report true operation outcome, not false terminal failure — kill/remove + non-terminal tool errors. - #54: surface the Bot Framework/Graph HTTP body on msteams send failures. Base = 2026.6.11-boon.3 (1bfc850). No code change in this commit — version bump only; the fixes are already merged on boon. Co-authored-by: Claude Opus 4.8 <[email protected]>
The prepack changelog gate (scripts/package-changelog.mjs) requires a matching ## <version> section; the boon.4 version bump (#57) omitted it, failing boon-release.yml at the pack step. Add the section (#53 operation-outcome, #54 msteams send-failure body). Verified locally: extractCurrentPackageChangelog finds it. Co-authored-by: Claude Opus 4.8 <[email protected]>
…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-15627 (§5b — operation-outcome vs session-state)
Supersedes #51 and #52 (consolidated into one reviewable unit).
What Problem This Solves
Two instances of the same lie: the runtime reports the mechanical outcome of an operation with no knowledge of the agent's intent or whether work actually continued — so the user sees a hard "failed" when nothing failed.
process kill/remove→ "Why This Change Was Made
§5b — kill/remove (
bash-tools.process.ts):details.status: "completed"(was"failed");isToolResultError(the"killed"(agent-requested), not"failed".failed.G4 — non-terminal tool errors (
payloads.ts):hasUserFacingAssistantReply && middlewareError) is computed once and drives both the visible text and the payload metadata (previously the metadata said non-terminal while the text said failed).↻ A step didn't complete, but I kept going (2 steps completed)— no⚠️ <tool> failedbanner.Scoped: this fixes the two concrete customer-visible instances. The full
OperationOutcometype (disposition/agency/terminality) and the subagent-still-working case are follow-ups.User Impact
An agent tearing down its own process, or hitting a transient tool hiccup during an otherwise-successful turn, no longer emits a false "failed" to the user. Genuine failures are unchanged; group/channel silence and verbose raw-detail are unchanged.
Evidence
isToolResultErrorand the payload metadata — the exact predicates that drive theagents-tools(989),agents-embedded-agent(1536), andcron(1174) shards green; process + payloads suites green (96 combined). oxlint clean.🤖 Generated with Claude Code
Summary by cubic
Fixes false “failed” banners by reporting the true outcome of operations. Agent-requested process teardown now shows success, and non-terminal tool errors render as a continuation status with correct completed-step counts, aligned with Linear ENG-15627 §5b/G4.
kill/removereturndetails.status: "completed"on success; SIGKILL fallback records"killed"(not"failed").poll/logon a killed session map todetails.status: "completed". Genuine inability to terminate/remove still returns failed.erroredflag across streaming vianormalize-tool-metas; types and tests updated to cover this.Written for commit bc99b01. Summary will update on new commits.