Skip to content

Add Think runtime comparison example - #3

Merged
ghostwriternr merged 5 commits into
mainfrom
examples/think-runtime-comparison
Jun 12, 2026
Merged

Add Think runtime comparison example#3
ghostwriternr merged 5 commits into
mainfrom
examples/think-runtime-comparison

Conversation

@ghostwriternr

@ghostwriternr ghostwriternr commented Jun 12, 2026

Copy link
Copy Markdown
Member

Adds examples/think-compare-runtimes, a side-by-side demo that runs the same Think agent against @cloudflare/workspace and @cloudflare/sandbox from a single seeded fixture. The goal is to make the runtime difference visible: Workspace gives the agent durable files immediately and only escalates to a container when a command needs a real runtime; Sandbox runs every file and exec call inside a container session. The app is a Worker plus a React client, with a CompareRun durable object coordinating both agents and streaming events to the browser over PartyServer.

Two cross-package changes ride along because the example needs them. The build script for @cloudflare/workspace-rpc now builds @cloudflare/dofs first, and @cloudflare/workspace builds @cloudflare/workspace-rpc first, so a clean checkout can build the example without pre-existing dist directories. The container backend grows a fetchPort helper on IWorkspaceContainerAPI so cross-durable-object container fetches go through the durable object that owns ctx.container instead of relying on a Fetcher stub that does not survive the durable object boundary.

To verify locally, install dependencies, then run npm run dev --workspace @cloudflare/example-think-compare-runtimes and open the dev URL printed by Vite. Click START RUN and watch both runtimes execute the same docs task. The example has its own test suite — npm test --workspace @cloudflare/example-think-compare-runtimes covers the worker, agent harness, fixture, dashboard model, and UI panels.

Direct package builds depend on generated output from upstream
workspace packages. Build dofs before workspace-rpc, and build
workspace-rpc before workspace, so fresh checkouts can run package
builds without relying on stale dist directories.
Add a Think-vs-Think example that compares Workspace and Sandbox
against the same docs task. The Workspace side uses durable file
operations, a worker-shell backend for lightweight commands, and a
container backend for real Linux tooling. The Sandbox side uses the
Sandbox SDK session for files and exec.

The example streams run events over PartyServer and renders a compact
runtime dashboard so the difference between direct file work, shell
commands, and container work is visible during a run.
Centralize run event interpretation so telemetry, routing, and evidence use the same parsed model. This keeps JSON detail parsing and runtime matching out of the React components and removes the older lane split.

Split the comparison shell into focused render modules and record explicit execution targets for Workspace and Sandbox commands. The UI can show routing behavior without leaking optional backend fields through generic command results.
Rework the comparison example around a compact substrate timeline and an agent activity stream that groups reasoning, file work, and command output by intent. The run control can now discard an active run and ask the backing Think agents to cancel their in-flight chats.

Record container assignment lifecycle events so the timeline can show when a run holds a container separately from command execution. Route Workspace container fetches through the owning Durable Object so local and deployed runs use the same container boundary.
Tell the comparison agents that the fixture files already exist before a run starts. The prompt now treats tool results as the source of truth and asks agents to report visibility mismatches instead of creating replacement project scaffolding.
@ghostwriternr
ghostwriternr marked this pull request as ready for review June 12, 2026 10:22
@ghostwriternr
ghostwriternr merged commit 245482b into main Jun 12, 2026
9 checks passed
@ghostwriternr
ghostwriternr deleted the examples/think-runtime-comparison branch June 12, 2026 10:22
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