Repository navigation
fix(errors): stop surfacing benign housekeeping exec failures after a correct answer (ENG-16318) - #75
Conversation
… 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]>
|
There was a problem hiding this comment.
cubic analysis
All reported issues were addressed across 10 files
Linked issue analysis
Linked issue: ENG-16318: MS teams agent works, spits out misleading tangential errors
| Status | Acceptance criteria | Notes |
|---|---|---|
| ✅ | Suppress the recovered-exec "↻ kept going" / tangential failure note when a turn produced a real answer and the failing exec command was entirely benign housekeeping (e.g., scratch setup + find / permission noise). | payload builder now conditionally suppresses the non-terminal warning when lastToolError.benignHousekeepingError is true; tests cover the suppression case. |
| ✅ | Keep the recovered-exec note when the failing exec chain ran real work (i.e., not benign housekeeping). | Tests assert that non-benign exec errors still produce the non-terminal warning; payload logic only suppresses for benignHousekeepingError. |
| ✅ | Still surface a terminal error badge when NO user-facing reply exists even if the exec error was benign housekeeping (i.e., do not silently drop honest terminal failures). | Payload tests include the guard case and payload logic only suppresses non-terminal warnings when a reply exists; terminal-only turns remain error payloads. |
| ✅ | Filter (drop) benign fs-housekeeping exec chains from user-facing progress bullets across channels (so trailing benign mkdir/ls/find don't appear on progress cards). | Channel progress builder returns undefined for exec commands classified as benign housekeeping; unit tests assert dropped vs kept lines. |
| ✅ | Add a display-only whole-command classifier isBenignHousekeepingShellCommand and use it to classify fused/chained commands (ensuring whole-command semantics, not last-stage guessing). | New classifier implementation and comprehensive unit tests verify behavior across piped/staged/unwrap cases and the whole-command rule. |
| ✅ | Flag benignHousekeepingError in tool execution end handling and expose it in the tool error summary so the reply builder can act on it. | Handler sets benignHousekeepingError for exec commands when classifier returns true; tool-error-summary type updated and tests verify the handler behavior. |
| ✅ | Nudge the agent via system prompt to scope filesystem searches to the workspace and treat housekeeping failures as non-fatal (to reduce model-authored find / usage). | System prompt string added and included in the built prompt sections. |
| Run pnpm build and live Crabbox MS Teams repro before merge (pending manual verification noted in PR). | PR notes explicitly list pnpm build + live repro as pending; code and tests are present but the live verification and build run remain undone per the description. |
Reply with feedback, questions, or to request a fix.
Fix all with cubic | Re-trigger cubic
…g (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]>
…ty-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]>
Dependency GuardThis PR changes dependency-related files. Maintainers should confirm these changes are intentional. Changed files:
Maintainer follow-up:
|
Dependency graph changes notedThis PR includes dependency graph changes. The dependency guard is informational because the PR author is a repository admin or a member of
Security review is still recommended before merge when the dependency graph change is intentional. |
There was a problem hiding this comment.
Reviewed the full diff, pulled boon + branch HEAD, and ran the new classifier against adversarial inputs (transpiled tool-display-exec-shell.ts from the branch, external import stubbed, executed under bun). Requesting changes — one blocking correctness bug, plus notes.
The design call is right, and I want to say that first: the whole-command rule over last-stage guessing is the correct read of a single exit code, benignHousekeepingError is threaded cleanly, keeping this classifier separate from tool-mutation.ts's security-sensitive READ_ONLY_SHELL_COMMANDS is the right boundary, and the terminal-badge-when-no-reply guard is exactly the honesty test this change needed. Tests are real tests, not decoration.
🔴 Blocking — isBenignHousekeepingShellCommand fails OPEN on the most common exec shape
The cubic P1 fix hardened find's predicates, but the underlying reason that bug existed is untouched: splitTopLevelStages only splits on ;, &&, ||, and splitShellWords treats a newline as ordinary whitespace. So a multi-line or &-separated command collapses into one "stage" whose first word decides everything.
Actual output from the branch code:
true mkdir -p build\nnpm run build
true ls\nrm -rf dist
true ls & rm -rf dist
true printf 'x' > ~/.zshrc
true cat > config.json <<'EOF' … EOF
true echo $(rm -rf dist)
true find . -name '*.x0' -o … (30 predicates) … -delete
Every one of those is classified benign housekeeping. Two consequences, both the inverse of the ticket's intent:
streaming.tsdrops the progress bullet entirely — anrm -rf dist/npm run builddisappears from the user-facing card because the chain "looked like"ls/mkdir.payloads.tssuppresses the failure note — if that real work is what exited non-zero on a turn that still produced a reply, the honest failure is now silent. That is precisely the case the "keeps the note when the failing step was NOT benign housekeeping" test is meant to protect, and it passes only because its fixture uses&&.
Multi-line exec is not an edge case for this product — heredocs and multi-line scripts are routine model-authored commands, so this is the common path, not a hostile one. The last row is also a straight regression against the cubic P1 fix: splitShellWords defaults to maxWords = 48, so isSideEffectingFind never sees a -delete past word 48 and the find guard silently fails open, contradicting its own "Fail closed" comment.
Suggested fix — the codebase already has the pattern, one line up the road in tool-mutation.ts:179:
if (/[;&|<>\n\r`]/.test(command) || command.includes("\\")) { … }Bail to false before stage-splitting when the command contains a newline, &, <, >, a backtick, or $(, and pass an explicit high maxWords (or scan the raw string) for the find predicate check. A benign housekeeping chain never needs a redirect or a subshell, so refusing them costs nothing and makes the classifier fail closed the way its comment claims. Please add the seven cases above as tests — every one currently returns true.
🟡 Non-blocking
- AC not fully met, by the PR's own account.
pnpm buildis effectively covered (build-artifactsis green), but the live Crabbox MS Teams repro is still listed pending and cubic's AC table flags it⚠️ . Please land that before merge — this whole change is judged on how one channel renders, and unit tests can't see a rendered card. minimumReleaseAgeExcludefor[email protected]bypasses the 2-day supply-chain maturity window on a transitively-pulled package to fix a DoS-only advisory. Documented with an advisory reference, and I'd probably make the same call — but it is a guardrail being stepped around, so it deserves a second pair of eyes rather than riding in on a display-fix PR. Same for bundling the dep pins here at all: unrelated scope, harder to revert independently.find-only commands now show no progress line at all, including when the user explicitly asked for a search. Afind /can run for minutes; the card will look stalled rather than noisy. Consider suppressing benign chains only once they've errored, or keeping a single line for long-running ones.- Nit:
echo/printfinBENIGN_HOUSEKEEPING_SHELL_BINARIESare only benign without a redirect — folded into the fix above, noting it so the set's contract stays explicit.
Fix the classifier's fail-open behaviour and I'll re-review promptly.
… 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]>
|
Thanks — the fail-open analysis was exactly right, and all 7 cases now return Blocking (fixed): Non-blocking:
Re-review when you have a moment. |
There was a problem hiding this comment.
Re-reviewed 314898431ce. Approved.
I re-ran the classifier from the branch head against all 7 of my cases plus 19 more adversarial ones (26 total: process substitution cat <(curl …), >> append, 2>/dev/null fd redirect, escaped line continuation, CRLF, backtick, eval, ${}/$() expansion, mkdir a; curl x | sh, find -exec, and the 6 original benign fixtures for regression). Every must-fail case returns false and every must-pass case still returns true — including the original ENG-16318 repro mkdir … && ls … && find / -name "abc*", so the fix didn't over-correct and lose the ticket's actual behaviour. Wrapper unwrapping still resolves real work correctly (bash -lc "mkdir tmp && npm run build" → false), cd/env preambles still classify, and removing the word cap costs nothing measurable (50k-word command: 14 ms).
The fail-closed shape is the right call, and the comment explains why the splitter can't model those forms rather than just listing characters — that's what stops the next person from "simplifying" the guard away. Regression tests are named to the cases, so a future refactor that reintroduces the fail-open collapses loudly.
CI: 107 pass, 0 fail (8 skipped by path scoping), build-artifacts green, cubic clean. Commits signed. No secrets in any commit in the history.
Three things carried forward, none blocking:
- Live Crabbox MS Teams repro is still the one open AC and is on you before merge — unit tests cannot see a rendered card, and this change is judged entirely on how one channel renders. Please attach the capture to the PR when it lands so the AC table closes honestly rather than by assertion.
- Splitting the dependency commit (
9d5386eebb9) — I won't hold the PR for it, but a maturity-window bypass reviewed as a line item in a display-fix PR gets less scrutiny than it would on its own. Your call; if it stays, flag it to whoever does the security review. find-only progress suppression — agreed that suppress-only-after-error is the right shape for the follow-up. Worth a ticket rather than memory, since the symptom (a long search looking stalled) will surface as a bug report from someone who has no idea it was a deliberate trade.
Nit, no action needed: the \\ in UNMODELLED_SHELL_CONTROL also demotes innocuous escaped args (grep 'a\.b') to non-benign. That errs toward showing a step, which is the safe direction — noting it only so it doesn't read as a bug later.
What Problem This Solves
On a live customer MS Teams (Power Solutions PSG), the agent answered a "triage this project" request correctly — a full discipline-by-discipline permit-set breakdown — but the reply was followed by a tool-progress card ending in:
A correct answer looked like it errored, undermining customer trust (ENG-16318). The failing step is a model-authored trailing
find / -name "<uuid>*"that exits non-zero on permission-denied system dirs — bookkeeping, not the task failing. OpenClaw does not inject or scope thatfind; the blanketexitCode !== 0 → errorrule turns it into a visible failure.Why This Change Was Made
#64 (ENG-16330, shipped in
v2026.6.11-boon.7) already reframed the hard⚠️ … failedbadge into a softer "↻ A step didn't complete, but I kept going" note. This removes the residual tangential markers so a correct answer stands alone:mkdir … && ls … && find / -name "<uuid>*"), append nothing. Genuinely mutating recovered failures and no-reply turns still surface the honest terminal failure.python build.py || find /. If every stage is benign, whichever failed was benign, with no guessing.buildChannelProgressDraftLineseam).find /) and treat benign housekeeping failures as non-fatal — the only lever for a model-authored command.The new
isBenignHousekeepingShellCommandclassifier is display-only and intentionally separate fromtool-mutation.ts's security-sensitiveREAD_ONLY_SHELL_COMMANDS(which must exclude mutating scaffolding likemkdir).User Impact
A successful MS Teams (and Slack/Matrix/Feishu) triage now shows the answer and nothing else — no
⚠️ failed, no↻continuation note, and no benignmkdir/ls/findprogress bullets. No change to genuinely failed mutating operations, which still surface honestly. No config or API surface changes.Evidence
tool-display-exec-shell.test.ts— classifier incl. fused chains,||fallback safety, pipes,sh -cunwrap (10)payloads.errors.test.ts— suppress-on-benign, keep-note-on-real-work, terminal-badge-when-no-reply (66)embedded-agent-subscribe.handlers.tools.test.ts—benignHousekeepingErrorflag set/unset (71)streaming.test.ts— housekeeping chain dropped, real-work chain kept (10)pnpm build+ live Crabbox MS Teams repro (worktree lacks pnpm-gated binaries) — to run before merge.🤖 Generated with Claude Code
Summary by cubic
Stops showing misleading “failed” notes after a correct answer by suppressing benign housekeeping
execfailures and hiding those steps from progress cards. Hardens the classifier to fail closed on complex shell constructs so real work and errors still surface; also pinsbrace-expansionandpostcssto patched versions. Addresses ENG-16318 so MS Teams (and other channels) show clean success when the task completes.Bug Fixes
mkdir,ls, read-onlyfind), explicitly rejecting side‑effectingfindforms (-delete,-exec*,-ok*,-fprint*).&,<,>, backticks, backslash,$()); remove the word cap so longfind … -deletepredicates are caught.buildChannelProgressDraftLine, and update the system prompt to scope searches to the workspace and treat housekeeping failures as non-fatal.Dependencies
brace-expansionto5.0.8to address DoS via unbounded expansion.postcssto8.5.22to address source-map path traversal.Written for commit 3148984. Summary will update on new commits.