Skip to content

codemode: client-side tool calls via durable pause/resolve#1905

Draft
mattzcarey wants to merge 2 commits into
mainfrom
feat/codemode-client-side-tools
Draft

codemode: client-side tool calls via durable pause/resolve#1905
mattzcarey wants to merge 2 commits into
mainfrom
feat/codemode-client-side-tools

Conversation

@mattzcarey

Copy link
Copy Markdown
Contributor

Closes #1735.

Lets generated code call client-side (execute-less) tools by generalizing the durable approval machinery into value-carrying resolution: a client tool call pauses the run as a pending log entry marked resolution: "client"; the client supplies the result via a new resolve(), which records it as applied and resumes via the existing replay — so the model just writes const tz = await tools.getUserTimezone({}) and the run durably parks until the client answers.

What changed

  • ToolAnnotations.resolution?: "approval" | "client" — both imply a pause; approval stays the default for gated calls. Carried through ToolLogEntry and PendingAction so approval UIs can distinguish "approve/deny" from "compute and return".
  • CodemodeRuntime.resolve(executionId, seq, result) — mirrors reject(): only a pending entry on a paused run; stores the client result (same size guard) and flips it to applied. decide() will never execute a client-pending entry server-side — approve() on such a run just re-pauses; once resolved, ordinary replay serves the value with the usual divergence check.
  • resolveCodemode() / handle.resolve({executionId, seq, result}) — records the result then reuses the resume path; stale/duplicate resolves return an error outcome, not a throw.
  • ToolSetConnector opt-in clientTools: "pause" (default "skip" preserves today's skip-and-warn): execute-less tools are exposed in the sandbox + getTypeScriptTypes(), annotated client-resolved, with a throwing server-side execute as a safety net.
  • e2e + toolset tests; patch changeset.

Notes / deferred

  • Client-supplied results are trusted (no output-schema validation yet) — follow-up.
  • expirePaused already covers a client that never answers.
  • No changes to the agents chat client; apps wire this like approvals (e.g. a @callable resolveExecution on the agent), reusing the existing onToolCall-style handler.

Draft — API surface up for discussion.

@changeset-bot

changeset-bot Bot commented Jul 9, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: ef24456

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

This PR includes changesets to release 1 package
Name Type
@cloudflare/codemode 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 Jul 9, 2026

Copy link
Copy Markdown

Open in StackBlitz

agents

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

@cloudflare/ai-chat

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

@cloudflare/codemode

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

create-think

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

hono-agents

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

@cloudflare/shell

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

@cloudflare/think

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

@cloudflare/voice

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

@cloudflare/worker-bundler

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

commit: ef24456

@mattzcarey mattzcarey force-pushed the feat/codemode-client-side-tools branch from 7daa1af to ef24456 Compare July 9, 2026 16:36
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.

[Discussion] Client-side tools inside the codemode execute sandbox

1 participant