Skip to content

[Agents] Draft workspaces documentation#31254

Draft
aron-cf wants to merge 4 commits into
productionfrom
agents-workspace-docs
Draft

[Agents] Draft workspaces documentation#31254
aron-cf wants to merge 4 commits into
productionfrom
agents-workspace-docs

Conversation

@aron-cf
Copy link
Copy Markdown
Contributor

@aron-cf aron-cf commented Jun 5, 2026

No description provided.

@github-actions github-actions Bot added product:agents Build and deploy AI-powered Agents on Cloudflare that can act autonomously. size/l labels Jun 5, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jun 5, 2026

This pull request requires reviews from CODEOWNERS as it changes files that match the following patterns:

Pattern Owners
/src/content/docs/agents/ @irvinebroque, @rita3ko, @elithrar, @thomasgauvin, @threepointone, @whoiskatrin, @cloudflare/product-owners, @cloudflare/ai-agents, @cloudflare/dev-plat-leads

@aron-cf aron-cf force-pushed the agents-workspace-docs branch from c66bfae to 7f59be8 Compare June 5, 2026 12:54
@ask-bonk ask-bonk Bot added documentation Documentation edits content:new Request for new/missing content labels Jun 5, 2026
Copy link
Copy Markdown
Contributor

@ask-bonk ask-bonk Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 critical issue and 13 suggestions.

  • CRITICAL src/content/docs/agents/tools/workspace.mdx:45await in constructor is invalid TypeScript.
  • HIGH src/content/docs/agents/tools/workspace.mdx:9,86,452 — Use PackageManagers component for install commands instead of bare sh fences.
  • HIGH src/content/docs/agents/tools/workspace.mdx:92,212,432WranglerConfig requires TOML input (JSON is auto-generated). Also use $today for compatibility_date.
  • HIGH src/content/docs/agents/tools/workspace.mdx:367 — Bare ts code block for a type interface; use TypeScriptExample.
  • MEDIUM src/content/docs/agents/tools/workspace.mdx:15,76,129 — Run-on sentences and typo.
  • MEDIUM src/content/docs/agents/tools/workspace.mdx:17,351 — "Coming soon" phrases trigger Semgrep warnings in CI.
  • LOW src/content/docs/agents/tools/workspace.mdx:300 — Grammar.

Note: The PR description lists many unrelated changes. Update it to describe only the workspace docs addition.

description: Give your agents a computer. Workspaces are shared between a Durable Object and a container, with built-in shell, mounts, and common filesystem tools.
---

import { Aside, LinkCard, Tabs, TabItem, TypeScriptExample, WranglerConfig } from "~/components";
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add PackageManagers to imports for install commands:

Suggested change
import { Aside, LinkCard, Tabs, TabItem, TypeScriptExample, WranglerConfig } from "~/components";
import { Aside, LinkCard, PackageManagers, Tabs, TabItem, TypeScriptExample, WranglerConfig } from "~/components";


Most work performed by an agent that requires a filesystem doesn't require a heavy Linux environment. Workspaces live inside a [Durable Object](/durable-objects/) right next to your agent harness.

Take advantage of the speed of working on files within the Worker environment and should a Linux environment be needed, you can drop into a [Cloudflare Container](/containers/) to execute bash commands, changes in either environment are reflected everywhere.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Split run-on sentence:

Suggested change
Take advantage of the speed of working on files within the Worker environment and should a Linux environment be needed, you can drop into a [Cloudflare Container](/containers/) to execute bash commands, changes in either environment are reflected everywhere.
Take advantage of the speed of working on files within the Worker environment. Should a Linux environment be needed, you can drop into a [Cloudflare Container](/containers/) to execute bash commands. Changes in either environment are reflected everywhere.


Take advantage of the speed of working on files within the Worker environment and should a Linux environment be needed, you can drop into a [Cloudflare Container](/containers/) to execute bash commands, changes in either environment are reflected everywhere.

File operations, R2 mounts and git clones within the Durable Object are all covered today, lightweight bash execution and code execution are coming soon!
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fix comma splice and avoid "coming soon" (flagged by Semgrep):

Suggested change
File operations, R2 mounts and git clones within the Durable Object are all covered today, lightweight bash execution and code execution are coming soon!
File operations, R2 mounts, and git clones within the Durable Object are all covered today. Lightweight bash execution and code execution are not yet available.

Comment on lines +44 to +46

const report = await this.#workspace.fs.readFile("/workspace/data/report.csv", "utf8");
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove await from constructor — constructors cannot be async:

Suggested change
const report = await this.#workspace.fs.readFile("/workspace/data/report.csv", "utf8");
}
}

```

1. A Durable Object constructs a `Workspace` backed by the Durable Object SQLite storage and configures a backend (currently a Cloudflare Container).
2. The backend starts the container, whose entrypoint is the a small `wsd` client. `wsd` mounts the workspace at a path inside the container using FUSE.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fix typo:

Suggested change
2. The backend starts the container, whose entrypoint is the a small `wsd` client. `wsd` mounts the workspace at a path inside the container using FUSE.
2. The backend starts the container, whose entrypoint is a small `wsd` client. `wsd` mounts the workspace at a path inside the container using FUSE.

Comment on lines +299 to +301

<Aside type="note" title="Prefer ReadableStream where possible">
Durable Objects are limited to 128MiB memory so it is preferable to avoid buffering data, particularly files into memory. All operations will default to `ReadableStream` and provide non-streaming alternatives when needed.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tighten grammar:

Suggested change
<Aside type="note" title="Prefer ReadableStream where possible">
Durable Objects are limited to 128MiB memory so it is preferable to avoid buffering data, particularly files into memory. All operations will default to `ReadableStream` and provide non-streaming alternatives when needed.
<Aside type="note" title="Prefer ReadableStream where possible">
Durable Objects are limited to 128 MiB of memory, so it is preferable to avoid buffering data — particularly files — into memory. All operations default to `ReadableStream` and provide non-streaming alternatives when needed.
</Aside>


## Shell API

`ws.shell.exec(command, options?)` spawns a command inside the container and returns an `ExecHandle` stub. Today's API is run-and-wait — call `handle.result()` to await the exit code and collected output. Streaming exec is coming soon.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Avoid "coming soon" (flagged by Semgrep):

Suggested change
`ws.shell.exec(command, options?)` spawns a command inside the container and returns an `ExecHandle` stub. Today's API is run-and-wait — call `handle.result()` to await the exit code and collected output. Streaming exec is coming soon.
`ws.shell.exec(command, options?)` spawns a command inside the container and returns an `ExecHandle` stub. Today's API is run-and-wait — call `handle.result()` to await the exit code and collected output. Streaming exec is not yet available.

Comment on lines +365 to +373
### `ExecResult`

```ts
interface WorkspaceExecResult<E extends "utf8" | undefined> {
exitCode: number;
stdout: E extends "utf8" ? string : Uint8Array;
stderr: E extends "utf8" ? string : Uint8Array;
}
```
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wrap interface in TypeScriptExample:

Suggested change
### `ExecResult`
```ts
interface WorkspaceExecResult<E extends "utf8" | undefined> {
exitCode: number;
stdout: E extends "utf8" ? string : Uint8Array;
stderr: E extends "utf8" ? string : Uint8Array;
}
```
<TypeScriptExample>
```ts
interface WorkspaceExecResult<E extends "utf8" | undefined> {
exitCode: number;
stdout: E extends "utf8" ? string : Uint8Array;
stderr: E extends "utf8" ? string : Uint8Array;
}
</TypeScriptExample>

Comment on lines +432 to +443
<WranglerConfig>

```jsonc
{
"r2_buckets": [
{ "binding": "Bucket", "bucket_name": "my-agent-data" },
{ "binding": "Skills", "bucket_name": "my-agent-skills" },
],
}
```

</WranglerConfig>
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use TOML input for WranglerConfig:

Suggested change
<WranglerConfig>
```jsonc
{
"r2_buckets": [
{ "binding": "Bucket", "bucket_name": "my-agent-data" },
{ "binding": "Skills", "bucket_name": "my-agent-skills" },
],
}
```
</WranglerConfig>
<WranglerConfig>
```toml
[[r2_buckets]]
binding = "Bucket"
bucket_name = "my-agent-data"
[[r2_buckets]]
binding = "Skills"
bucket_name = "my-agent-skills"
```

Comment on lines +450 to +452

```sh
npm install isomorphic-git diff
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use PackageManagers for install commands:

Suggested change
```sh
npm install isomorphic-git diff
<PackageManagers pkg="isomorphic-git diff" />

@ask-bonk
Copy link
Copy Markdown
Contributor

ask-bonk Bot commented Jun 5, 2026

Applied labels documentation, content:new, and product:agents.

Posted a review with 14 inline comments on PR #31254:

  • CRITICAL: await inside a constructor (invalid TypeScript)
  • HIGH: Three WranglerConfig blocks using JSONC instead of TOML, plus hardcoded compatibility_date
  • HIGH: Missing PackageManagers component for two install commands
  • HIGH: Bare ts code block instead of TypeScriptExample
  • MEDIUM: Grammar/run-on sentences, "coming soon" phrases (Semgrep warnings)
  • LOW: Aside grammar

Also flagged that the PR description lists many unrelated changes instead of describing the workspace docs addition.

github run

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jun 5, 2026

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

content:new Request for new/missing content documentation Documentation edits product:agents Build and deploy AI-powered Agents on Cloudflare that can act autonomously. size/l

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants