Skip to content

think: Use Computer as the default workspace - #2074

Draft
aron-cf wants to merge 5 commits into
think-computer/01-legacy-workspacefrom
think-computer/02-computer-default
Draft

think: Use Computer as the default workspace#2074
aron-cf wants to merge 5 commits into
think-computer/01-legacy-workspacefrom
think-computer/02-computer-default

Conversation

@aron-cf

@aron-cf aron-cf commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

This PR introduces @cloudflare/computer as a dependency and makes its backend-free Workspace the default.

Think continues to use its own fs and runtime contract for now, so custom and shared workspaces do not need to extend a concrete Computer class. The legacy @cloudflare/shell-based workspace remains available through @cloudflare/think/workspace-shell-legacy.

The default workspace requires no additional configuration:

import { Think } from "@cloudflare/think";

export class MyAgent extends Think<Env> {
  getModel() {
    // ...
  }
}

Agent methods can access Computer’s filesystem through workspace.fs:

await this.workspace.fs.mkdir("/notes", { recursive: true });
await this.workspace.fs.writeFile("/notes/today.md", "# Today\n");

const content = await this.workspace.fs.readFile(
  "/notes/today.md",
  "utf8"
);

The codemode interface uses Computer’s file tools directly under workspace.*. It exposes read, list, write, and edit, renaming Computer’s ls tool to list. Read-only tools are re-executed after a durable resume, while mutations remain in the replay log.

createExecuteTool(this) automatically exposes the selected Computer workspace:

import { Think } from "@cloudflare/think";
import { createExecuteTool } from "@cloudflare/think/tools/execute";

export class MyAgent extends Think<Env> {
  getModel() {
    // ...
  }

  getTools() {
    return {
      execute: createExecuteTool(this)
    };
  }
}

Generated codemode programs can then work with the durable filesystem:

async () => {
  await workspace.write({
    path: "/notes/today.md",
    content: "# Today\n\n- Review the workspace migration\n"
  });

  await workspace.edit({
    path: "/notes/today.md",
    edits: [
      {
        oldText: "- Review the workspace migration",
        newText: "- Finish the workspace migration"
      }
    ]
  });

  const file = await workspace.read({
    path: "/notes/today.md"
  });

  const directory = await workspace.list({
    path: "/notes"
  });

  return {
    content: file.content,
    entries: directory.entries
  };
}

The backend-free workspace does not expose workspace.exec or workspace.bash. Code outside the createExecuteTool(this) convenience path can pass a Computer-shaped workspace explicitly:

const execute = createExecuteTool({
  ctx: this.ctx,
  workspace: this.workspace,
  loader: this.env.LOADER
});

Legacy workspaces continue to provide their richer state.* connector. Agents that need existing Shell storage, R2 data, snapshot-based Bash, or the legacy codemode interface can select it explicitly:

import { Think } from "@cloudflare/think";
import { Workspace } from "@cloudflare/think/workspace-shell-legacy";

export class ExistingAgent extends Think<Env> {
  override workspace = new Workspace({
    sql: this.ctx.storage.sql,
    name: () => this.name
  });

  getModel() {
    // ...
  }
}

This intentionally keeps Computer tools under workspace.* and the richer legacy interface under state.*. Whether those interfaces should converge can be evaluated separately.

A following pull request adds the opt-in Computer Worker Shell backend and exposes command execution as bash.

@changeset-bot

changeset-bot Bot commented Aug 7, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 97e9eee

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
@cloudflare/think Minor
@cloudflare/agent-think Patch

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

@pkg-pr-new

pkg-pr-new Bot commented Aug 7, 2026

Copy link
Copy Markdown

Open in StackBlitz

agents

npm i https://pkg.pr.new/agents@2074

@cloudflare/ai-chat

npm i https://pkg.pr.new/@cloudflare/ai-chat@2074

@cloudflare/codemode

npm i https://pkg.pr.new/@cloudflare/codemode@2074

create-think

npm i https://pkg.pr.new/create-think@2074

hono-agents

npm i https://pkg.pr.new/hono-agents@2074

@cloudflare/shell

npm i https://pkg.pr.new/@cloudflare/shell@2074

@cloudflare/think

npm i https://pkg.pr.new/@cloudflare/think@2074

@cloudflare/voice

npm i https://pkg.pr.new/@cloudflare/voice@2074

@cloudflare/worker-bundler

npm i https://pkg.pr.new/@cloudflare/worker-bundler@2074

commit: b2ef8ed

@aron added 5 commits August 11, 2026 15:24
Introduce @cloudflare/computer behind the opt-in workspace entrypoint. Turn tools, skill runners, and codemode keep their existing interfaces while using the provider's fs surface.
Use a reproducible package tarball built from cloudflare/computer commit 5bac080 until the corresponding npm release is available.
Replace the temporary package built from Computer main with the published 0.2.0 release.
@aron-cf
aron-cf force-pushed the think-computer/02-computer-default branch from b2ef8ed to 97e9eee Compare August 11, 2026 17:15
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