Skip to content

fix(errors): reframe recovered exec/process/tmux failures as non-terminal status (ENG-16330) - #64

Merged
convyusboy merged 3 commits into
boonfrom
ridho/eng-16330-nonterminal-exec-badge-seam
Jul 23, 2026
Merged

convyusboy merged 3 commits into
boonfrom
ridho/eng-16330-nonterminal-exec-badge-seam

Conversation

@convyusboy

@convyusboy convyusboy commented Jul 22, 2026 •

Copy link
Copy Markdown
Collaborator

What Problem This Solves

Since the error-guardrails work shipped (#53 / ENG-15627 §5b/G4, #47/#48, #50), the agent over-reports: a backgrounded exec/bash/process/tmux session that exits non-zero but which the agent recovers from — the turn still produces a real final reply — renders a terminal ⚠️ 🧰 Process: <session> failed badge to the customer. The user sees "failed" and infers the agent broke, when the task actually completed (e.g. gandalf salty-shore, power-solutions triage find … failed; salty-* are auto-generated bg-exec session names).

Why This Change Was Made

The scary badge is built at buildEmbeddedRunPayloads (payloads.ts) from ctx.state.lastToolError, not by emitToolResultOutput (which only streams live tool output text and returns early on error). So the correct seam is shouldMarkNonTerminalToolErrorWarning, which already drives the shipped G4 continuation-note reframe.

This widens that predicate from middlewareError-only to also treat a recovered exec/bash/process/tmux error as non-terminal. The caller already gates on hasUserFacingAssistantReply, so the reframe fires only when the turn produced a real reply:

Reuses the shipped ENG-15627 G4 copy — no new user-facing strings, no raw generated session names.

User Impact

Customers no longer see a false terminal ⚠️ … failed badge when the agent hit a recoverable sub-step error and completed the task anyway. Genuinely failed turns and confabulated successes are still flagged exactly as before.

Evidence

  • src/agents/embedded-agent-runner/run/payloads.errors.test.ts: 60/60 green, including new guards for the salty-shore bg-process case, exec non-zero exit, exec timeout reframe, and the reply-less regression guard (asserts ⚠️/failed/🧰/raw session name are all absent on the recovered case, present on the reply-less failure).
  • node scripts/run-vitest.mjs src/agents/embedded-agent-runner/run/payloads.errors.test.ts → 60 passed.
  • Model-facing isToolResultError semantics untouched — the model still sees the true non-zero exit.

Supersedes the buffer approach in #62, which intercepted emitToolResultOutput (live streamed output) — a different sink from the badge, so the badge was never reached. #62 left open pending decision.

🤖 Generated with Claude Code


Summary by cubic

Prevents false "⚠️ … failed" badges when a recovered exec/bash/process error occurs but the turn still completes by reframing it as a continuation note. Simplifies to a single seam in payloads.ts; genuine failures and confabulation checks remain unchanged. Addresses Linear ENG-16330.

  • Bug Fixes
    • Expanded shouldMarkNonTerminalToolErrorWarning to mark recovered exec/bash/process errors as non-terminal when a user-facing reply exists; intentionally excluded tmux (already suppressed once a reply exists).
    • Centralized the behavior in buildEmbeddedRunPayloads; removed the buffering/path-trail code and reverted handler wiring (intelligent-messaging.* deleted).
    • Preserved model-facing isToolResultError semantics; no relabeling of real non-zero exits.
    • Reused existing G4 continuation copy and sanitized raw session names from user-facing text.
    • Updated tests for exec timeout/non-zero and bg-process exits (reframed), plus a reply-less failure guard that still surfaces the terminal badge.

Written for commit 652e6ee. Summary will update on new commits.

Review in cubic

@claude

claude Bot commented Jul 22, 2026 •

Copy link
Copy Markdown

Claude encountered an error —— View job


I'll analyze this and get back to you.

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cubic analysis

All reported issues were addressed across 2 files

Linked issue analysis

Linked issue: ENG-16330: Intelligent Messaging — outcome-aware status (improve on error guardrails)

Status Acceptance criteria Notes
✅ Recovered non-terminal sub-failures on a successful turn do not render a terminal '⚠️ … failed' badge (show success / continuation note instead) PR widens the non-terminal predicate to include recovered exec/bash/process/tmux errors when there is a user-facing reply, and tests assert the warning payload contains no ⚠️/failed and matches continuation-note language.
✅ Genuinely failed turns still surface an honest, coded failure (no regression of prior guardrails) The reframing is gated on presence of a user-facing assistant reply; when there is no reply the tests assert the terminal badge is still emitted. Existing model-facing error semantics are preserved.
✅ Confabulated successes (agent claims done while tool never ran/errored) remain flagged (no over-suppression) The code keeps write/edit/message strict and only treats command-exec-class tools as recoverable; reframing only applies when there's a user-facing reply. That preserves the confabulation checks. Tests exercise related guards and the PR description documents this explicitly.
✅ No internal job/session names or raw filesystem/tool error strings leak into customer-facing messages Tests explicitly assert the reframed warning text does not contain raw session names or raw error text, and the PR reuses the existing G4 continuation copy instead of the raw error lines.

Reply with feedback, questions, or to request a fix.

Fix all with cubic | Re-trigger cubic

convyusboy and others added 3 commits July 22, 2026 22:28
…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]>
…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]>
… 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]>
@convyusboy
convyusboy force-pushed the ridho/eng-16330-nonterminal-exec-badge-seam branch from aa986e9 to 652e6ee Compare July 22, 2026 15:47
@convyusboy

Copy link
Copy Markdown
Collaborator Author

Heads-up @monac24 — this PR now unwinds the buffer/path-trail machinery from #62 and keeps a single seam. Wanted to flag it directly since it touches your just-merged code.

Why: #62's buffer wraps the emitToolResultOutput call, but the ⚠️ 🧰 Process: <session> failed badge isn't built there — emitToolResultOutput returns early on error and never renders a badge. The badge is built in buildEmbeddedRunPayloads (payloads.ts) from ctx.state.lastToolError, which handleToolExecutionEnd still sets unconditionally, independent of the buffer. I verified this on current boon after your merge:

  • handlers.tools.ts — ctx.state.lastToolError = { … } still runs before the buffer branch.
  • payloads.ts — shouldMarkNonTerminalToolErrorWarning is still middlewareError-only.

So the salty-shore badge still fires on boon today, now alongside the new 🔧 Recovered… note — the user gets both, and the headline symptom is unfixed. Layering this PR's reframe on top of the buffer would emit two redundant recovery notes (🔧 + ↻).

What this PR does instead: widen shouldMarkNonTerminalToolErrorWarning (the real sink) to reframe recovered exec/bash/process errors on a successful turn into the shipped ENG-15627 G4 note (↻ A step didn't complete, but I kept going). Reply-less genuine failures keep the honest badge; write/edit/message stay strict (confab guard, #53). Per the one-canonical-path guideline I removed intelligent-messaging.ts + its test and restored the 3 handler files to their pre-#62 state.

Net: 5 files changed, +9 / −404. 60/60 payloads.errors + 69/69 handlers.tools green. Happy to walk through the trace if you'd rather keep the buffer approach and harden it instead — but it'd need to hook the lastToolError/payloads.ts sink to actually drop the badge.

@gandalfboon gandalfboon Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved — verified live, not from memory.

What I checked

  • Traced the real seam: process is in MUTATING_TOOL_NAMES, so a non-zero bg-process exit on a turn with a reply hits the mutating branch of resolveToolErrorWarningPolicy (showWarning=true) and previously rendered the terminal ⚠️ 🧰 Process: <session> failed badge. Widening shouldMarkNonTerminalToolErrorWarning to the recoverable exec class reframes it into the shipped G4 ↻ … kept going note. The salty-shore symptom is genuinely fixed at the correct sink (not the emitToolResultOutput sink #62 wrongly targeted).
  • Gate is correct: isNonTerminalWarning = hasUserFacingAssistantReply && shouldMark…, so reply-less genuine failures keep the honest badge (confirmed by the new regression-guard test). Model-facing isToolResultError untouched.
  • tmux correctly dropped — not exec-like and not mutating, so resolveToolErrorWarningPolicy already returns showWarning=false once a reply exists; listing it was dead.
  • #62 unwind is clean (intelligent-messaging + its test deleted, handlers reverted to single-path). No duplicate 🔧/↻ notes.
  • Ran the suite locally on this branch (non-verbose defaults, i.e. real customer path): node scripts/run-vitest.mjs …/payloads.errors.test.ts → 60/60 passed.

One non-blocking observation (follow-up, not a blocker)
shouldMarkNonTerminalToolErrorWarning keys on toolName === "process" only — it does not consult lastToolError.mutatingAction. I verified with a probe that a mutating process action (kill/remove/write/send_keys/paste/submit/clear) that errors on a turn with a reply is now also reframed to ↻ A step didn't complete, but I kept going instead of ⚠️ … failed. That slightly contradicts the PR's own stated principle ("a failed write with a 'done' reply is confabulation → stay strict"): a failed process kill with a "cleaned up the job" reply is the same confabulation shape. exec/bash don't have this issue (exec-like → showWarning=false in non-verbose, so the reframe isn't reached). Consider gating on !mutatingAction for process. Minor — the model still sees the true error and this only affects channel wording on a turn that produced a real reply, so it doesn't block the approval.

Nice, focused fix. Ship it.

@convyusboy
convyusboy merged commit c506d5b into boon Jul 23, 2026
145 of 146 checks passed
@convyusboy
convyusboy deleted the ridho/eng-16330-nonterminal-exec-badge-seam branch July 23, 2026 07:44
convyusboy added a commit that referenced this pull request Jul 23, 2026
Bump gateway + @openclaw/slack + @openclaw/msteams to 2026.6.11-boon.7 in
lockstep (package.json + npm-shrinkwrap.json roots) and add the CHANGELOG entry.
Ships the boon.7 train: #70 (ENG-16418 concise + A/B/C overlay for Claude),
#68 (ENG-16200 progress nudges runtime, gated off by default), #69 (security
dep bumps), #64 (ENG-16330 non-terminal recovered-tool-error badge).

Base = 2026.6.11-boon.6. Only slack + msteams carry the -boon.N suffix; other
extensions stay at plain 2026.6.11 (fork release does not run a blanket
plugins:sync). Formatting proof: oxfmt --check clean on CHANGELOG.md; the six
JSON files are oxfmt-excluded lockfile-class and byte-shape-identical to the
boon.6 release commit.

Co-authored-by: Claude Opus 4.8 (1M context) <[email protected]>
convyusboy added a commit that referenced this pull request Jul 27, 2026
… correct answer (ENG-16318) (#75)

* fix(errors): stop surfacing benign housekeeping exec failures after a correct answer (ENG-16318)

A correct MS Teams triage answer was followed by a "⚠️ 🛠️ … failed" card whose
failing step was a trailing model-authored `find /` that hit permission-denied
noise — bookkeeping, not the task failing. Building on #64 (ENG-16330, which
reframed the hard badge into a "↻ kept going" note), this removes the residual
tangential markers:

- payloads: when a turn delivered a real answer and the recovered exec command
  was ENTIRELY benign housekeeping (scratch setup + inspection, e.g.
  `mkdir … && ls … && find / -name "<uuid>*"`), append nothing — not even the
  "↻" note. Mutating recovered tails and no-reply turns still surface the honest
  terminal failure. Keyed off a new whole-command classifier, not a
  last-stage guess (which breaks on `python build.py || find /`).
- streaming: drop benign housekeeping exec chains from the progress card across
  all channels (shared buildChannelProgressDraftLine seam).
- system-prompt: nudge the agent to scope filesystem searches to the workspace
  (not `find /`) and treat benign housekeeping failures as non-fatal.

New display-only classifier isBenignHousekeepingShellCommand lives in
tool-display-exec-shell.ts; intentionally separate from tool-mutation.ts's
security-sensitive READ_ONLY_SHELL_COMMANDS (which must exclude mutating
scaffolding like mkdir).

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>

* fix(errors): reject side-effecting find forms from benign housekeeping (ENG-16318)

Cubic P1: the binary-only benign-housekeeping check classified destructive
`find` forms (`find . -delete`, `find . -exec rm …`, -execdir/-ok/-okdir/
-fprint*) as benign, so real work could disappear from the progress card and
its failure note be suppressed — the opposite of the ticket intent.

Guard `find` in isBenignHousekeepingStage: any -delete/-exec/-execdir/-ok/
-okdir/-fprint/-fprintf/-fls predicate makes the stage non-benign (fail closed →
surface it and its failure). Pure traversal (`find / -name "x*"`) stays benign.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>

* fix(deps): bump brace-expansion + postcss off high advisories (security-fast)

security-fast / pnpm-audit-prod flagged two production advisories on the boon
baseline:
- brace-expansion <=5.0.7 — DoS via unbounded expansion (GHSA-mh99-v99m-4gvg)
- postcss <=8.5.17 — path traversal in source-map auto-load (GHSA-r28c-9q8g-f849)

Bump the pinned overrides: brace-expansion 5.0.7 -> 5.0.8, add postcss 8.5.22
(both patched, no major bump). 5.0.8 is the only patched 5.x release and is
newer than the 2-day minimumReleaseAge window, so it is added to
minimumReleaseAgeExclude with an advisory reference. postcss 8.5.22 is the
newest patched release that clears the maturity window (8.5.23 too fresh).

Regenerated pnpm-lock.yaml and root npm-shrinkwrap.json. pnpm-audit-prod now
reports no high/critical advisories; shrinkwrap --all --check is current.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>

* fix(errors): fail closed on shell control the housekeeping classifier can't model (ENG-16318)

gandalfboon (blocking): isBenignHousekeepingShellCommand decided "benign" from
each stage's first word, but splitTopLevelStages only breaks on ;/&&/|| and
splitShellWords treats a newline as whitespace. So a multi-line, &-separated,
redirected, or subshell command collapsed to one stage whose benign first word
hid real work — e.g. `mkdir -p build\nnpm run build`, `ls & rm -rf dist`,
`printf 'x' > ~/.zshrc`, `echo $(rm -rf dist)` all classified benign. That
dropped the progress bullet for real work and silenced its genuine failure —
the inverse of the ticket intent. The 48-word cap in splitShellWords also let a
long `find … -delete` predicate list fail open, regressing the cubic P1 guard.

Fix (mirrors tool-mutation.ts): fail CLOSED — a stage containing a newline, `&`,
`<`, `>`, backtick, backslash, or `$(` is treated as real work, since this
simple splitter cannot model it and a benign chain never needs those. Remove the
word cap on the find predicate scan. Added the 7 adversarial cases as regression
tests.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>

---------

Co-authored-by: Claude Opus 4.8 (1M context) <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants