Skip to content

fix(agents): fall back to raw command when most exec stages are generic#87431

Closed
mogglemoss wants to merge 1 commit into
openclaw:mainfrom
mogglemoss:fix-tool-display-mostly-generic-fallback
Closed

fix(agents): fall back to raw command when most exec stages are generic#87431
mogglemoss wants to merge 1 commit into
openclaw:mainfrom
mogglemoss:fix-tool-display-mostly-generic-fallback

Conversation

@mogglemoss

Copy link
Copy Markdown
Contributor

Summary

Fixes #87426.

When a multi-stage shell script has a few recognized stages mixed with many unrecognized "run X" stages, the previous joined paraphrase in resolveExecDetail reads as gibberish — e.g. a real

mkdir -p /tmp/x && set -u && if [ -f /tmp/x/y ]; then jq empty /tmp/x/y && true; fi && cat /tmp/x/y

rendered as create folder /tmp/x → run then set → run [ → run jq → run fi → run cat. That string is what landed in cron-delivery Discord notifications as ⚠️ 🛠️ `...` (agent) failed when agent turns ended in error without a final assistant message — looking like the agent had gone off the rails when really the underlying issue was upstream (HTTP 5xx, etc.).

This adds a mostlyGeneric heuristic in summarizeExecCommand: for scripts with ≥3 stages where ≥50% are unrecognized "run X" forms, prefer the compact raw command in resolveExecDetail instead of joining the stages. Short pipelines and commands with only one generic stage out of two keep their existing paraphrased summary.

Before:

⚠️ 🛠️ `create folder ~/.openclaw/workspace/.tmp → run then set → run true set → run [ → run then → run jq → run true) fi → run python3 scripts/birdweather.py → run sed transform (+2 steps) → run true) cat (agent)` failed

After (typical):

⚠️ 🛠️ `mkdir -p ~/.openclaw/workspace/.tmp && set -u && if [ -f ... ] (agent)` failed

The compact raw command is still truncated to 120 chars by compactRawCommand, so the notification stays readable.

Test plan

  • Added two tests in src/agents/tool-display.test.ts:
    • falls back to raw command when most stages of a multi-stage script are generic — repros the gibberish scenario and asserts the fallback path.
    • keeps the paraphrase for short multi-stage commands with one generic stage — regression guard so a 3-stage command with one unrecognized stage still gets the paraphrased summary, not the raw fallback.
  • Existing keeps multi-stage summary when only some stages are generic test continues to pass (2-stage case with one generic stage).
  • pnpm tsgo:core clean.
  • pnpm tsgo:core:test clean.
  • pnpm lint:core clean.
  • Full vitest.agents-core.config.ts suite: 299 test files passed, 4269 tests passed, 4 skipped.

Scope

Intentionally narrow: only changes the summarizeExecCommandresolveExecDetail decision for multi-stage exec details. The paraphraser itself, KNOWN_SUMMARY_PREFIXES, summarizePipeline, and formatToolAggregate are untouched. The fallback summary text format for cron delivery in src/agents/embedded-agent-runner/run/payloads.ts is unchanged — this PR just makes the meta string it consumes more readable when the command is a real script.


PR developed with assistance from Claude (Anthropic) per CONTRIBUTING.md AI-disclosure guidance. Repro evidence (multiple cron-delivery Discord notifications from production), root cause analysis, and fix were authored by [@mogglemoss]; Claude helped with code edits, test scaffolding, and exposition.

When a multi-stage shell script has a few recognized stages mixed with
many unrecognized "run X" stages, the previous joined paraphrase reads
as gibberish — e.g. a real `mkdir -p X && set -u && if [ -f Y ]; then
jq empty Y && true; fi && cat Y` would render as
`create folder X → run then set → run [ → run jq → run fi`. That
string is what landed in cron-delivery Discord notifications as
``⚠️ 🛠️ \`...\` (agent) failed`` when agent turns ended in error
without a final assistant message.

Add a `mostlyGeneric` heuristic in `summarizeExecCommand`: for scripts
with ≥3 stages where ≥50% are unrecognized "run X" forms, prefer the
compact raw command in `resolveExecDetail` instead of joining the
stages. Short pipelines and commands with one generic stage out of two
keep their existing paraphrased summary.

Fixes openclaw#87426

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@openclaw-barnacle openclaw-barnacle Bot added agents Agent runtime and tooling size: S triage: needs-real-behavior-proof Candidate: external PR needs after-fix proof from a real setup. labels May 27, 2026
@clawsweeper

clawsweeper Bot commented May 27, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge. Reviewed May 29, 2026, 1:14 AM ET / 05:14 UTC.

Summary
Review failed before ClawSweeper could summarize the requested change.

PR surface: Source +10, Tests +32, Docs +1. Total +43 across 3 files.

Reproducibility: unclear. The review failed before ClawSweeper could establish a reproduction path.

Review metrics: none identified.

Merge readiness
Overall: 🌊 off-meta tidepool
Proof: 🌊 off-meta tidepool
Patch quality: 🌊 off-meta tidepool
Result: rating does not apply to this item.

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

Risk before merge

  • [P1] No close action taken because the review did not complete.

Maintainer options:

  1. Decide the mitigation before merge
    Retry the Codex review after fixing the execution failure.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Next step before merge

  • [P1] Review did not complete, so no work-lane recommendation was made.
Review details

Best possible solution:

Retry the Codex review after fixing the execution failure.

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

Unclear. The review failed before ClawSweeper could establish a reproduction path.

Is this the best way to solve the issue?

Unclear. Retry the review first so ClawSweeper can evaluate the actual issue and fix direction.

AGENTS.md: unclear because the file could not be read completely.

Codex review notes: model gpt-5.5, reasoning high; reviewed against 98611e62728e.

Label changes

Label changes:

  • add rating: 🌊 off-meta tidepool: Overall readiness is 🌊 off-meta tidepool; proof is 🌊 off-meta tidepool and patch quality is 🌊 off-meta tidepool.
  • remove P2: Current review triage priority is none.
  • remove rating: 🧂 unranked krab: Current PR rating is rating: 🌊 off-meta tidepool, so this older rating label is no longer current.
  • remove status: 📣 needs proof: Current PR status no longer selects a status label.

Label justifications:

  • rating: 🌊 off-meta tidepool: Overall readiness is 🌊 off-meta tidepool; proof is 🌊 off-meta tidepool and patch quality is 🌊 off-meta tidepool.
Evidence reviewed

PR surface:

Source +10, Tests +32, Docs +1. Total +43 across 3 files.

View PR surface stats
Area Files Added Removed Net
Source 1 14 4 +10
Tests 1 32 0 +32
Docs 1 1 0 +1
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 3 47 4 +43

What I checked:

  • failure reason: codex execution failed.
  • codex failure detail: Codex review failed for this PR with exit 1.
  • codex stdout: Per-item Codex failure; continuing with the rest of the shard.

Likely related people:

  • unknown: Codex failed before it could trace repository history. (role: review did not complete; confidence: low)
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.

@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. P2 Normal backlog priority with limited blast radius. labels May 27, 2026
@clawsweeper

clawsweeper Bot commented May 27, 2026

Copy link
Copy Markdown
Contributor

ClawSweeper PR egg

🎁 Pass real behavior proof to wake the egg and unlock a hatchable treat.

Where did the egg go?
  • The egg game starts only after the PR passes the real-behavior proof check.
  • Before that, no creature or rarity is rolled. The treat waits for real proof.
  • This is still just collectible flavor: proof affects review readiness, not creature quality.

@amknight

Copy link
Copy Markdown
Member

The true root cause is that the splitter (splitTopLevelStages) doesn't understand if/then/fi - this is just a patch/workaround on top of it. I'll defer to @steipete on the best direction here - should we do a bigger refactor or accept this short-term patch?

@clawsweeper clawsweeper Bot added rating: 🌊 off-meta tidepool PR readiness rating does not apply to this item. 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 May 29, 2026
@mogglemoss

Copy link
Copy Markdown
Contributor Author

Closing this PR — not pursuing upstream.

The underlying issue (cron-delivery fallback summary paraphrases bash into unreadable step lists) has been mitigated locally by hardening the originating cron job's prompt to wrap inner failure-prone bash with set +e; …; exit 0 and always emit a final assistant message. That has been live for 10+ days with no recurrence, so the fix in this PR isn't load-bearing for my setup.

Leaving #87426 open as a report for maintainers — the paraphraser behavior is still suboptimal for any cron job that ends a turn in status: error without a final assistant message, and a maintainer is better positioned to choose the right shape of the fix (this PR's mostlyGeneric heuristic, an unconditional raw-fallback for shell tools, etc.). Happy to revisit if a maintainer wants to pick this up.

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

Labels

agents Agent runtime and tooling P2 Normal backlog priority with limited blast radius. rating: 🌊 off-meta tidepool PR readiness rating does not apply to this item. size: S triage: needs-real-behavior-proof Candidate: external PR needs after-fix proof from a real setup.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Cron delivery: synthesized "(agent) failed" summary paraphrases bash into garbled "step list"

3 participants