Repository navigation
[Agents] Think works in a @cloudflare/computer Workspace - #34297
mattzcarey wants to merge 5 commits into
Conversation
|
|
||
| ## Migrate your workspace data | ||
|
|
||
| This is a breaking change. Computer stores files in different tables from Shell, and nothing moves your data automatically. To keep an existing workspace, copy its files with the script in [Migrating from `@cloudflare/shell` to `@cloudflare/computer`](https://github.com/cloudflare/agents/blob/main/docs/shell/migrating-to-computer.md). If you do not, your agent starts with an empty workspace. |
There was a problem hiding this comment.
| This is a breaking change. Computer stores files in different tables from Shell, and nothing moves your data automatically. To keep an existing workspace, copy its files with the script in [Migrating from `@cloudflare/shell` to `@cloudflare/computer`](https://github.com/cloudflare/agents/blob/main/docs/shell/migrating-to-computer.md). If you do not, your agent starts with an empty workspace. | |
| This is a breaking change. Computer stores files in different tables from Shell, and there is no automatic data migration between workspace formats. To keep an existing workspace, copy its files with the script in [Migrating from `@cloudflare/shell` to `@cloudflare/computer`](https://github.com/cloudflare/agents/blob/main/docs/shell/migrating-to-computer.md). If you do not, your agent starts with an empty workspace. |
| - Streams responses to a React chat UI | ||
| - Has persistent memory the model can read and write | ||
| - Includes workspace file tools (read, write, edit, find, grep, delete) | ||
| - Includes workspace file tools (read, ls, find, grep, write, edit, delete) |
There was a problem hiding this comment.
| - Includes workspace file tools (read, ls, find, grep, write, edit, delete) | |
| - Includes workspace file tools (read, ls, find, grep, write, edit, delete) from @cloudflare/computer |
🚀 Deploying Preview to Cloudflare 🚀Preview URL: https://agents-computer-workspace-changelog.previews.developers.cloudflare.com (commit 0e02e1b)This URL reflects your latest Preview deploymentPreview Deployments by commit
|
| @@ -581,7 +581,7 @@ The browser agent example uses the legacy tools. It covers Browser Run setup, to | |||
|
|
|||
| ### Think execute tool | |||
There was a problem hiding this comment.
should we remove this section
There was a problem hiding this comment.
Yes, removed in 5d5b441. It only documented the deprecated execute tool, and the Think tools page already covers that with a deprecation notice. Nothing linked to the section.
aron-cf
left a comment
There was a problem hiding this comment.
This looks great. Some comments inline. I need to get on those workspace docs.
| @@ -0,0 +1,39 @@ | |||
| --- | |||
| title: Think agents now use a @cloudflare/computer Workspace | |||
| description: Think and Agent Skills now work in a Workspace from @cloudflare/computer. @cloudflare/shell is deprecated. | |||
There was a problem hiding this comment.
| description: Think and Agent Skills now work in a Workspace from @cloudflare/computer. @cloudflare/shell is deprecated. | |
| description: @cloudflare/computer now provides the Think filesystem and execution environment. @cloudflare/shell is deprecated. |
| @@ -0,0 +1,39 @@ | |||
| --- | |||
| title: Think agents now use a @cloudflare/computer Workspace | |||
There was a problem hiding this comment.
Too much?
| title: Think agents now use a @cloudflare/computer Workspace | |
| title: Giving Think a computer |
|
|
||
| import { TypeScriptExample } from "~/components"; | ||
|
|
||
| [Think](/agents/harnesses/think/) and [Agent Skills](/agents/runtime/execution/agent-skills/) now work in a `Workspace` from [`@cloudflare/computer`](https://github.com/cloudflare/computer). Think's built-in workspace tools are now Computer's tools. Add an execution backend to the Workspace and the model gets an `exec` tool. |
There was a problem hiding this comment.
| [Think](/agents/harnesses/think/) and [Agent Skills](/agents/runtime/execution/agent-skills/) now work in a `Workspace` from [`@cloudflare/computer`](https://github.com/cloudflare/computer). Think's built-in workspace tools are now Computer's tools. Add an execution backend to the Workspace and the model gets an `exec` tool. | |
| [Think](/agents/harnesses/think/) and [Agent Skills](/agents/runtime/execution/agent-skills/) are now backed by [`@cloudflare/computer`](https://github.com/cloudflare/computer), providing the file system, execution environment and toolset, `read`, `write`, `find`, `glob`, `exec`. |
|
|
||
| [Think](/agents/harnesses/think/) and [Agent Skills](/agents/runtime/execution/agent-skills/) now work in a `Workspace` from [`@cloudflare/computer`](https://github.com/cloudflare/computer). Think's built-in workspace tools are now Computer's tools. Add an execution backend to the Workspace and the model gets an `exec` tool. | ||
|
|
||
| `@cloudflare/shell` is deprecated, and so is Think's `createExecuteTool`. |
There was a problem hiding this comment.
Move this below the example to tie it in with the migration information. What's the maintainance status and timeline until it's unsupported?
| | `edit` | Apply exact text replacements to a file, falling back to whitespace-tolerant search | | ||
| | `delete` | Delete a file or directory | | ||
| | `exec` | Run a command or module on one of the Workspace's execution backends | | ||
| | `publish` | Share a workspace file through a presigned URL, when the Workspace has assets | |
There was a problem hiding this comment.
do we want to add git and artifacts? Or leave them private?
|
|
||
| </WranglerConfig> | ||
|
|
||
| Computer also ships a `just-bash` shell backend that runs in Dynamic Workers, and a container backend with a full Linux userland. Refer to the [Computer README](https://github.com/cloudflare/computer/tree/main/packages/computer#choosing-a-backend) for each backend's bindings. |
There was a problem hiding this comment.
| Computer also ships a `just-bash` shell backend that runs in Dynamic Workers, and a container backend with a full Linux userland. Refer to the [Computer README](https://github.com/cloudflare/computer/tree/main/packages/computer#choosing-a-backend) for each backend's bindings. | |
| Computer also ships a container backend to provide a Linux shell and a `just-bash` backend that runs in Dynamic Workers, these are both still experimental. Refer to the [Computer README](https://github.com/cloudflare/computer/tree/main/packages/computer#choosing-a-backend) for each backend's bindings. |
| ### Call the agent's tools from code | ||
|
|
||
| By default, the workspace stores everything in SQLite. For large files, override `workspace` to add R2 spillover: | ||
| Give a JavaScript backend a `ws:tools` module, and code the model runs with `exec` can import the agent's tools. Code reads files through `node:fs/promises`, so serve `getTools()` rather than the workspace tools: |
There was a problem hiding this comment.
| Give a JavaScript backend a `ws:tools` module, and code the model runs with `exec` can import the agent's tools. Code reads files through `node:fs/promises`, so serve `getTools()` rather than the workspace tools: | |
| The file-system can always be accessed via `node:fs/promises` but additional tools can be provided to the `WorkerJavaScriptBackend` using `createToolBindings` to make the registered tools accessible to the JavaScript environment through the `ws:tools` module: |
| ``` | ||
|
|
||
| </TypeScriptExample> | ||
| `ws:tools` does not export tools that need approval or tools that run in the browser, because nothing can approve or run them from code. Calls from code do not go through `beforeToolCall`. Refer to [`ws:tools`](https://github.com/cloudflare/computer/blob/main/docs/17_isolate_javascript.md#wstools) for how calls and results work. |
There was a problem hiding this comment.
Need those workspace docs before we ship this.
| ### Change the tools | ||
|
|
||
| <WranglerConfig> | ||
| `exec` offers every backend the Workspace has, and each backend describes itself to the model. To change a built-in tool, return a tool with the same name from `getTools()`. It replaces the built-in. To hide tools for a turn, return `activeTools` from `beforeTurn`. |
There was a problem hiding this comment.
| `exec` offers every backend the Workspace has, and each backend describes itself to the model. To change a built-in tool, return a tool with the same name from `getTools()`. It replaces the built-in. To hide tools for a turn, return `activeTools` from `beforeTurn`. | |
| To change a built-in tool, return a tool with the same name from `getTools()`. It replaces the built-in. To hide tools for a turn, return `activeTools` from `beforeTurn`. |
| bucket_name = "agent-files" | ||
| ### Share a workspace | ||
|
|
||
| To work in a Workspace another Durable Object owns, wrap `getWorkspace` in `lazyWorkspace`. Think contacts the owner only when a turn first touches a file: |
There was a problem hiding this comment.
I think we need to revisit this API...
| To work in a Workspace another Durable Object owns, wrap `getWorkspace` in `lazyWorkspace`. Think contacts the owner only when a turn first touches a file: | |
| To access a Workspace efficiently from another worker via RPC wrap `getWorkspace` in `lazyWorkspace`: |
Typically, changelog entries should be dated the day they merge. This is not blocking — if the date is unintentional, please update it. |
- Cover the Think, AI SDK, Pi, and OpenCode harnesses, with a note pointing to each and typed adapters for Pi Durable and OpenCode. - Update the Think guidance for the Computer workspace that Think now includes (PR #34297): no useThink, workspaceBash, or createAITools(). - Add an API reference for Workspace, workspace.fs, workspace.runtime, the tool functions, and the host modules, and link to it. - Link the Worker Loader binding to /dynamic-workers/ directly, which fixes the nimbus/internal-link redirect error. - Fix the description, the "accesing" and "it's" typos, and wording.
* docs(agents): add File system page under Tools Add /agents/tools/filesystem/, placed above Sandbox in the Tools sidebar. It covers adding a Cloudflare Computer workspace to a Durable Object, giving a model the workspace file tools with createAITools(), and optionally running JavaScript with WorkerJavaScriptBackend. * Apply batched suggestions from code review Co-authored-by: Aron <263346377+aron-cf@users.noreply.github.com> * docs(agents): address review feedback on File system page - Cover the Think, AI SDK, Pi, and OpenCode harnesses, with a note pointing to each and typed adapters for Pi Durable and OpenCode. - Update the Think guidance for the Computer workspace that Think now includes (PR cloudflare#34297): no useThink, workspaceBash, or createAITools(). - Add an API reference for Workspace, workspace.fs, workspace.runtime, the tool functions, and the host modules, and link to it. - Link the Worker Loader binding to /dynamic-workers/ directly, which fixes the nimbus/internal-link redirect error. - Fix the description, the "accesing" and "it's" typos, and wording.
Adds a changelog entry for Think moving to a
@cloudflare/computerWorkspace, and updates the Think docs to match. The Think tools page now covers Computer's workspace tools,execbackends,ws:tools,lazyWorkspace, and upgrading from Shell. The getting started, configuration, Agent Skills, Code Mode AI SDK and browser pages no longer use@cloudflare/shell.This ships in cloudflare/agents #2559 to #2565:
@cloudflare/shellis deprecated, and Computer's tools replace Think's built-in tools (workspaceBash,createWorkspaceToolsand@cloudflare/think/tools/workspaceare removed, with no new config property; the Workspace backends decideexec)createExecuteToolis deprecated in favour ofexecwithws:toolsMerge this when cloudflare/agents #2559 to #2565 are released. Update the changelog date to the release day, and check that the migration guide link resolves on
main.pnpm run checkandpnpm run buildpass. I checked the new anchors on the Think tools page in the build output.