Repository navigation
Add the tool-cli runner (remote tools, executor step 2) - #4312
Merged
Merged
Conversation
Contributor
Author
|
Merge queue: #4312 was taken out of the queue — the merge gate failed on it, on top of main. Reproduce by merging or rebasing |
Runs the program a tool-cli binding names: no shell, each placeholder one whole argv element with -- before model values, a built environment, credentials resolved only into the child's environment and redacted from every result, stream-capped output, and a timeout that kills the process group. Offering is gated on a confirmer being installed, so until one is wired no tool-cli is offered. Results and errors from a remote program are not repeated as the failure reason; the system prompt carries the external-data rule only when a remote tool is offered. Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
…dentials always in the confirmation, private working directory, group kill on cancel Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
…entials, repeat the tail strip Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
mstomar125
force-pushed
the
issue-4291-cli-runner
branch
from
November 19, 2026 16:26
2db380d to
abd8441
Compare
This was referenced Nov 19, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Refs #4291, executor step 2: the
tool-clirunner. This PR changespackages/agent(and installs the runner inpackages/daemon): the user's sign-off stands in for the agent owner's for this build. The acceptance criteria are the ones carried in the merged gate PR.What it adds
packages/agent/src/local_agent/cli_runner.rs(CliRunner), installed in the daemon'sRemoteToolHost:ToolCliFields::from_bucketand must passcheck_completeagainst the tool's schema; a malformed or incomplete binding is an error before any process starts.{name}placeholder is one whole argv element whatever the model's value holds (spaces,;,$(...), backticks, quotes, a leading-). A value is a string, number or boolean; anything else, and any string with a NUL, is refused. A placeholder whose argument the model left out is dropped.--before model values. A--element is inserted before the first model-supplied element, only when there is one.env_clear(), thenPATH HOME LANG USER TMPDIRfrom the daemon when set, plus the entries the binding declares. Nothing else is inherited. The child's working directory is the system temp dir.enventry'skeychain:/env:reference is resolved (resolve_credential_with, platform store off the async threads) only while the child's environment is built, goes to that one child only, is never an argument, is held inZeroizingmemory and is redacted from everything the runner returns. A credential shorter than 4 bytes is refused (it cannot be redacted safely). A missing credential stops the call before the program runs.sanitizeon each stream's raw bytes, converting to text last (so a character cut in half cannot turn a credential's prefix into text that no longer matches it). Every occurrence of every credential is found in the original bytes; overlapping or adjacent occurrences (one credential inside or overlapping another, or itself) are merged and replaced once by the marker. When the program was stopped at the cap, the trailing part of any credential the read stopped inside of is removed too, repeatedly (removing one can uncover another); a tail that overlaps an occurrence joins its marker, one that overlaps none is dropped. The invariant is tested exhaustively at every cut position, for ASCII, prefix-of-another, suffix-prefix overlap, self-overlap and multibyte credentials: the text holds no complete credential and, when cut, no prefix of one of four bytes or more.PATH), then the credential references (NAME from keychain:x, up to eight, then "and N more", so none is hidden silently), then the arguments. The credentials come before the arguments and the argument list alone is cut (with a marker) to fit 4 KiB, so a long argument can never push them out; a long resolved path is cut at 160 characters; an unsetPATHis said to be unset rather than reported as not found. Never a value.0700), empty directory made for the call and removed afterwards, not the shared temp directory.Offering, and what is not wired yet
The host now offers a tool whose calls need confirmation only when a confirmer is installed (so a tool is never offered that every call would refuse). The real confirmer is the confirmation step's work, so in this PR no
tool-clitool is offered and a call to one is refused as unknown (tested: not offered,UnknownTool, nothing runs, with the real runner and the real gate). With a test confirmer the runner is offered and dispatched through the host (also tested); aGETREST tool with no credential is unaffected.Remote text, logs and the system prompt
failure_reason()shows nothing for an external result; the host's own refusals still show).test:changedpasses the prompt snapshot gate).Known limits
--goes before the first model-supplied element, so the binding's own fixed arguments that follow a placeholder come after it too (["log", "{q}"]runsgit log -- main, which names paths, not a revision;["{q}", "--out", "x"]passes--outpositionally). A program that does not honour--receives a literal--. Option injection through a value is prevented only for programs that honour--(git, ssh, curl do). A binding that is itself dangerous (an interpreter run with-c) is within what its approval covers. Documented in the runner header and in nodespace-docs Add comprehensive event tests for SlashCommandDropdown component #166.After a normal exit, background processes the program left running are not stopped; processes that leave the group (
setsid) escape the group kill.The program inherits the daemon's
PATH(bare names resolve as they do for the user; a fixed safePATHwould break Homebrew and similar installs, andPATHcannot be declared by a binding), the file descriptors the platform does not mark close-on-exec, the umask and the signal mask. Another process of the same user can read the child's environment.Redaction replaces the exact value: a program that prints a transformed form (base64, URL-encoded, split across lines) is not caught. The child's environment copy of a credential is held by the process machinery and is not wiped.
--is inserted before model values; a program that does not honour--will see it as an argument.Unix process groups only for the kill-the-tree guarantee; the tests that run fake programs are
cfg(unix).A program path in the binding is resolved by the OS; a bare name is found on the daemon's
PATH.Tests
cargo clippy -D warningsclean;bun run test:changedpasses.stopcan be removed without a test noticing, because the drop guard kills the same group when the call returns. Caught include (first round): no separator; a separator before every value; environment not cleared; a leaked base variable; output not redacted; the cap boundary not covered for redaction; output buffered rather than stream-capped; the timeout not stopping the program; only the child killed; no process group; short credential accepted; non-scalar value accepted; NUL accepted; completeness not checked; failing status ignored; a tool offered without a confirmer; a remote failure reason shown; the rule in every prompt; the rule never added. (Earlier rounds led to fixes: a test where the credential arrived in one write, and an unbounded wait after a kill, now bounded.) Added in the second review round: text converted before the strip (stdout and stderr, each caught by a run-level mid-character test), the strip as a single pass, overlapping occurrences not merged, a merged span losing its marker, a tail overlapping nothing getting a marker, the last position missed, the resolved path not cut, an unset PATH reported as not found. Added in the first review round: the partial tail not stripped (stdout, stderr, or both), the cancellation guard removed, the working directory not removed, not private, or the shared temp dir, the confirmation budget ignoring the credentials, hiding the "more" count, listing every credential, not saying where a bare name resolves, and stderr not counting toward the cap. A pinned regression test is the reviewer's case: a 40-byte credential, cap 64, output = 30 filler + the credential + 20 filler + its first 14 bytes in one write. Not covered by a test: stdin being null (a program reading stdin is given none).What remains
tool-restandtool-mcprunners; the real confirmation wiring with a bounded timeout and a cap on the displayed arguments; the enable-and-approve command (with an add-if-absent key primitive);tool_whitelistdecision; fixtures.🤖 Generated with Claude Code