fix(agents): fall back to raw command when most exec stages are generic#87431
fix(agents): fall back to raw command when most exec stages are generic#87431mogglemoss wants to merge 1 commit into
Conversation
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]>
|
Codex review: needs real behavior proof before merge. Reviewed May 29, 2026, 1:14 AM ET / 05:14 UTC. Summary 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 follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch. Risk before merge
Maintainer options:
Next step before merge
Review detailsBest 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 changesLabel changes:
Label justifications:
Evidence reviewedPR surface: Source +10, Tests +32, Docs +1. Total +43 across 3 files. View PR surface stats
What I checked:
Likely related people:
What the crustacean ranks mean
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 PR egg 🎁 Pass real behavior proof to wake the egg and unlock a hatchable treat. Where did the egg go?
|
|
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? |
|
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 Leaving #87426 open as a report for maintainers — the paraphraser behavior is still suboptimal for any cron job that ends a turn in |
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
resolveExecDetailreads as gibberish — e.g. a realrendered 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) failedwhen 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
mostlyGenericheuristic insummarizeExecCommand: for scripts with ≥3 stages where ≥50% are unrecognized "run X" forms, prefer the compact raw command inresolveExecDetailinstead of joining the stages. Short pipelines and commands with only one generic stage out of two keep their existing paraphrased summary.Before:
After (typical):
The compact raw command is still truncated to 120 chars by
compactRawCommand, so the notification stays readable.Test plan
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.keeps multi-stage summary when only some stages are generictest continues to pass (2-stage case with one generic stage).pnpm tsgo:coreclean.pnpm tsgo:core:testclean.pnpm lint:coreclean.vitest.agents-core.config.tssuite: 299 test files passed, 4269 tests passed, 4 skipped.Scope
Intentionally narrow: only changes the
summarizeExecCommand→resolveExecDetaildecision for multi-stage exec details. The paraphraser itself,KNOWN_SUMMARY_PREFIXES,summarizePipeline, andformatToolAggregateare untouched. The fallback summary text format for cron delivery insrc/agents/embedded-agent-runner/run/payloads.tsis 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.