Skip to content

fix(tool-display): don't render shell redirects or rg --files as search targets - #133783

Merged
steipete merged 3 commits into
openclaw:mainfrom
darioandyoshi-tech:fix/rg-files-display-redirect
Sep 1, 2026
Merged

steipete merged 3 commits into
openclaw:mainfrom
darioandyoshi-tech:fix/rg-files-display-redirect

Conversation

@darioandyoshi-tech

@darioandyoshi-tech darioandyoshi-tech commented Aug 31, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Tool-progress summaries could mistake shell redirection destinations for search paths, and treated rg --files as a search pattern. Filtering the decoded words alone also loses the distinction between redirection syntax and a literal quoted search pattern.

Move redirect handling into the existing shell-word parser, before quote removal, and consume option values through one shared option parser. This preserves quoted/escaped literals, attached and separated redirects, -- and -e/-f boundaries, and ripgrep glob/type options. The same lexical repair fixes misleading cat, head, tail, and copy summaries; raw command text keeps its separate opt-in.

The old tokenizer and duplicate positional/option scans are removed. The production delta is +133 lines (+244/-111): the lexical state now owns redirection operands and quote provenance, while the search owner declares the existing grep/ripgrep option arity. No new dependency, config, execution behavior, or public API is added. The richer asynchronous shell parser is unsuitable for this synchronous display boundary.

Evidence

  • New regression table: 20 failures and three passing controls against unchanged trusted main.
  • Final focused formatter, shell-substitution and shared helper suites: 93 passed. An intermediate ANSI-C quoting regression was caught by an existing sibling test and fixed without weakening the assertion.
  • Real GNU Bash argv/redirection and actual ripgrep checks: 15 passed, including quoted redirect literals, file-descriptor syntax, --files, --, and explicit patterns.
  • Full-candidate Codex P0 review: no actionable findings.
  • Changed-file gates passed, including core and core-test types, lint, formatting, and selected guards. Canonical task-scoped QA runtime build passed. Two actual ephemeral Gateway/mock-provider QA suites executed six shell commands and observed the real QA-channel tool-start arguments through the shared channel formatter. Explain/raw summaries were correct and default command-text privacy remained intact; task instrumentation was restored afterward. This is synthetic channel proof, not an external live-channel claim.
  • Final head ccdeaf5f92ec724489ebb93c20d38b2255fdb76b includes an ordinary merge of main; all four display owner/test files are byte-identical to the independently proven candidate. Exact-head CI run 33457433301 passed, including the required gate.

Review follow-through

The prior ClawSweeper findings about quoted redirection-like patterns and option boundaries are addressed at the lexical owner. Separated/attached redirects and glob/type values have focused coverage. The nearby hidden bug in sibling display summaries is fixed by the same parser rather than retained as a misleading display contract.

CI follow-through

The preceding head encountered two provider pricing tests whose expected introductory prices expired when the UTC date changed. The ordinary main merge includes the canonical clock-scoped fixture fix from #134564; no pricing production behavior changed. A separate job failed while downloading the Matrix crypto binary during dependency installation, before its tests ran. The prior PR-context check also required the exact Problem/Evidence headings, which this body now supplies. Final-head checks have now passed without changing the proven display-owner bytes or weakening assertions.

Observable Gateway proof

The following is the actual saved verdict from two ephemeral Gateway runs using the QA channel and a mock provider, with real shell execution. A task-only probe at the channel onToolStart sink recorded the existing shared progress formatter's output. The commands and paths are synthetic. This is trusted-main equivalent execution with the candidate's exact display-owner bytes; those bytes are unchanged at ccdeaf5f92ec724489ebb93c20d38b2255fdb76b. It is not a live external-channel test. Source instrumentation was restored and the clean runtime rebuilt afterward.

All six starts retain the default command-text privacy behavior (🛠️ Exec). With the existing command-text opt-in, explain mode gives the corrected summaries and raw mode additionally retains the original command.

{
  "complete": true,
  "runtime": "v24.20.0",
  "results": [
    {
      "mode": "explain",
      "status": "pass",
      "events": [
        {
          "toolName": "exec",
          "args": {
            "command": "rg --files -g '*.ts' source 2>err"
          },
          "detailMode": "explain",
          "defaultLine": "🛠️ Exec",
          "optInLine": "🛠️ list files in source"
        },
        {
          "toolName": "exec",
          "args": {
            "command": "rg '2>/dev/null' source/file.ts 2>err"
          },
          "detailMode": "explain",
          "defaultLine": "🛠️ Exec",
          "optInLine": "🛠️ search \"2>/dev/null\" in source/file.ts"
        },
        {
          "toolName": "exec",
          "args": {
            "command": "grep -e needle source/file.ts 2>err"
          },
          "detailMode": "explain",
          "defaultLine": "🛠️ Exec",
          "optInLine": "🛠️ search \"needle\" in source/file.ts"
        }
      ]
    },
    {
      "mode": "raw",
      "status": "pass",
      "events": [
        {
          "toolName": "exec",
          "args": {
            "command": "rg --files -g '*.ts' source 2>err"
          },
          "detailMode": "raw",
          "defaultLine": "🛠️ Exec",
          "optInLine": "🛠️ list files in source, `rg --files -g '*.ts' source 2>err`"
        },
        {
          "toolName": "exec",
          "args": {
            "command": "rg '2>/dev/null' source/file.ts 2>err"
          },
          "detailMode": "raw",
          "defaultLine": "🛠️ Exec",
          "optInLine": "🛠️ search \"2>/dev/null\" in source/file.ts, `rg '2>/dev/null' source/file.ts 2>err`"
        },
        {
          "toolName": "exec",
          "args": {
            "command": "grep -e needle source/file.ts 2>err"
          },
          "detailMode": "raw",
          "defaultLine": "🛠️ Exec",
          "optInLine": "🛠️ search \"needle\" in source/file.ts, `grep -e needle source/file.ts 2>err`"
        }
      ]
    }
  ]
}

…arch targets

`rg --files` takes no pattern, so every positional is a path, but the exec
summary read `positional[0]` as the pattern. `positionalArgs` also keeps shell
redirect tokens, and the summary uses the LAST positional as the target.

Together those made

    rg --files autonomy .openclaw 2>/dev/null

render as `search "autonomy" in 2>/dev/null`, naming a redirect as the path that
was searched. The same shape appeared in an agent failure notification, where it
read as though a file called `2>/dev/null` had been searched and sent debugging
down the wrong path.

Redirect filtering is deliberately applied only inside the grep/rg branch rather
than in `positionalArgs`. Other summaries already render redirect operators --
`cat > file <<EOF` renders as `show >` and is covered by an existing test -- so
filtering globally would change long-standing unrelated output.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01YbWMfBs2sgfwzkDkmnLSEB
@clawsweeper

clawsweeper Bot commented Aug 31, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

@openclaw-barnacle openclaw-barnacle Bot added agents Agent runtime and tooling size: S labels Aug 31, 2026
@clawsweeper clawsweeper Bot added merge-risk: 🚨 other 🚨 Merging this PR has meaningful risk outside the owned taxonomy. P2 Normal backlog priority with limited blast radius. 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. labels Aug 31, 2026
@clawsweeper

clawsweeper Bot commented Aug 31, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge. Reviewed August 31, 2026, 8:52 PM ET / September 1, 2026, 00:52 UTC.

ClawSweeper review

What this changes

The PR replaces the shell-word parsing used for agent tool-progress displays so shell redirects are excluded from summaries and rg --files is shown as a file listing.

Merge readiness

⛔ Blocked until stronger real behavior proof is added - 3 items remain

No blocking code findings: the prior lexical and option-boundary concerns are addressed at the shared display owner. Keep this PR open until it has inspectable after-fix behavior evidence and exact-head checks complete.

Priority: P2
Reviewed head: 3ff69aedf485f9088693532ca6577fb85454c157

Review scores

Measure Result What it means
Overall readiness 🦪 silver shellfish (2/6) The implementation cleanly addresses the earlier findings, but the reviewed material lacks inspectable after-fix behavior proof.
Proof confidence 🦪 silver shellfish (2/6) Needs stronger real behavior proof before merge: The shared exec-detail formatter feeds embedded, CLI, TUI, and channel progress text. The PR body describes after-fix formatter and mock-gateway runs, but contains no observable output or verdict JSON that demonstrates the corrected runtime result. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Needs proof Needs stronger real behavior proof before merge: The shared exec-detail formatter feeds embedded, CLI, TUI, and channel progress text. The PR body describes after-fix formatter and mock-gateway runs, but contains no observable output or verdict JSON that demonstrates the corrected runtime result. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
Evidence reviewed 7 items Current-main defect: Current main retains redirects as parsed words and then selects the last positional argument as the grep/ripgrep target, which permits a redirect operand to appear in the display summary.
Introduced repair: The verified PR delta classifies redirects before quote removal, shares option-boundary parsing, and adds focused cases for redirects, explicit patterns, and file-list mode.
Shared runtime boundary: The exec-detail formatter is reached through the common tool-display resolver; embedded tool starts and CLI command-result projection derive their summaries through the same helper.
Findings None None.
Security None None.

How this fits together

Agent tool calls are converted into concise, privacy-aware progress text for transcripts, channel updates, CLI output, and the TUI. This formatter receives command text and emits explanatory or raw display text without changing command execution.

flowchart LR
  A[Agent tool call] --> B[Shell command text]
  B --> C[Shell syntax parser]
  C --> D[Command summary formatter]
  D --> E[Transcript and channel display]
  D --> F[CLI and TUI display]
Loading

Before merge

  • Add real behavior proof - Needs stronger real behavior proof before merge: The shared exec-detail formatter feeds embedded, CLI, TUI, and channel progress text. The PR body describes after-fix formatter and mock-gateway runs, but contains no observable output or verdict JSON that demonstrates the corrected runtime result. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
  • Resolve merge risk (P1) - This common parser changes several command-summary paths; its asserted runtime validation is not independently inspectable in the reviewed PR material, and exact-head checks remain incomplete.
  • Complete next step (P2) - No mechanical repair is indicated; the remaining merge gates are inspectable behavior proof and exact-head validation.
Agent review details

Security

None.

PR surface

Source +133, Tests +45. Total +178 across 4 files.

View PR surface stats
Area Files Added Removed Net
Source 2 244 111 +133
Tests 2 47 2 +45
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 4 291 113 +178

Review metrics

Metric Value Why it matters
Production versus test delta production +133, tests +45 The shared lexical parser grows materially for a bug fix, making focused runtime evidence and exact-head validation important before merge.

Merge-risk options

Maintainer options:

  1. Complete behavior proof and checks (recommended)
    Attach a redacted after-fix formatter trace or mock-gateway verdict, then merge only after the exact reviewed head has green required checks.

Technical review

Best possible solution:

Retain the single lexical parser and focused regression table, attach a redacted after-fix formatter or mock-gateway trace, then merge once exact-head checks are green.

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

Yes: current main retains redirect operands in its word list and then chooses the last positional item for grep/ripgrep display text; the new focused cases directly cover that owner path.

Is this the best way to solve the issue?

Yes: handling redirects before quote removal at the shared shell-word owner is the maintainable solution, because it preserves literals and corrects sibling command summaries without a search-only workaround.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

  • add rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦪 silver shellfish and patch quality is 🐚 platinum hermit.
  • add status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs stronger real behavior proof before merge: The shared exec-detail formatter feeds embedded, CLI, TUI, and channel progress text. The PR body describes after-fix formatter and mock-gateway runs, but contains no observable output or verdict JSON that demonstrates the corrected runtime result. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
  • remove proof: sufficient: Current real behavior proof status is insufficient, not sufficient.
  • remove rating: 🦐 gold shrimp: Current PR rating is rating: 🦪 silver shellfish, so this older rating label is no longer current.
  • remove status: ⏳ waiting on author: Current PR status label is status: 📣 needs proof.

Label justifications:

  • P2: This is a bounded correction to agent progress text without demonstrated data loss, security, delivery, or availability impact.
  • merge-risk: 🚨 other: The shared parser changes token interpretation across multiple user-visible command summaries, so untested shell edge cases could misdescribe activity.
  • rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦪 silver shellfish and patch quality is 🐚 platinum hermit.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs stronger real behavior proof before merge: The shared exec-detail formatter feeds embedded, CLI, TUI, and channel progress text. The PR body describes after-fix formatter and mock-gateway runs, but contains no observable output or verdict JSON that demonstrates the corrected runtime result. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.

Evidence

What I checked:

  • Current-main defect: Current main retains redirects as parsed words and then selects the last positional argument as the grep/ripgrep target, which permits a redirect operand to appear in the display summary. (src/agents/tool-display-exec.ts:119, 2fb27b8d3724)
  • Introduced repair: The verified PR delta classifies redirects before quote removal, shares option-boundary parsing, and adds focused cases for redirects, explicit patterns, and file-list mode. (src/agents/tool-display-exec-shell.ts:36, 3ff69aedf485)
  • Shared runtime boundary: The exec-detail formatter is reached through the common tool-display resolver; embedded tool starts and CLI command-result projection derive their summaries through the same helper. (src/agents/tool-display-common.ts:747, 3ff69aedf485)
  • Existing and added coverage: Existing formatter tests cover compound commands, shell substitutions, raw/explain modes, and heredocs; the new table covers the repaired redirect and ripgrep cases at the display boundary. (src/agents/tool-display-exec-search.test.ts:4, 3ff69aedf485)
  • Feature history: Commit e20a329 created the shared display formatter files; current-main blame is boundary-limited, so it is only a routing signal rather than exact-line introduction proof. (src/agents/tool-display-exec-shell.ts:29, e20a3298b13d)
  • Release status: No local release tag contains the PR head, so the proposed repair is neither on current main nor shipped. (3ff69aedf485)

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Attach a redacted terminal trace or mock-gateway verdict showing corrected redirect and rg --files summaries; redact private paths, endpoints, and tokens.
  • Let required checks complete on the exact reviewed head; if body-only proof does not trigger refresh, ask a maintainer to comment @clawsweeper re-review.

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
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.

Workflow

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

History

Review history (1 earlier review cycle)
  • reviewed August 31, 2026, 2:42 AM ET / 06:42 UTC sha unknown :: needs changes before merge. :: [P2] Preserve literal redirect-like search patterns | [P2] Honor ripgrep option boundaries in file-list mode

@steipete steipete self-assigned this Sep 1, 2026
Retain quote provenance while excluding complete redirections, and use one option parser for value-taking flags and positional boundaries. Correct ripgrep file-list mode and inherited cat/head/tail/copy summaries without changing execution or command-text privacy.

Co-authored-by: darioandyoshi-tech <[email protected]>
@openclaw-barnacle openclaw-barnacle Bot added size: M triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence. and removed size: S labels Sep 1, 2026
@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. and removed 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. labels Sep 1, 2026
Merge trusted main with the landed clock-scoped provider fixtures addressing the observed CI failures. Keep the reviewed shell display owner and regression files byte-identical to the passing focused and actual Gateway proof.

Co-authored-by: darioandyoshi-tech <[email protected]>
@openclaw-barnacle openclaw-barnacle Bot removed the triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence. label Sep 1, 2026
@steipete
steipete merged commit b48e2db into openclaw:main Sep 1, 2026
298 checks passed
@steipete

steipete commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 1, 2026
…arch targets (openclaw#133783)

* fix(tool-display): don't render shell redirects or `rg --files` as search targets

`rg --files` takes no pattern, so every positional is a path, but the exec
summary read `positional[0]` as the pattern. `positionalArgs` also keeps shell
redirect tokens, and the summary uses the LAST positional as the target.

Together those made

    rg --files autonomy .openclaw 2>/dev/null

render as `search "autonomy" in 2>/dev/null`, naming a redirect as the path that
was searched. The same shape appeared in an agent failure notification, where it
read as though a file called `2>/dev/null` had been searched and sent debugging
down the wrong path.

Redirect filtering is deliberately applied only inside the grep/rg branch rather
than in `positionalArgs`. Other summaries already render redirect operators --
`cat > file <<EOF` renders as `show >` and is covered by an existing test -- so
filtering globally would change long-standing unrelated output.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01YbWMfBs2sgfwzkDkmnLSEB

* fix(agents): parse shell redirects before display arguments

Retain quote provenance while excluding complete redirections, and use one option parser for value-taking flags and positional boundaries. Correct ripgrep file-list mode and inherited cat/head/tail/copy summaries without changing execution or command-text privacy.

Co-authored-by: darioandyoshi-tech <[email protected]>

---------

Co-authored-by: darioandyoshi-tech <[email protected]>
Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
Co-authored-by: Peter Steinberger <[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 merge-risk: 🚨 other 🚨 Merging this PR has meaningful risk outside the owned taxonomy. P2 Normal backlog priority with limited blast radius. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. size: M 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.

2 participants