computer: Carry backend information through Workspace clients - #182
Merged
Merged
Conversation
A WorkspaceClient from getWorkspace() wrapped the runtime with exec,
getExec, killExec, and disposeExec only. The exec tool also asks the
runtime for backendIds, isCallable, and describe, so a client lost all
three: with exec omitted it offered no exec tool, and a callable
backend lost its input argument and its module list. Over RPC those
calls would be asynchronous, while the tool builds its schema
synchronously.
Backends are fixed when the Workspace is constructed, so the runtime
and its RPC stub now expose one backends() call, and a client takes
that snapshot when it is created and answers the three questions from
it, locally and remotely alike.
CloudflareContainerBackend now describes network access from its
egress setting instead of always claiming it, exec takes precedence
over the deprecated shell option so exec: {} always means no tool, and
the mcp README and think prompt stop implying a default backend.
馃 Changeset detectedLatest commit: 6511ce7 The changes in this PR will be included in the next version bump. This PR includes changesets to release 4 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: |
The exec tool learned about backends through three runtime methods, backendIds, isCallable, and describe, and every way of reaching a Workspace had to forward all three. It now reads one list from runtime.backends(), each entry carrying the id, whether the backend is callable, and its description. backendIds and describe are gone, and a Workspace client exposes the same backends() from its snapshot. isCallable stays on the runtime for its own check before running.
A client returned its backend snapshot array itself, so a caller that edited it changed what later tool sets saw. The snapshot is now frozen once when the client is created. The client tests only checked that the exec schema offered input. They now send structured input through the exec tool on a local and a remote client to a callable backend that echoes it, and check the value comes back as the result. The mcp README no longer calls worker-shell the default.
mattzcarey
added a commit
that referenced
this pull request
Oct 1, 2026
* computer: Carry backend information through Workspace clients
A WorkspaceClient from getWorkspace() wrapped the runtime with exec,
getExec, killExec, and disposeExec only. The exec tool also asks the
runtime for backendIds, isCallable, and describe, so a client lost all
three: with exec omitted it offered no exec tool, and a callable
backend lost its input argument and its module list. Over RPC those
calls would be asynchronous, while the tool builds its schema
synchronously.
Backends are fixed when the Workspace is constructed, so the runtime
and its RPC stub now expose one backends() call, and a client takes
that snapshot when it is created and answers the three questions from
it, locally and remotely alike.
CloudflareContainerBackend now describes network access from its
egress setting instead of always claiming it, exec takes precedence
over the deprecated shell option so exec: {} always means no tool, and
the mcp README and think prompt stop implying a default backend.
* computer: Answer backend questions with one backends() call
The exec tool learned about backends through three runtime methods,
backendIds, isCallable, and describe, and every way of reaching a
Workspace had to forward all three. It now reads one list from
runtime.backends(), each entry carrying the id, whether the backend is
callable, and its description. backendIds and describe are gone, and
a Workspace client exposes the same backends() from its snapshot.
isCallable stays on the runtime for its own check before running.
* computer: Freeze the client backend snapshot and test input through it
A client returned its backend snapshot array itself, so a caller that
edited it changed what later tool sets saw. The snapshot is now frozen
once when the client is created.
The client tests only checked that the exec schema offered input. They
now send structured input through the exec tool on a local and a
remote client to a callable backend that echoes it, and check the
value comes back as the result. The mcp README no longer calls
worker-shell the default.
mattzcarey
added a commit
that referenced
this pull request
Oct 1, 2026
Split each tool into a framework-neutral core under tools/common (schema, description, executor; zod only) and an adapter per agent library. tools/ai-sdk wraps the core with `tool()` from `ai`; tools/pi-ai and tools/tanstack-ai build their own shapes from the same core without importing their libraries, so each entry point pulls in only what it uses. The exec core is the one #181 and #182 settled on: `exec` takes a backend map, every Workspace backend is offered by default, `backend` appears only when there is a choice, and `input` only when a backend is callable. All three tool sets resolve options through the same resolveToolOptions, so they offer the same tools. The pi and TanStack adapters come from #149. Co-authored-by: aron <263346377+aron-cf@users.noreply.github.com>
This was referenced Oct 1, 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.
Stacked on #172, after #181 merged into it.
This fixes the issues review found in #181.
A
WorkspaceClientfromgetWorkspace()wrapped the runtime withexec,getExec,killExec, anddisposeExeconly. Theexectool also asks the runtime forbackendIds,isCallable, anddescribe, so a client lost all three. Withexecleft out, an agent got no exec tool, and a callable backend such ascelld's lost itsinputargument and its module list:A Durable Object that builds its own
Workspacepasses it straight tocreateAIToolsand was never affected. The bug hit the two cases that go throughgetWorkspace():The tool needs one list of facts per backend, so this PR also collapses those three methods into one:
The
Workspaceruntime, its RPC stub, the client, and the tool all speak that one method.backendIdsanddescribeare gone.isCallablestays on the runtime only for its own check before running.Backends are fixed when the Workspace is constructed, so a client takes one
backends()snapshot whengetWorkspace()creates it:sequenceDiagram participant Agent participant Client as WorkspaceClient participant Stub as WorkspaceRuntimeStub (RPC) Agent->>Client: getWorkspace(handle) Client->>Stub: backends() Stub-->>Client: [{ id, callable, description }] Agent->>Client: createAITools({ workspace }) Client-->>Agent: backends(), answered from the snapshotThe snapshot keeps
createAIToolssynchronous over RPC, where the call would otherwise be a round trip.Three smaller fixes:
CloudflareContainerBackendclaimed network access even with the defaultegress: { mode: "none" }. Its description now follows the egress mode: direct, through a gateway, or none.execnow takes precedence over the deprecatedshelloption, soexec: {}always means no exec tool.mcpREADME describedbackendas optional, and thethinkprompt named a default backend. Both now say to name a backend on every call.client.test.tsbuilds tools from both a local and a remote client against a realWorkerJavaScriptBackend, checks the backend answers and the module list, and sends structuredinputthrough each client's exec tool to a callable backend that echoes it. The snapshot is frozen, so editing the list a client returns cannot change later answers. The other fixes each have a focused test.