Repository navigation
Conversation
A read-only tool set left out exec, since a command can write files. But a backend can refuse writes itself: a CodemodeBackend built with `access: "read"` runs code that can read the Workspace and not change it. An agent that may only read still wants to run code there, so a consumer had to build the full tool set and filter it by name. Module backends now say what their execs may do to the Workspace, as `access`, and `runtime.backends()` reports it for every backend, `"read-write"` for any that doesn't say. A read-only tool set keeps the file tools that read, and offers exec on the backends that report `"read"`, as listed in `exec.backends` or registered. With none, it has no exec, as before. The backend enforces the access, so the tool set stays read-only.
🦋 Changeset detectedLatest commit: 8bf026e The changes in this PR will be included in the next version bump. This PR includes changesets to release 5 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
commit: |
| /** | ||
| * Omit `write`, `edit`, `delete`, and `publish`, and offer `exec` only | ||
| * on backends that can't change the Workspace, such as a | ||
| * `CodemodeBackend` with `access: "read"`. | ||
| */ |
There was a problem hiding this comment.
🔍 Missing runnable read-only execution example
The example rules require an example update for public API changes. The changed readonly option has no runnable example; the pi agent already uses the tool factory.
Was this helpful? React with 👍 or 👎 to provide feedback.
| function canDetach(backends: ExecBackends, runtime: ExecWorkspaceLike["runtime"]): boolean { | ||
| return (runtime.backends?.() ?? []).some( | ||
| (info) => info.detachable === true && info.id in backends, | ||
| ); |
There was a problem hiding this comment.
🔍 Excluded backend can keep detach
canDetach counts an excluded detachable backend named constructor. defineExec finds no selected backend that can detach and rejects the tool set.
Was this helpful? React with 👍 or 👎 to provide feedback.
| /** | ||
| * Save output too long to show, and return values too large to show, | ||
| * to files in the Workspace, which the reply names. Defaults to | ||
| * `true`. With `false` the model sees them cut, and nothing is | ||
| * written: a read-only tool set turns it off. | ||
| */ | ||
| saveOutput?: boolean; |
There was a problem hiding this comment.
🔍 Read-only example still saves output
The RLM executor uses a read-only backend but leaves saveOutput at its default. The example does not demonstrate the new option for callers who build an exec tool directly.
Was this helpful? React with 👍 or 👎 to provide feedback.
A read-only set's exec ran on backends that can't change the Workspace, but the runtime still saved long output, and the tool large return values, to files in the Workspace from the host, past the backend's guard. The exec tool takes `saveOutput: false`, which cuts them for the model with nothing written, and says so in its description; a read-only set passes it. A read-only set also kept `exec.detach` when no backend it kept could detach, so building the set threw where it used to leave exec out. It now drops `detach` in that case. TanStack's "mutating" approval no longer gates a read-only set's exec, and the AI SDK factory's comment says when exec is offered.
f376e7f to
8bf026e
Compare
readonly: trueleavesexecout of every tool set, because a command can write files. But a backend can refuse writes itself: aCodemodeBackendbuilt withaccess: "read"runs code that reads the Workspace and can't change it, which is what Backend authority suggests for different authority levels. An agent that may only read still wants to run code on that backend, and today the only way to offer it is to build the full tool set and filter outwrite,editanddeleteby name.This lets the backend say so. Module backends get an optional
access, whichCodemodeBackendsets from itsaccessoption, andruntime.backends()reports it for every backend,"read-write"for any that doesn't say. A read-only tool set keepsread,ls,findandgrep, and offersexecon the backends that report"read", whether listed inexec.backendsor registered:With no such backend a read-only set has no
exec, as before, so shell and container backends, and a set that lists only backends that write, are unchanged. The tool set doesn't decide what's safe: it trusts the access the backend reports, and the backend enforces it.The same goes for
createAITools,createTanStackToolsandcreatePiTools, which all build fromresolveToolOptions. Most of the diff in those three is re-indenting the write tools underif (!readonly)instead of returning early; it reads better with whitespace hidden.Testing
codemode.test.tschecks thatruntime.backends()reports eachCodemodeBackend's access. The pi tests check that a read-only set offersexecwith only the read-only backend, runs on it, and has noexecwhenexec.backendsnames only backends that write. The AI SDK and TanStack tests check that a read-only set keepsexecfor a read-only backend.