Skip to content

tools: copyable examples for wrong calls; tool-layer review fixes (deny floor, atomic writes, git) - #417

Merged
rromenskyi merged 7 commits into
mainfrom
tool-call-example
Nov 25, 2026
Merged

rromenskyi merged 7 commits into
mainfrom
tool-call-example

Conversation

@rromenskyi

@rromenskyi rromenskyi commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

Batch: copyable examples for wrong tool calls, and fixes from a review of the tool layer.

tools: answer a wrong call with a filled-in correct one

A call that misuses a tool (missing param, unknown action, an action of another
tool) now gets, ahead of the tool's schema, a ready-to-copy arguments object for
the action it meant: the model's own values for declared params, a
for each required one it left out, undeclared keys dropped, long values never
carried truncated. A garbled action name ("read_file") maps to the one action it
contains or is contained in; an ambiguous one gets no example. Encoded without
HTML escaping, so the model sees , not .

tools: example review fixes for #417

  • An action of another tool gets that tool's example, named as such — only when
    the params sent fit it (run + action "run" + command is not agent's run).
  • A garbled action matches an action by whole word ("readFile" → read, not
    "catalog" → log), never a mutating one, and never ambiguously.
  • No example when it would correct nothing (a call that failed for another
    reason, such as a remote MCP tool's own validation).
  • Optional values are kept as sent, a lone space included; blank required ones
    become placeholders.
  • Values are capped by their JSON size at any depth, and one of the wrong JSON
    type for its param is a placeholder. Placeholders are always marked slots
    ("", never a sentence or a bare 1/true).
  • The unparseable-params note no longer carries a file.write example.

tools: example — ambiguity before the mutation rule; edits as JSON string; integral ints

  • A garbled name matching two actions gets no example even when one of them
    mutates ("read_then_write" on the real file tool is not a read).
  • A list or object sent for a str param goes in as the JSON string the param
    takes (file.edit's edits, mcp's args), instead of a placeholder.
  • A fractional number is not a correct value for an int param.

config: the max_history row shows the cap in force

Raw memory raises auto's cap and the agent raises one below 2; the row showed
the configured number either way. It now shows what is in force, and
"2 (set 1)" when that differs from what was set.

tools: fixes from a review of the tool layer

  • Deny floor: also judged on every command the shell grammar nests (shellsplit:
    $( ), backticks, { }, ( ), if/while bodies, sh -c code), and past leading
    VAR=val assignments and keywords. FOO=1 rm -fr ~, echo $(rm -fr ~),
    then rm -fr ~ ran under run.default=allow.
  • write/edit replace a file whole (temp file, fsync, rename, mode kept), so a
    failure part-way can't leave half of it; in place only where no temp file can
    be made. append reports a failed flush on close.
  • write/edit refuse a pipe or device (opening one blocked with the file lock
    held); append to a pipe opens without blocking and fails if nothing reads it.
  • edit: find and replace follow a CRLF file's line endings; a find occurring
    more than once is refused (with the count) unless replace_all. write keeps a
    UTF-8 BOM the file had.
  • git push refuses a refspec that deletes a remote branch (":main").
  • git commit checks the staged set for secrets, failing closed, and names the
    staged files in the approval.
  • git push/pull/fetch: with no remote named, resolve the one git will use;
    every remote's URL is checked against the jail and named in the approval.
  • run keeps the start and the end of long output (the end holds the failures),
    cutting the middle; its approval names the directory when not the default.
  • search/find look in .github, .gitlab, .circleci and .devcontainer; an empty
    result says which dot-directories were skipped. find matches with slashes on
    Windows.

Not taken: lingering-child exit masking (os/exec returns ErrWaitDelay only on a
successful exit; checked), disabling filter drivers on status/diff (ADR 0017,
and it breaks LFS), plan-mode branch listing and offline local fetch (low).

tools: review fixes for the tool-layer changes

  • Deny floor: words are split the way the shell splits them (FOO='a b' rm -fr x
    ran past it); a command nested deeper than the parser follows is asked, never
    auto-run.
  • replaceFile: a new file is created directly, under the user's umask; a file
    with other hard links is written in place; owner and group are kept where we
    may; a rename that fails (a file held open on Windows) falls back to writing
    in place.
  • write keeps a BOM however large the file, and not into an empty write.
  • edit's note says a find must match once, or replace_all.
  • git: clone no longer resolves the workspace's default remote; a detached-HEAD
    push names no destination; remote URLs are taken a line each (a path may hold
    a space); commit's staged list skips the empty-output sentinel and keeps names
    exactly as git gives them.
  • HeadTailWriter drops at most one incomplete rune at the cut; tests pin the cut
    count.

tools: codex review fixes for the tool-layer changes

  • Deny floor: leading redirections (>out, 2>/dev/null, "> out") are skipped
    like assignments before naming the program.
  • replaceFile writes in place a file a replacement can't stand in for: other
    hard links (now counted on Windows too), extended attributes / POSIX ACLs, or
    an owner other than us.
  • edit tries the find exactly as given before its CRLF form: in a mixed file the
    CRLF form could match — and edit — a different place.
  • git: a detached-HEAD push resolves remote.pushDefault (it can push with a push
    refspec); a remote with more URLs than fit the output cap is refused rather
    than half-checked; commit doesn't refuse staging the removal of a tracked
    secret (deletions are named, not content-checked).

Each change has a test that fails with it reverted. go test ./..., -race on internal/agent, internal/tool, internal/policy, internal/textutil, and windows/darwin builds pass. Reviewed by codex, muse and devin; findings verified, the ones not taken are listed in the commits.

🤖 Generated with Claude Code

A call that misuses a tool (missing param, unknown action, an action of another
tool) now gets, ahead of the tool's schema, a ready-to-copy arguments object for
the action it meant: the model's own values for declared params, a <placeholder>
for each required one it left out, undeclared keys dropped, long values never
carried truncated. A garbled action name ("read_file") maps to the one action it
contains or is contained in; an ambiguous one gets no example. Encoded without
HTML escaping, so the model sees <path>, not <path>.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

@claude claude Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Code review skipped — your organization has no extra usage available to pay for this review.

If your organization's extra usage balance is empty, an organization admin can add extra usage credits at claude.ai/admin-settings/usage. If its monthly spend limit was reached, an admin can raise it on the same page. If neither applies, contact Anthropic support.

Once extra usage is available, someone with write access to this repository can comment @claude review on this pull request to trigger a review.

rromenskyi and others added 4 commits November 22, 2026 22:48
- An action of another tool gets that tool's example, named as such — only when
  the params sent fit it (run + action "run" + command is not agent's run).
- A garbled action matches an action by whole word ("readFile" → read, not
  "catalog" → log), never a mutating one, and never ambiguously.
- No example when it would correct nothing (a call that failed for another
  reason, such as a remote MCP tool's own validation).
- Optional values are kept as sent, a lone space included; blank required ones
  become placeholders.
- Values are capped by their JSON size at any depth, and one of the wrong JSON
  type for its param is a placeholder. Placeholders are always marked slots
  ("<content>", never a sentence or a bare 1/true).
- The unparseable-params note no longer carries a file.write example.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ring; integral ints

- A garbled name matching two actions gets no example even when one of them
  mutates ("read_then_write" on the real file tool is not a read).
- A list or object sent for a str param goes in as the JSON string the param
  takes (file.edit's edits, mcp's args), instead of a placeholder.
- A fractional number is not a correct value for an int param.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Raw memory raises auto's cap and the agent raises one below 2; the row showed
the configured number either way. It now shows what is in force, and
"2 (set 1)" when that differs from what was set.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
- Deny floor: also judged on every command the shell grammar nests (shellsplit:
  $( ), backticks, { }, ( ), if/while bodies, sh -c code), and past leading
  VAR=val assignments and keywords. `FOO=1 rm -fr ~`, `echo $(rm -fr ~)`,
  `then rm -fr ~` ran under run.default=allow.
- write/edit replace a file whole (temp file, fsync, rename, mode kept), so a
  failure part-way can't leave half of it; in place only where no temp file can
  be made. append reports a failed flush on close.
- write/edit refuse a pipe or device (opening one blocked with the file lock
  held); append to a pipe opens without blocking and fails if nothing reads it.
- edit: find and replace follow a CRLF file's line endings; a find occurring
  more than once is refused (with the count) unless replace_all. write keeps a
  UTF-8 BOM the file had.
- git push refuses a refspec that deletes a remote branch (":main").
- git commit checks the staged set for secrets, failing closed, and names the
  staged files in the approval.
- git push/pull/fetch: with no remote named, resolve the one git will use;
  every remote's URL is checked against the jail and named in the approval.
- run keeps the start and the end of long output (the end holds the failures),
  cutting the middle; its approval names the directory when not the default.
- search/find look in .github, .gitlab, .circleci and .devcontainer; an empty
  result says which dot-directories were skipped. find matches with slashes on
  Windows.

Not taken: lingering-child exit masking (os/exec returns ErrWaitDelay only on a
successful exit; checked), disabling filter drivers on status/diff (ADR 0017,
and it breaks LFS), plan-mode branch listing and offline local fetch (low).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@rromenskyi rromenskyi changed the title tools: answer a wrong call with a filled-in correct one tools: copyable examples for wrong calls; tool-layer review fixes (deny floor, atomic writes, git) Nov 23, 2026
rromenskyi and others added 2 commits November 22, 2026 23:37
- Deny floor: words are split the way the shell splits them (FOO='a b' rm -fr x
  ran past it); a command nested deeper than the parser follows is asked, never
  auto-run.
- replaceFile: a new file is created directly, under the user's umask; a file
  with other hard links is written in place; owner and group are kept where we
  may; a rename that fails (a file held open on Windows) falls back to writing
  in place.
- write keeps a BOM however large the file, and not into an empty write.
- edit's note says a find must match once, or replace_all.
- git: clone no longer resolves the workspace's default remote; a detached-HEAD
  push names no destination; remote URLs are taken a line each (a path may hold
  a space); commit's staged list skips the empty-output sentinel and keeps names
  exactly as git gives them.
- HeadTailWriter drops at most one incomplete rune at the cut; tests pin the cut
  count.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
- Deny floor: leading redirections (>out, 2>/dev/null, "> out") are skipped
  like assignments before naming the program.
- replaceFile writes in place a file a replacement can't stand in for: other
  hard links (now counted on Windows too), extended attributes / POSIX ACLs, or
  an owner other than us.
- edit tries the find exactly as given before its CRLF form: in a mixed file the
  CRLF form could match — and edit — a different place.
- git: a detached-HEAD push resolves remote.pushDefault (it can push with a push
  refspec); a remote with more URLs than fit the output cap is refused rather
  than half-checked; commit doesn't refuse staging the removal of a tracked
  secret (deletions are named, not content-checked).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@rromenskyi
rromenskyi merged commit 5b11ed6 into main Nov 25, 2026
2 checks passed
@rromenskyi
rromenskyi deleted the tool-call-example branch November 25, 2026 02:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant