Skip to content

fix(agents): remove misleading run prefix from exec display for interpreter commands (fixes #97319)#97326

Closed
zw-xysk wants to merge 2 commits into
openclaw:mainfrom
zw-xysk:fix/issue-97319-exec-failure-label-format
Closed

fix(agents): remove misleading run prefix from exec display for interpreter commands (fixes #97319)#97326
zw-xysk wants to merge 2 commits into
openclaw:mainfrom
zw-xysk:fix/issue-97319-exec-failure-label-format

Conversation

@zw-xysk

@zw-xysk zw-xysk commented Jun 27, 2026

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes #97319.

When an exec tool call fails, the cron run history and chat surface render the failure with a leading "run" that is a framework display label, not part of the command. This makes it look like the agent prepended "run" to the actual command.

Root Cause

summarizeKnownExec generates display summaries. For interpreter binaries (python3, node, ruby, php), it prepended "run" to the canonical bin+script form, producing e.g. "run python3 /path/to/script.py".

Changes Made

  • src/agents/tool-display-exec.ts: Changed interpreter fallback from run- <script> to just <script> so the display matches the actual command.
  • src/agents/tool-display.test.ts: Added regression test.

Evidence

  • Unit tests: 43/43 passed
  • Lint: clean
  • Lockfile: unchanged

AI Assistance

  • AI-assisted: Yes
  • Co-Authored-By: Claude [email protected]
  • Human confirmed understanding: Yes

…preter commands (openclaw#97319)

For interpreter binaries (python3, node, ruby, php), the exec tool
display summary showed "run python3 /path/to/script.py" which
looks indistinguishable from the agent prepending "run" to the
command. Drop the "run" prefix so the display shows the actual
command as-is.
@openclaw-barnacle openclaw-barnacle Bot added agents Agent runtime and tooling size: XS labels Jun 27, 2026
@clawsweeper

clawsweeper Bot commented Jun 27, 2026

Copy link
Copy Markdown
Contributor

Thanks for the context here. I swept through the related work, and this is now duplicate or superseded.

Close: this PR is superseded by the proof-positive shared failure-warning fix in #97511. This branch targets the same linked bug, still lacks real user-path proof, and its broad run-prefix stripper can degrade semantic exec summaries if merged as-is.

Root-cause cluster
Relationship: superseded
Canonical: #97511
Summary: This PR, the linked issue, and the overlapping PRs all target the exec failure-warning ambiguity; the proof-positive shared formatter PR is the viable canonical landing path.

Members:

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

Canonical path: Use #97511, or an equivalent maintainer-approved shared payload-warning formatter, as the landing path for the linked bug.

So I’m closing this here and keeping the remaining discussion on #97511.

Review details

Best possible solution:

Use #97511, or an equivalent maintainer-approved shared payload-warning formatter, as the landing path for the linked bug.

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

Yes. Current main still formats exec failure warnings as ⚠️ ${toolSummary} failed, and the exec display formatter 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?

No. The shared formatter in #97511 is the better fix because it separates the failure label from the command subject at the common payload-warning boundary without broadly stripping display metadata.

Security review:

Security review cleared: The diff only changes TypeScript presentation formatting and tests; it does not touch dependencies, workflows, permissions, secrets, install scripts, or package metadata.

AGENTS.md: found and applied where relevant.

What I checked:

  • Repository policy read: Root and scoped agent runner policies were read fully and applied; the relevant guidance required reviewing the shared warning path, caller/callee context, sibling surfaces, proof, and best-fix shape before verdict. (AGENTS.md:1, 245c18da5a6c)
  • Current main warning construction: Current main still builds visible tool failure text from formatToolAggregate(...) and then appends failed, so the warning boundary is the central shared surface for the reported ambiguity. (src/agents/embedded-agent-runner/run/payloads.ts:553, 245c18da5a6c)
  • Current main exec summary source: Current main summarizes Python and similar interpreter script invocations as run ${bin} ${script}, matching the linked issue's run python3 ... warning example. (src/agents/tool-display-exec.ts:240, 245c18da5a6c)
  • Current PR over-strips run metadata: At this PR head, stripLeadingExecDisplayVerb strips any multi-token metadata beginning with run, which can turn semantic summaries such as run sed on <file> into malformed command-looking warning text. (src/agents/tool-display-exec.ts:306, c992739b9667)
  • Superseding PR implementation: The canonical related PR implements a shared formatToolErrorWarningText path that separates the exec/bash tool label and failure state from the command subject instead of stripping metadata in place. (src/agents/embedded-agent-runner/run/payloads.ts:159, e170fa7a7876)
  • Superseding PR viability: The related PR is open, mergeable, clean, labeled proof: sufficient, and has no failed checks in the live status summary, so it is a viable canonical landing path rather than a closed or unproven replacement. (e170fa7a7876)

Likely related people:

  • Peter Steinberger: Introduced the split exec display parser and earlier extracted the compact tool-meta formatter that the warning path uses. (role: feature-history contributor; confidence: high; commits: ca0159569954, 597e7e6f1345; files: src/agents/tool-display-exec.ts, src/auto-reply/tool-meta.ts)
  • chenyangjun-xy: Authored recent merged work in buildEmbeddedRunPayloads, the surface that appends failure warnings from formatted tool metadata. (role: recent payload-warning contributor; confidence: medium; commits: e6f391234791; files: src/agents/embedded-agent-runner/run/payloads.ts)
  • Bartok: Authored recent merged work directly in the exec display formatter and adjacent tests. (role: recent exec-display contributor; confidence: medium; commits: 4d9cd7d22755; files: src/agents/tool-display-exec.ts, src/agents/tool-display.test.ts)
  • Vincent Koc: Git history shows recent current-main release/change history touching the exec display string history in this checkout, though the deeper feature ownership is shared with earlier parser and formatter work. (role: adjacent release/current-main contributor; confidence: low; commits: aa69b12d0086; files: src/agents/tool-display-exec.ts, src/auto-reply/tool-meta.ts)

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

@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 27, 2026
@zw-xysk

zw-xysk commented Jun 27, 2026

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Jun 27, 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.

@harjothkhara

Copy link
Copy Markdown
Contributor

I did a source-level pass on the remaining scope here. The patch fixes the narrow interpreter-summary path in summarizeKnownExec, but the reported user-visible string is assembled one layer later: formatToolAggregate() still wraps exec/bash metadata as the command-shaped segment, and src/agents/embedded-agent-runner/run/payloads.ts still appends the failure suffix from that aggregate summary.

That makes the maintainer decision mostly about scope. If this PR is intended as the narrow python3 /path/to/script.py summary fix, the code shape looks aligned and the remaining proof should exercise a real cron/chat warning so reviewers can see the final rendered string. If it is intended to satisfy the broader wording in #97319 where the framework/tool label is outside the literal command, I would add a regression at the warning-payload or cron-diagnostics boundary rather than only formatToolDetail(), because that is the boundary that preserves or removes the ambiguous command-shaped failure text.

…n summaries (openclaw#97319)

For exec/bash tool failures, the warning text embeds the exec display
summary inside backticks before appending "failed". When the summary
is a framework-injected "run <binary> <args>" pattern (e.g. "run python3
/path/to/script.py"), the leading "run" appears as if the agent typed it.

Add stripLeadingExecDisplayVerb that collapses "run <bin> <args>" to
"<bin> <args>" while preserving single-token map labels ("run tests",
"run build") and non-run action verbs ("install dependencies",
"show last 20 lines").

This complements the interpreter-summary fix in summarizeKnownExec by
catching all exec/bash failure paths at the warning-rendering layer.
@zw-xysk

zw-xysk commented Jun 28, 2026

Copy link
Copy Markdown
Contributor Author

Enhancement: strip run prefix from exec failure warnings

This adds a second layer to the fix: stripLeadingExecDisplayVerb in payloads.ts strips the framework-injected run verb from exec/bash failure warnings, complementing the summarizeKnownExec interpreter-summary fix already in this PR.

Changes

  • src/agents/tool-display-exec.ts — new stripLeadingExecDisplayVerb export: collapses run <bin> <args><bin> <args>, preserves single-token labels (run tests, run build) and non-run action verbs (install dependencies, show last 20 lines)
  • src/agents/embedded-agent-runner/run/payloads.ts — applies strip in the failure-warning path for exec/bash tools before formatToolAggregate wraps the meta
  • src/agents/tool-display.test.ts — 9 test cases covering strip, preserve, and edge cases

Effect

Before After
⚠️ 🛠️ `run python3 /path` failed ⚠️ 🛠️ `python3 /path` failed
⚠️ 🛠️ `run tests` failed ⚠️ 🛠️ `run tests` failed (unchanged, single-token)
⚠️ 🛠️ `install dependencies` failed ⚠️ 🛠️ `install dependencies` failed (unchanged, not a run verb)

CI

136 checks passed. The single failure (checks-node-compact-large-whole-1) is an unrelated flaky session-lock test (attempt.session-lock.test.ts:3987), not related to this change.

@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: 🚨 other 🚨 Merging this PR has meaningful risk outside the owned taxonomy. label Jun 28, 2026
@vincentkoc

Copy link
Copy Markdown
Member

Closing this as superseded by the canonical shared formatting fix in #97511, landed as 3e90125. #97511 covers the broader payload warning boundary instead of only this narrower exec-summary slice. Thanks for pushing on the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling merge-risk: 🚨 other 🚨 Merging this PR has meaningful risk outside the owned taxonomy. P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. size: S status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

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