Skip to content

fix: clarify exec tool failure warnings#97511

Merged
vincentkoc merged 7 commits into
openclaw:mainfrom
aditya-vithaldas:codex/exec-failure-message-labels
Jun 28, 2026
Merged

fix: clarify exec tool failure warnings#97511
vincentkoc merged 7 commits into
openclaw:mainfrom
aditya-vithaldas:codex/exec-failure-message-labels

Conversation

@aditya-vithaldas

@aditya-vithaldas aditya-vithaldas commented Jun 28, 2026

Copy link
Copy Markdown
Contributor

Closes #97319

AI-assisted by Codex.

What Problem This Solves

Fixes an issue where users debugging failed exec/bash tool calls could see the framework-generated action summary rendered like a literal command, for example a Python script failure appearing as if the agent typed run python3 ....

This affected chat/tool-failure cards and cron run diagnostics that reuse the embedded-runner payload warning text.

Why This Change Was Made

Exec-like tool failures now render the tool label and failure state separately from the command subject, using forms like Exec failed: <command> instead of wrapping the whole summary before appending failed.

When the stored exec summary has a raw trailing inline command, the warning prefers that literal command. Known literal run <tool> <arg> summaries render without the framework run label, while semantic summaries such as package scripts, inline scripts, cwd/repo labels, node context, and pipeline summaries keep the useful display context. Non-verbose exec failures also include a concise (exit N) suffix when the error text exposes an exit code.

The raw metadata parser preserves explicit node: <name> context plus cwd labels such as (in /tmp/build) and (repo), while avoiding duplicate/false cwd suffixes when the literal raw command itself contains parenthesized text.

User Impact

Users get clearer failure messages when debugging failed scripts or shell commands, including which node and working directory context applied to a failed exec. The change is presentation-only; it does not change tool execution, retry policy, cron behavior, or verbose error-detail rules.

Evidence

  • Pushed follow-up commits f89d605c, aed96cde, and 9d955988 after review feedback.
  • node scripts/run-vitest.mjs src/agents/embedded-agent-runner/run/payloads.errors.test.ts src/agents/embedded-agent-subscribe.handlers.tools.test.ts src/cron/run-diagnostics.test.ts src/cron/isolated-agent.helpers.test.ts src/agents/tool-display.test.ts ui/src/ui/chat/tool-cards.test.ts
  • node node_modules/oxfmt/bin/oxfmt --check --threads=1 src/agents/embedded-agent-runner/run/payloads.ts src/agents/embedded-agent-runner/run/payloads.errors.test.ts src/agents/embedded-agent-subscribe.handlers.tools.test.ts
  • git diff --check
  • .agents/skills/autoreview/scripts/autoreview --mode local --codex-bin /tmp/codex-fast-wrapper reported clean after the raw-detail, semantic-summary, node-context, cwd-context, compact-label, and false-positive review findings were fixed.
  • Focused handler tests cover production handleToolExecutionStart -> handleToolExecutionEnd -> buildEmbeddedRunPayloads for raw command, node context, path cwd context, and compact repo cwd context.
  • Local terminal proof using production buildEmbeddedRunPayloads with static command metadata:
local raw: ⚠️ 🛠️ Exec failed: `python3 /tmp/audit.py` (exit 1)
node raw: ⚠️ 🛠️ Exec failed: `node: mac-1 · python3 /tmp/audit.py` (exit 1)
cwd raw: ⚠️ 🛠️ Exec failed: `python3 audit.py (in /tmp/build)` (exit 1)
repo raw: ⚠️ 🛠️ Exec failed: `git status (repo)` (exit 1)
quoted arg: ⚠️ 🛠️ Exec failed: `ls "(in progress)"` (exit 1)

@openclaw-barnacle openclaw-barnacle Bot added agents Agent runtime and tooling size: S labels Jun 28, 2026
@clawsweeper

clawsweeper Bot commented Jun 28, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed June 28, 2026, 2:25 PM ET / 18:25 UTC.

Summary
This PR changes exec/bash failure warnings to render the tool label and failure state separately from the command subject, adds concise exit-code suffixes, and covers raw, node, cwd, compact-label, and backtick command metadata in payload and handler tests.

PR surface: Source +287, Tests +543. Total +830 across 4 files.

Reproducibility: yes. source-reproducible: origin/main still builds warnings as ⚠️ ${toolSummary} failed, and exec summaries can still produce run python3 ...; I did not run a live cron/chat flow in this read-only review.

Review metrics: none identified.

Stored data model
Persistent data-model change detected: vector/embedding metadata: src/agents/embedded-agent-runner/run/payloads.errors.test.ts, vector/embedding metadata: src/agents/embedded-agent-subscribe.handlers.tools.test.ts. Confirm migration or upgrade compatibility proof before merge.

Root-cause cluster
Relationship: fixed_by_candidate
Canonical: #97319
Summary: This PR is a candidate fix for the canonical exec failure-warning ambiguity; the two other open PRs overlap but are narrower and still marked as needing proof.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Merge readiness
Overall: 🐚 platinum hermit
Proof: 🐚 platinum hermit
Patch quality: 🐚 platinum hermit
Result: ready for maintainer review.

Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch.

Rank-up moves:

  • none.

Next step before merge

  • No automated repair job is needed; the remaining action is ordinary maintainer merge review and normal protected-check gating.

Security
Cleared: The diff only changes TypeScript presentation formatting and tests, with no workflow, dependency, permission, secret, package-script, download, or supply-chain surface changed.

Review details

Best possible solution:

Land this shared payload-warning fix or an equivalent maintainer-approved version, then close #97319 and supersede the narrower overlapping PRs if this one merges first.

Do we have a high-confidence way to reproduce the issue?

Yes, source-reproducible: origin/main still builds warnings as ⚠️ ${toolSummary} failed, and exec summaries can still produce run python3 ...; I did not run a live cron/chat flow in this read-only review.

Is this the best way to solve the issue?

Yes: fixing the shared payload-warning boundary covers both chat and cron consumers, while the narrower overlapping PRs only adjust parts of exec display metadata and do not cover the same raw-mode warning surface.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against e5205a4cef0e.

Label changes

Label justifications:

  • P3: This is a low-severity diagnostic presentation fix with real debugging impact but no data loss, security, availability, or delivery failure.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (terminal): The PR body includes terminal output from production buildEmbeddedRunPayloads showing after-fix local, node, cwd, repo, and quoted-argument warning strings, which is sufficient for this text-formatting change.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR body includes terminal output from production buildEmbeddedRunPayloads showing after-fix local, node, cwd, repo, and quoted-argument warning strings, which is sufficient for this text-formatting change.
Evidence reviewed

PR surface:

Source +287, Tests +543. Total +830 across 4 files.

View PR surface stats
Area Files Added Removed Net
Source 2 298 11 +287
Tests 2 544 1 +543
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 4 842 12 +830

What I checked:

Likely related people:

  • steipete: Git history shows Peter Steinberger introduced and refined the central tool-display metadata and exec/tool-summary formatting paths that this warning surface uses. (role: feature owner and adjacent display owner; confidence: high; commits: 6e16c0699a41, 31e8ecca10d5, 3200b51160ff; files: src/agents/tool-display-exec.ts, src/auto-reply/tool-meta.ts)
  • giodl73-repo: The current checked-out blame for the relevant payload and exec-display lines points to the merged current-main commit from the gateway runtime findings PR, so Gio is a recent routing candidate for this area. (role: recent current-main area contributor; confidence: medium; commits: 3630d502eb9b; files: src/agents/embedded-agent-runner/run/payloads.ts, src/agents/tool-display-exec.ts, src/auto-reply/tool-meta.ts)
What the crustacean ranks mean
  • 🦀 challenger crab: rare, exceptional readiness with strong proof, clean implementation, and convincing validation.
  • 🦞 diamond lobster: very strong readiness with only minor maintainer review expected.
  • 🐚 platinum hermit: good normal PR, likely mergeable with ordinary maintainer review.
  • 🦐 gold shrimp: useful signal, but proof or patch confidence is still limited.
  • 🦪 silver shellfish: thin signal; proof, validation, or implementation needs work.
  • 🧂 unranked krab: not merge-ready because proof is missing/unusable or there are serious correctness or safety concerns.
  • 🌊 off-meta tidepool: rating does not apply to this item.

Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

How this review workflow works
  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

@harjothkhara

Copy link
Copy Markdown
Contributor

I think the shared presentation-layer direction is right for #97319, but this still needs a raw-progress regression before I would call it the best fix.

LOC: +164/-11 (2 files). Best-fix verdict: right layer, incomplete coverage for the documented raw detail mode.

toolProgressDetail: "raw" is a documented/user-configurable mode, and the start handler passes that through when it captures exec metadata (src/agents/embedded-agent-subscribe.handlers.tools.ts, via inferToolMetaFromArgs). In that mode, resolveExecDetail() can append the compact raw command as summary · + an inline-code raw command (src/agents/tool-display-exec.ts). The new parser in src/agents/embedded-agent-runner/run/payloads.ts only recognizes a trailing inline-code command at the start/end or after a comma, then applies the run ... stripping regex to the whole remaining display string.

So a raw-mode meta shape like:

run python3 /tmp/audit.py · `python3 /tmp/audit.py`

would be treated as one subject instead of extracting the trailing raw command first. That can put the display summary plus the raw suffix inside the failure command text, which reintroduces the same “display text looks like the command” ambiguity for users who enabled raw progress specifically to debug commands.

The small fix is probably to split/extract a trailing · <inline-code raw command> before stripping the friendly run ... display summary, then add a regression that builds the warning with raw-style exec metadata. A cleaner longer-term shape would be to carry structured exec display/raw command fields instead of reparsing the formatted meta string, but a narrow raw-meta regression is enough for this PR.

@clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. labels Jun 28, 2026
@aditya-vithaldas

Copy link
Copy Markdown
Contributor Author

Updated in f89d605c: raw trailing inline exec metadata is extracted before display-summary stripping, known literal run <tool> <arg> summaries are handled narrowly, and semantic summaries such as package scripts, inline scripts, sed summaries, and pipeline summaries stay intact. PR body evidence now includes the focused Vitest/format checks plus terminal proof from the production handler-to-payload path.

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Jun 28, 2026

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: the existing ClawSweeper review comment will be edited in place when the review finishes.

@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. and removed rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Jun 28, 2026
@aditya-vithaldas

Copy link
Copy Markdown
Contributor Author

Updated in aed96cde: raw exec warning extraction now preserves explicit node: <name> context before the raw command and avoids treating commas inside human-readable command summaries as context. PR body evidence includes the refreshed production handler-to-payload terminal proof for both local and node-target exec warnings.

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Jun 28, 2026

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: the existing ClawSweeper review comment will be edited in place when the review finishes.

@clawsweeper clawsweeper Bot added the merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. label Jun 28, 2026
@aditya-vithaldas

Copy link
Copy Markdown
Contributor Author

Updated in 9d955988: raw exec warnings now preserve cwd/workspace context as well as node context when a trailing raw command is preferred. The parser keeps path-like cwd suffixes and compact generated labels such as (repo), while avoiding false positives when the literal raw command already contains parenthesized text like "(in progress)".

Added direct payload regressions plus production handler-to-payload coverage for raw path cwd and compact repo cwd. Refreshed evidence in the PR body includes the full focused Vitest matrix, formatter check, git diff --check, clean local auto-review, and terminal proof for local/node/cwd/repo/quoted-argument cases.

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Jun 28, 2026

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: the existing ClawSweeper review comment will be edited in place when the review finishes.

@clawsweeper clawsweeper Bot removed proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. labels Jun 28, 2026
@clawsweeper clawsweeper Bot removed the merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. label Jun 28, 2026
@aditya-vithaldas
aditya-vithaldas marked this pull request as ready for review June 28, 2026 17:12

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 9d95598860

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/agents/embedded-agent-runner/run/payloads.ts Outdated
@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. and removed rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Jun 28, 2026
@aditya-vithaldas

Copy link
Copy Markdown
Contributor Author

Follow-up for the check-test-types failure on the ready-for-review run.

Root cause: the new handler-level payload assertions passed ctx.state.toolMetas directly into buildEmbeddedRunPayloads; the handler state intentionally allows optional toolName, while the payload builder requires named tool metadata.

Fix pushed in cbccd654: added a test helper that narrows handler tool metadata into the payload-builder shape and throws if a test records nameless metadata.

Evidence:

  • pnpm check:test-types
  • node scripts/run-vitest.mjs src/agents/embedded-agent-subscribe.handlers.tools.test.ts src/agents/embedded-agent-runner/run/payloads.errors.test.ts
  • node node_modules/oxfmt/bin/oxfmt --check --threads=1 src/agents/embedded-agent-subscribe.handlers.tools.test.ts
  • git diff --check

@clawsweeper clawsweeper Bot added rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. labels Jun 28, 2026
@aditya-vithaldas

aditya-vithaldas commented Jun 28, 2026

Copy link
Copy Markdown
Contributor Author

Addressed the ClawSweeper P2 about raw exec commands containing backticks in commit cb8abf3.

What changed:

  • Raw exec metadata now wraps commands with a markdown code-span delimiter longer than any backtick run inside the command.
  • Payload parsing now extracts the trailing markdown code span by delimiter length, so an internal comma/backtick sequence in commands such as node -e 'console.log(1, `x`)' does not steal the raw-command metadata boundary.
  • Added regression coverage for both the payload parser and the runtime handler path that records lastToolError metadata.

Verification:

  • /Users/AdityaWork/.cache/codex-runtimes/codex-primary-runtime/dependencies/node/bin/node scripts/run-vitest.mjs src/agents/embedded-agent-runner/run/payloads.errors.test.ts src/agents/embedded-agent-subscribe.handlers.tools.test.ts src/agents/tool-display.test.ts
  • /Users/AdityaWork/.cache/codex-runtimes/codex-primary-runtime/dependencies/node/bin/node node_modules/oxfmt/bin/oxfmt --check --threads=1 src/agents/tool-display-exec.ts src/agents/embedded-agent-runner/run/payloads.ts src/agents/embedded-agent-runner/run/payloads.errors.test.ts src/agents/embedded-agent-subscribe.handlers.tools.test.ts
  • git diff --check
  • .agents/skills/autoreview/scripts/autoreview --mode local --codex-bin /tmp/codex-fast-wrapper — clean, no actionable findings.

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Jun 28, 2026

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: the existing ClawSweeper review comment will be edited in place when the review finishes.

@clawsweeper clawsweeper Bot added rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Jun 28, 2026
@aditya-vithaldas

Copy link
Copy Markdown
Contributor Author

Pushed e170fa7a as a no-op CI retrigger only. No code changed after cb8abf3a; the previous security-fast failure died while installing Python/pre-commit dependencies (No matching distribution found for setuptools>=40.8.0), before scanning this PR. I do not have upstream rerun rights, and #97505's fresh security-fast run is now passing, so this retriggers the recovered lane without altering the fix.

@vincentkoc
vincentkoc merged commit 3e90125 into openclaw:main Jun 28, 2026
93 checks passed
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Jun 29, 2026
* clarify exec failure warnings

* fix exec failure raw command labels

* preserve node context in exec failure warnings

* fix exec raw context warnings

* fix exec payload test metadata types

* fix raw exec command backtick parsing

* chore: retrigger ci after security-fast outage

---------

Co-authored-by: aditya-vithaldas <[email protected]>
QiuYuang pushed a commit to QiuYuang/openclaw that referenced this pull request Jul 1, 2026
* clarify exec failure warnings

* fix exec failure raw command labels

* preserve node context in exec failure warnings

* fix exec raw context warnings

* fix exec payload test metadata types

* fix raw exec command backtick parsing

* chore: retrigger ci after security-fast outage

---------

Co-authored-by: aditya-vithaldas <[email protected]>
chenyangjun-xy pushed a commit to chenyangjun-xy/openclaw that referenced this pull request Jul 1, 2026
* clarify exec failure warnings

* fix exec failure raw command labels

* preserve node context in exec failure warnings

* fix exec raw context warnings

* fix exec payload test metadata types

* fix raw exec command backtick parsing

* chore: retrigger ci after security-fast outage

---------

Co-authored-by: aditya-vithaldas <[email protected]>
chenyangjun-xy pushed a commit to chenyangjun-xy/openclaw that referenced this pull request Jul 3, 2026
* clarify exec failure warnings

* fix exec failure raw command labels

* preserve node context in exec failure warnings

* fix exec raw context warnings

* fix exec payload test metadata types

* fix raw exec command backtick parsing

* chore: retrigger ci after security-fast outage

---------

Co-authored-by: aditya-vithaldas <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: L status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: exec tool failure message format makes framework labels indistinguishable from agent-typed commands

3 participants