Repository navigation
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
Codex review: needs maintainer review before merge. Reviewed August 22, 2026, 9:28 PM ET / August 23, 2026, 01:28 UTC. ClawSweeper reviewWhat this changesThis PR preserves literal dollar sequences in slash-command prompt-template and bundle-command arguments, and prevents inserted prompt arguments from being expanded again by later placeholder passes. Merge readinessThe patch appears correct at its reviewed head and has credible real behavior proof, but this checkout could not materialize the supplied current-main revision to verify whether the work is already covered or safely fresh against main. Keep it open for an exact-main refresh rather than making an obsolete/merge-ready verdict. Priority: P2 Review scores
Verification
Live VerificationCommand: Result: PASS (completed) Assertions:
How this fits togetherSlash commands are converted into prompt text before an agent run. This change sits in the argument-template and bundle-command expansion paths, which pass user-entered arguments into the model-facing message body. flowchart LR
A[Slash command] --> B[Argument parsing]
B --> C[Prompt template expansion]
A --> D[Bundle command lookup]
D --> E[Bundle prompt expansion]
C --> F[Model-facing message]
E --> F
F --> G[Agent run]
Before merge
Agent review detailsSecurityNone. PR surfaceSource +1, Tests +44. Total +45 across 4 files. View PR surface stats
Review metrics
Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Rebase the focused repair onto current main, retain the canonical single-pass resolver and literal callback replacement, then rerun the two owner-boundary suites on the exact merge candidate. Do we have a high-confidence way to reproduce the issue? Yes—source establishes both affected paths, and the PR body includes a before/after terminal probe through the real prompt-template owner plus owner-boundary red-green regressions. Is this the best way to solve the issue? Yes—the callback replacement and one-pass placeholder resolver repair the producing expansion owners without adding a parallel path or changing command syntax. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against d75164c46d43. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (7 earlier review cycles)
|
21dccec to
cb60ffe
Compare
|
CI failure attribution for
|
cb60ffe to
535219f
Compare
… substitution Three call sites used String.replace/replaceAll with a string replacement fed a runtime variable, causing dollar-amp/dollar-1/dollar-backtick sequences in user-supplied args or approval ids to corrupt the rendered text. Switch each to a function replacement so the value is treated literally: - prompt-template-arguments: dollar-ARGUMENTS and dollar-@ substitution corrupted slash-command args containing dollar signs - get-reply-inline-actions: bundle command template expansion had the same issue with normalizedArgs - approval-reaction-runtime: approval id placeholder rendering mangled ids containing dollar signs; the iMessage sibling (extensions/imessage/src/approval-text.ts) already escapes this
Address review: the approval placeholder helper has no canonical /approve <id> producer in the plugin-SDK manual fallback path, so its rewrite is unproven - revert it. Keep the two reachable prompt-template fixes and add an owner-boundary regression covering literal dollar sequences in dollar-ARGUMENTS and dollar-@ substitution (fails on the old string replacement form, passes with the callback form).
535219f to
b18fc02
Compare
|
Maintainer verification on the unchanged original contributor head
|
|
Merged via squash.
|
…titution (openclaw#123015) * fix: prevent dollar-pattern injection in prompt template and approval substitution Three call sites used String.replace/replaceAll with a string replacement fed a runtime variable, causing dollar-amp/dollar-1/dollar-backtick sequences in user-supplied args or approval ids to corrupt the rendered text. Switch each to a function replacement so the value is treated literally: - prompt-template-arguments: dollar-ARGUMENTS and dollar-@ substitution corrupted slash-command args containing dollar signs - get-reply-inline-actions: bundle command template expansion had the same issue with normalizedArgs - approval-reaction-runtime: approval id placeholder rendering mangled ids containing dollar signs; the iMessage sibling (extensions/imessage/src/approval-text.ts) already escapes this * fix: rebase, drop unproven approval rewrite, add dollar regression Address review: the approval placeholder helper has no canonical /approve <id> producer in the plugin-SDK manual fallback path, so its rewrite is unproven - revert it. Keep the two reachable prompt-template fixes and add an owner-boundary regression covering literal dollar sequences in dollar-ARGUMENTS and dollar-@ substitution (fails on the old string replacement form, passes with the callback form). * test(auto-reply): cover literal dollar bundle command arguments * fix(agent-core): resolve prompt placeholders in a single substitution pass
What Problem This Solves
Two call sites used
String.replace/replaceAllwith a string replacement fed a runtime variable. JavaScript interprets$&,$1–$9,$`,$'in string replacements, so user-supplied content containing$is silently corrupted:packages/agent-core/src/harness/prompt-template-arguments.ts:83-84—$ARGUMENTSand$@substitution corrupts slash-command args containing$(e.g. shell variables, prices).$$collapses to$,$&becomes the entire match.replaceAll("$ARGUMENTS", normalizedArgs)as a string replacement re-interprets$patterns fromskillInvocation.args; the rendered result feeds agent prompt fields. (Owner moved during this PR's lifetime: originallysrc/auto-reply/reply/get-reply-inline-actions.ts, extracted upstream tosrc/skills/discovery/chat-command-invocation.tsin fix(ui): show skill mentions in the new-session composer #125554-era refactoring; this branch follows the invariant to the new owner.)Why This Change Was Made
String.replace(regex, () => value)treats the return value literally — no$interpretation. Each call site switches from the string form to the function form. Same fix pattern as #111398 (terminal-core display-string) and the core home-dir resolver PR #122991.(An initially included third call site — the plugin-SDK
replaceApprovalIdPlaceholder— was removed per review: that helper has no canonical/approve <id>placeholder producer in the plugin-SDK manual fallback path, so the rewrite was unproven.)User Impact
When a user runs a slash command (or bundle command) with arguments containing
$— e.g.fix $HOME variable,price is $$5— the args are mangled before reaching the model:$$collapses to$,$&re-expands to the template placeholder text. The model sees corrupted input and acts on wrong data.Evidence
Runtime probe through the real prompt-template owner (before → after)
node --import tsx /tmp/verify-prompt-dollar.mjsimports the realsubstituteArgsmodule from this branch:Owner-boundary regressions (both red-green verified)
packages/agent-core/src/harness/prompt-template-arguments.test.ts:substituteArgs("Args: $ARGUMENTS", parseCommandArgs("price $$ and $& here"))must stay literal.expected 'Args: price $ and $ARGUMENTS here'.src/auto-reply/reply/get-reply-inline-actions.skip-when-config-empty.test.ts: new case "keeps literal $ patterns in bundle command arguments" drives the actual changed route end-to-end throughrunTestInlineActions(realhandleInlineActions, real skill-command rewriting) with/office_hours price $$ and $& here, asserting bothctx.Bodyand thehandleCommandsprompt body keepprice $$ and $& hereliterally.AssertionError: expected 'Act as an engineering advisor.\n\nFoc…' to be '…'— the rendered prompt had$$/$&re-expanded.Single-pass placeholder resolution (addresses review finding)
substituteArgspreviously ran four sequential replace passes ($1…,${@:N},$ARGUMENTS,$@), so text inserted by an early pass could be re-interpreted by a later one. It now resolves every placeholder in one combined pass; an inserted argument is final data.AssertionError: expected '$ARGUMENTS safe $ARGUMENTS safe' to be '$ARGUMENTS $ARGUMENTS safe'forsubstituteArgs("$1 $@", ["$ARGUMENTS", "safe"])— exactly the review's reproduction.substituteArgs("$1 $@", ["$ARGUMENTS", "safe"]) === "$ARGUMENTS $ARGUMENTS safe", plussubstituteArgs("$1 ${@:2:1}", ["$@", "$ARGUMENTS", "safe"]) === "$@ $ARGUMENTS".node --import tsx /tmp/verify-prompt-dollar.mjs) now printsPASS substituteArgs resolves all placeholders in one passalongside the literal-$PASS above.Tests (rebased onto latest
mainincl. the chat-command extraction, exact head91cb18b38f2)node scripts/run-vitest.mjs src/auto-reply/reply/get-reply-inline-actions.skip-when-config-empty.test.ts→ 35 passed (red-green re-verified on the newchat-command-invocation.tsowner: reverting only that file tomainmakes the literal-$case fail)node scripts/run-vitest.mjs packages/agent-core/src/harness/prompt-template-arguments.test.ts→ 3 passedgit diff --check→ cleanPrior CI red-shard attribution (superseded head)
On head
cb60ffe9f61,checks-node-compact-small-12failed attest/scripts/install-sh.test.ts > install.sh > bounds installer npm prefix probes during finalization helpers. That test passes 88/88 on latestmainlocally (node 26.5.0) and touches the installer, unrelated to this diff — runner/flaky-specific, not introduced by this PR.Production LOC: the two substitutions became one single-pass resolver (+6 net in
prompt-template-arguments.ts, callback form retained);chat-command-invocation.tsnet 0. Test LOC: +46.Sibling already fixed:
packages/terminal-core/src/display-string.ts:53(#111398) uses the callback form for the same$-expansion invariant.CI (exact head
91cb18b38f2)Full CI matrix green: run 32098907313.