Skip to content

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

Merged
convyusboy merged 4 commits into
boonfrom
worktree-mellow-gathering-popcorn
Jul 27, 2026
Merged

convyusboy merged 4 commits into
boonfrom
worktree-mellow-gathering-popcorn

Conversation

@convyusboy

@convyusboy convyusboy commented Jul 25, 2026 •

Copy link
Copy Markdown
Collaborator

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:

⚠️ 🛠️ create folder ~/.openclaw/workspace/scratch → list files … → find files named "<uuid>*" in / failed

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 that find; the blanket exitCode !== 0 → error rule 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 ⚠️ … failed badge 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:

  1. Suppress the note entirely (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. Genuinely mutating recovered failures and no-reply turns still surface the honest terminal failure.
    • Keyed off a new whole-command classifier, not a last-stage guess — the exec result carries one exit code, not per-stage info, and "last stage = failing stage" breaks on python build.py || find /. If every stage is benign, whichever failed was benign, with no guessing.
  2. Filter the progress card (streaming): drop benign housekeeping exec chains from the user-facing progress bullets, across all channels (shared buildChannelProgressDraftLine seam).
  3. Prompt guidance (system-prompt): nudge the agent to scope filesystem searches to the workspace (not find /) and treat benign housekeeping failures as non-fatal — the only lever for a model-authored command.

The new isBenignHousekeepingShellCommand classifier is display-only and intentionally separate from tool-mutation.ts's security-sensitive READ_ONLY_SHELL_COMMANDS (which must exclude mutating scaffolding like mkdir).

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 benign mkdir/ls/find progress bullets. No change to genuinely failed mutating operations, which still surface honestly. No config or API surface changes.

Evidence

  • Tests (all green, per-file in worktree):
    • tool-display-exec-shell.test.ts — classifier incl. fused chains, || fallback safety, pipes, sh -c unwrap (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 — benignHousekeepingError flag set/unset (71)
    • streaming.test.ts — housekeeping chain dropped, real-work chain kept (10)
  • Typecheck: tsgo core lane clean (0 errors).
  • Format: oxfmt clean on all touched files.
  • Autoreview: 4-agent simplify pass (reuse/simplification/efficiency/altitude); altitude finding drove the whole-command-vs-last-stage redesign.
  • Pending: 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 exec failures 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 pins brace-expansion and postcss to patched versions. Addresses ENG-16318 so MS Teams (and other channels) show clean success when the task completes.

  • Bug Fixes

    • Use a whole-command classifier to tag benign housekeeping chains (e.g., mkdir, ls, read-only find), explicitly rejecting side‑effecting find forms (-delete, -exec*, -ok*, -fprint*).
    • Fail closed on shell control the splitter can’t model (newline, &, <, >, backticks, backslash, $()); remove the word cap so long find … -delete predicates are caught.
    • When a real answer exists and only benign housekeeping failed, suppress the continuation note; still surface terminal errors if no reply or if real work failed.
    • Filter benign exec chains out of progress cards via buildChannelProgressDraftLine, and update the system prompt to scope searches to the workspace and treat housekeeping failures as non-fatal.
  • Dependencies

    • Pin brace-expansion to 5.0.8 to address DoS via unbounded expansion.
    • Pin postcss to 8.5.22 to address source-map path traversal.

Written for commit 3148984. Summary will update on new commits.

Review in cubic

… 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]>
@boon-atlantis-production

Copy link
Copy Markdown
Error: This repo is not allowlisted for Atlantis.

@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 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

Comment thread src/agents/tool-display-exec-shell.ts Resolved
convyusboy and others added 2 commits July 25, 2026 10:37
…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]>
@github-actions

Copy link
Copy Markdown

Dependency Guard

This PR changes dependency-related files. Maintainers should confirm these changes are intentional.

Changed files:

  • npm-shrinkwrap.json
  • pnpm-lock.yaml
  • pnpm-workspace.yaml

Maintainer follow-up:

  • Review whether the dependency changes are intentional.
  • Inspect resolved package deltas when lockfile, shrinkwrap, or workspace dependency policy changes are present.
  • Treat package-lock.json and npm-shrinkwrap.json diffs as security-review surfaces.
  • Run pnpm deps:changes:report -- --base-ref origin/main --markdown /tmp/dependency-changes.md --json /tmp/dependency-changes.json locally for detailed release-style evidence.

@github-actions

github-actions Bot commented Jul 25, 2026 •

Copy link
Copy Markdown

Dependency graph changes noted

This PR includes dependency graph changes. The dependency guard is informational because the PR author is a repository admin or a member of @openclaw/openclaw-secops.

  • Current SHA: 314898431ce5d00db5f3c73dab47d92e7b852f3a
  • Trusted actor: @convyusboy
  • Trusted role: pull request author; repository admin

Security review is still recommended before merge when the dependency graph change is intentional.

@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.

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:

  1. streaming.ts drops the progress bullet entirely — an rm -rf dist / npm run build disappears from the user-facing card because the chain "looked like" ls/mkdir.
  2. payloads.ts suppresses 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 build is effectively covered (build-artifacts is 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.
  • minimumReleaseAgeExclude for [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. A find / 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/printf in BENIGN_HOUSEKEEPING_SHELL_BINARIES are 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]>
@convyusboy

Copy link
Copy Markdown
Collaborator Author

Thanks — the fail-open analysis was exactly right, and all 7 cases now return false. Fixed in 314898431ce.

Blocking (fixed): isBenignHousekeepingStage now fails closed on any shell control this splitter can't model — a stage containing a newline, &, <, >, backtick, backslash, or $( is treated as real work (a benign housekeeping chain never needs a redirect/subshell/line-break, so refusing them costs nothing). ;/&&/||/| stay allowed since they're split and each segment is classified. Also removed the 48-word cap on the find predicate scan so a trailing -delete past word 48 can't slip through — closes the regression against the cubic P1 guard. Added all 7 of your cases (plus a long-predicate find … -delete) as regression tests.

Non-blocking:

  • Live Crabbox MS Teams proof — agreed, that's the tracked pre-land item; will land it before merge.
  • [email protected] maturity bypass + dep pins in a display PR — fair. Happy to split the dependency commit (9d5386eebb9) into its own security PR if preferred.
  • find-only shows no progress line — good point on the long-running-search UX; leaving that as a follow-up rather than expanding this PR's scope (suppress-only-after-error is the right shape).

Re-review when you have a moment.

@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.

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:

  1. 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.
  2. 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.
  3. 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.

@convyusboy
convyusboy merged commit cc4d315 into boon Jul 27, 2026
145 checks passed
@convyusboy
convyusboy deleted the worktree-mellow-gathering-popcorn branch July 27, 2026 03:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant