Skip to content

fix(agents): remind exec models to quote shell metacharacters - #125485

Merged
steipete merged 3 commits into
openclaw:mainfrom
clawSean:fix/exec-shell-quoting-guidance
Aug 26, 2026
Merged

steipete merged 3 commits into
openclaw:mainfrom
clawSean:fix/exec-shell-quoting-guidance

Conversation

@clawSean

@clawSean clawSean commented Aug 18, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • add Unix shell-quoting guidance to the model-facing exec tool description
  • call out URL query strings containing ? or &, a common source of zsh glob failures
  • keep the guidance off Windows, where OpenClaw directs models to invoke executables directly
  • keep the final authorized-tool description expectations aligned with the shared description builder

What Problem This Solves

On Unix-like hosts, an agent can pass an unquoted URL/query argument such as path?recursive=1 to exec. Under zsh's default nomatch behavior, ? is treated as a glob and the shell aborts before the intended CLI runs.

The current exec description explains backgrounding, cron, and PTY usage without warning about shell metacharacters. That leaves the model without the instruction needed to form shell-safe arguments.

Why This Change Was Made

The model-facing exec description is the owning boundary for command-construction guidance. Adding one Unix-only sentence there reaches both the direct exec tool and the final authorized-tool composition without changing execution, approval, warning, or configuration behavior.

The follow-up updates the two exact composed-description expectations that CI caught. Those expectations intentionally protect the final prompt bytes both with and without cron available; the direct builder test alone would not prove that the post-filter composition preserved the guidance.

User Impact

On Unix-like systems, models now receive a concise reminder to quote arguments containing shell metacharacters, explicitly including URL query strings with ? or &. This reduces commands that fail in the shell before the requested CLI can run. Windows guidance is unchanged.

Evidence

  • Failing reproduction before the expectation repair:
    • node scripts/run-vitest.mjs src/agents/agent-tools.deferred-followup-guidance.test.ts
    • result: 2 failed, 2 passed; both failures showed the rendered exec description contained the new quoting sentence while the two exact composed expectations did not
  • Focused composed-path regression after the repair:
    • node scripts/run-vitest.mjs src/agents/agent-tools.deferred-followup-guidance.test.ts
    • result: 4/4 passed
  • Focused direct-builder regression:
    • node scripts/run-vitest.mjs src/agents/bash-tools.test.ts
    • result: 35/35 passed
  • Formatting:
    • node_modules/.bin/oxfmt --check src/agents/agent-tools.deferred-followup-guidance.test.ts
    • result: passed
  • Diff integrity:
    • git diff --check
    • result: passed

Rendered final authorized-tool description on a Unix host:

$ node --import tsx --input-type=module -e 'import { applyToolAvailabilityDescriptions } from "./src/agents/agent-tools.deferred-followup.ts"; const [exec] = applyToolAvailabilityDescriptions([{ name: "exec", description: "base" }, { name: "process", description: "base" }]); console.log(`platform=${process.platform}`); console.log(exec.description);'
platform=darwin
Run shell now; background continuation supported. Use yieldMs/background, then process for logs/status/input/intervention. Long run: automatic completion wake when enabled and output/failure occurs; otherwise process confirms completion. Quote arguments containing shell metacharacters, including URL query strings with `?` or `&`. TTY CLI/UI/coding agent: pty=true.

The transcript contains no credentials, user paths, or other sensitive values.

Scope

No execution behavior, warning policy, config, or Windows guidance changes. The PR remains a +3 production-line / +6 test-line change; the follow-up updates two existing test lines with zero net line growth.

AI-assisted: yes. I reviewed the implementation, composed prompt behavior, and focused test results.

@clawsweeper

clawsweeper Bot commented Aug 18, 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: XS triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence. and removed triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence. labels Aug 18, 2026
@clawsweeper clawsweeper Bot added merge-risk: 🚨 automation 🚨 May affect CI, automerge, proof capture, label sync, or maintainer automation. P2 Normal backlog priority with limited blast radius. 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 Aug 18, 2026
@clawsweeper

clawsweeper Bot commented Aug 18, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 26, 2026, 6:36 PM ET / 22:36 UTC.

ClawSweeper review

What this changes

Adds Unix-only shell-quoting guidance to the model-facing exec description and expands its direct and composed-description contract tests.

Merge readiness

✅ Ready for maintainer review

This PR remains necessary: current main still omits Unix shell-metacharacter quoting guidance from the exec tool description. The focused change uses the shared description builder and covers both direct and final authorized-tool composition paths; no correctness finding was identified.

Priority: P2
Reviewed head: a74f33c97fa4a67cd5898ba654d3c2a8a6dac810

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused owner-boundary change with composed-path and platform coverage plus direct terminal evidence.
Proof confidence 🐚 platinum hermit (4/6) Sufficient (terminal): The PR body includes an after-fix terminal rendering of the final Unix authorized-tool description with the new guidance.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (terminal): The PR body includes an after-fix terminal rendering of the final Unix authorized-tool description with the new guidance.
Evidence reviewed 4 items Current-main behavior: Current main returns the base exec description unchanged on non-Windows hosts, so it does not include the requested quoting reminder.
PR owner-boundary change: The PR adds the guidance at the shared description builder’s Unix branch; the final availability pass also calls this builder when assembling authorized tools.
Composition coverage: The updated composed-description test fixes the platform to Linux and verifies the final exec text with scheduler and process-tool availability variants.
Findings None None.
Security None None.

Live Verification

Command: node --import tsx --input-type=module -e 'import { describeExecTool } from "./src/agents/bash-tools.descriptions.ts"; console.log(describeExecTool())'

Result: PASS (completed)

Run shell now; background continuation supported. Use yieldMs/background, then process for logs/status/input/intervention. Long run: automatic completion wake w
hen enabled and output/failure occurs; otherwise process confirms completion. TTY CLI/UI/coding agent: pty=true. Quote arguments containing shell metacharacters
, including URL query strings with ˋ?ˋ or ˋ&ˋ.
Run shell now; background continuation supported. Use yieldMs/background, then process for logs/status/input/intervention. Long run: automatic completion wake w
hen enabled and output/failure occurs; otherwise process confirms completion. TTY CLI/UI/coding agent: pty=true. Quote arguments containing shell metacharacters
, including URL query strings with ˋ?ˋ or ˋ&ˋ.

Assertions:

  • PASS expect_output: Quote arguments containing shell metacharacters

How this fits together

Agent tool assembly creates an exec tool description for the model, then finalizes the authorized tool set before a run. The description varies by host platform and available companion tools, affecting how agents form shell commands.

flowchart LR
  A[Agent tool assembly] --> B[Exec description builder]
  B --> C{Host platform}
  C -->|Unix| D[Quoting guidance]
  C -->|Windows| E[Windows execution guidance]
  D --> F[Final authorized tools]
  E --> F
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source 0, Tests +41. Total +41 across 4 files.

View PR surface stats
Area Files Added Removed Net
Source 1 1 1 0
Tests 3 73 32 +41
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 4 74 33 +41

Review metrics

Metric Value Why it matters
Production vs test LOC production +0 net; tests +41 net, including a 24-line test relocation The behavior change is absorbed into an existing description branch; the remaining growth is focused platform and final-composition coverage.

Technical review

Best possible solution:

Land the shared Unix-only guidance after exact-head checks are green and GitHub confirms a clean merge.

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

Yes, source establishes the missing path: on Unix current main returns the base exec description without shell-quoting guidance, while the PR adds it at that branch.

Is this the best way to solve the issue?

Yes. Adding the reminder in the shared description builder reaches both direct exec creation and final authorized-tool composition without adding runtime policy or configuration.

AGENTS.md: found and applied where relevant.

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

Labels

Label justifications:

  • P2: The PR addresses a bounded agent command-construction failure mode without changing execution policy or user configuration.
  • 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 an after-fix terminal rendering of the final Unix authorized-tool description with the new guidance.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR body includes an after-fix terminal rendering of the final Unix authorized-tool description with the new guidance.

Evidence

What I checked:

Likely related people:

  • steipete: Current-main blame attributes the platform-specific description branch to this author, who also authored accessible direct history for the description and final-tool composition surfaces. (role: current feature owner and recent area contributor; confidence: high; commits: 0e054de54fa2, 5fa137ee4737, 204d2b176aaf; files: src/agents/bash-tools.descriptions.ts, src/agents/agent-tools.deferred-followup.ts, src/agents/lazy-exec-tool.ts)

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 (5 earlier review cycles)
  • reviewed 2026-08-18T00:59:48.545Z sha 6a3dcc62ec3f720d3853cf579f0d27278259177b :: needs real behavior proof before merge. :: [P2] Update exact composition-description expectations
  • reviewed August 21, 2026, 7:57 AM ET / 11:57 UTC sha unknown :: needs real behavior proof before merge. :: [P2] Update composed-description expectations
  • reviewed 2026-08-22T01:03:58.506Z sha 16d27858dabdfde1f15536a9a51197978f3367c5 :: needs maintainer review before merge. :: none
  • reviewed 2026-08-22T01:45:48.963Z sha 16d27858dabdfde1f15536a9a51197978f3367c5 :: needs maintainer review before merge. :: none
  • reviewed 2026-08-26T22:13:05.491Z sha 6685010 :: needs maintainer review before merge. :: none

@clawsweeper clawsweeper Bot removed the merge-risk: 🚨 automation 🚨 May affect CI, automerge, proof capture, label sync, or maintainer automation. label Aug 21, 2026
@clawSean
clawSean force-pushed the fix/exec-shell-quoting-guidance branch from 6a3dcc6 to 16d2785 Compare August 22, 2026 00:57
@clawSean

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Aug 22, 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 exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@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: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. 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 Aug 22, 2026
@steipete
steipete force-pushed the fix/exec-shell-quoting-guidance branch from 16d2785 to 6685010 Compare August 26, 2026 22:06
@clawsweeper clawsweeper Bot added rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. labels Aug 26, 2026
@steipete

steipete commented Aug 26, 2026 •

Copy link
Copy Markdown
Contributor

Refreshed and verified at a74f33c97fa4. Exact-head CI passed, including these complete files:

  • src/agents/bash-tools.descriptions.test.ts: 4 tests passed (Darwin/Linux/Windows and public-factory scheduler guidance).
  • src/agents/agent-tools.deferred-followup-guidance.test.ts: 27 tests passed (including process present/absent with automations, cron alias, or no scheduler).
  • src/agents/bash-tools.test.ts: 33 tests passed.

The fix stays in the canonical exec-description owner: one Unix-only sentence, no additional runtime branch, and no change to Windows guidance or current process/scheduler wording. Production is +1/-1 (net zero); tests are +73/-32, including relocation of the complete existing description suite. The previous CI run caught the large test file exceeding its line limit; the dedicated description suite preserves every assertion, and the formerly failing lint lane now passes.

Independent real /bin/zsh -f -c probes with harmless printf demonstrated both failure modes: an unquoted query URL fails with no matches found, while an unquoted ampersand silently truncates the argument. Quoting the identical arguments preserves their bytes. These are shell-behavior proofs, not a measured claim about model success rates. No network request was needed for those probes.

Full-runtime/live-model proof was not completed: the isolated proof environment failed before candidate execution. The completed execution evidence is secretless exact-head CI plus the real zsh probes above; no live-model compliance claim is made.

The earlier ClawSweeper current-main/history gap is resolved: the local merge base is 11661e4502fe9946661e357439cfbb9d02375264, and the affected owner/finalizer/test paths remain unchanged on main through 8237d3fac23869341f8e52abcec0811f64a05d0f. GitHub reports the PR mergeable, so another rebase solely for main's advancement was skipped. The latest ClawSweeper review covers this exact final head and has no outstanding before-merge items; its requested focused execution proof is recorded above.

Thanks @clawSean for the original fix. Contributor authorship is preserved.

@steipete
steipete merged commit 976d195 into openclaw:main Aug 26, 2026
250 checks passed
@steipete

Copy link
Copy Markdown
Contributor

Merged via squash.

vincentkoc added a commit that referenced this pull request Aug 26, 2026
* origin/main: (26 commits)
  fix(plugins): preserve registry epoch on activation rollback (#129232)
  refactor(plugins): make discovery invocation-owned (#130486)
  feat(ui): save appearance preferences per user profile (#130340)
  fix: Buzz bots recover relay stalls and reject revoked senders (#130467)
  fix(code-mode): serialize catalog handles nested in final values (#130276)
  fix(webchat): CLI skill and harness-injected turns render as operator-sent messages (#130427)
  fix(agents): read the published model catalog owner from session_status (#130277)
  fix(channels): preserve long presentation text (#130368)
  fix(agents): route CLI bootstrap truncation notice into the system prompt (#130325)
  refactor(plugins): unify setup registration and artifact selection (#130474)
  fix(memory): prevent forgotten session content from returning (#130451)
  refactor(outbound): consolidate transport completion (#130460)
  fix(workers): protect in-flight workspace manifests from concurrent retention (#130449)
  fix(portals): keep worker previews reachable and owned by the active environment (#130434)
  fix(config): keep core channels keys in the generated config schema (#120736)
  chore(deps): refresh dependencies after seven-day cooldown (#130296)
  fix(agents): remind exec models to quote shell metacharacters (#125485)
  fix(auth): honor shared-store ownership in temp-state exec and agent deletion (#130437)
  fix(openshell): preserve file writes during concurrent mirror commands (#130447)
  fix(workers): report full nodes as at capacity, not offline (#130445)
  ...
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 27, 2026
…aw#125485)

* fix(agents): remind exec models to quote shell metacharacters

* test(agents): cover exec quoting across platform and tool availability

* test(agents): isolate exec description contracts

---------

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 P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: S 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.

2 participants