feat(think): make platform tools native to code#1947
Open
mattzcarey wants to merge 8 commits into
Open
Conversation
🦋 Changeset detectedLatest commit: 44e1c31 The changes in this PR will be included in the next version bump. This PR includes changesets to release 5 packages
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 |
agents
@cloudflare/ai-chat
@cloudflare/codemode
create-think
hono-agents
@cloudflare/shell
@cloudflare/think
@cloudflare/voice
@cloudflare/worker-bundler
commit: |
mattzcarey
force-pushed
the
feat/think-codemode-bash
branch
from
July 15, 2026 16:01
120efd8 to
6fac110
Compare
mattzcarey
marked this pull request as ready for review
July 17, 2026 10:23
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
codetool a durable Code Mode runtime while keepingread,write,edit, andcodeas the four built-in model toolscodeasworkspace.*,context.*,skills.*,extensions.*,fetch.*, and one namespace per connected MCP servermcp.getAITools()while assembling a turnMCPClientManager.getAITools()conversion by live connection, server id, and catalog revision, without scattered invalidation branchesbash, customcode, orcreateExecuteTool(this)setreadonly codeTool = falseexamples/think-codemode-mcpappWhy
Issue #1938 reproduces with a 313-tool MCP server. A normal Think turn currently calls
getAITools()beforeactiveToolsfiltering, recursively converting 626 input/output JSON Schemas into Zod graphs even when the application intends to use MCP only through Code Mode.The regression registers 313 complex MCP tools, replaces
getAITools()with a throwing/counting trap, and completes this flow through the real Durable Object transport and Dynamic Worker runtime:codemode.search()findscatalog.echocodemode.describe()generates its types on demandcatalog.echo()executes over MCP RPCgetAITools()is called zero timesA separate MCP manager regression verifies that filtered and unfiltered
getAITools()calls share converted schemas. Replacing the connection, changing its id, or replacing its catalog causes conversion exactly once for the new revision.Compatibility boundary
This is a pre-1.0 minor change for
@cloudflare/think:codeand accepts{ code: string }; it does not accept POSIX shell syntax or the legacy{ script, cwd }payloadreadonly codeTool = falseopts out of the built-in runtime and restores the direct workspace, context, skills, extensions, and fetch layoutbash, customcode, andcreateExecuteTool(this)do not opt out implicitly; Think rejects competing runtime owners with an actionable errorworkspaceBashconfiguration moves tocodeToolor an explicitcreateWorkspaceTools()tool setgetTools(), Think actions, and client tools remain direct because they have separate lifecycle and approval semanticsworker_loaders: [{ binding: "LOADER" }]; generated Think config includes it, and custom Worker entries exportCodemodeRuntimethrough@cloudflare/think/server-entrycreateWorkspaceTools().bashremains a realjust-bashPOSIX shellStructural audit
WeakMapkeyed by the live connectionThink;codeToolis the sole ownership policy@cloudflare/shelland deleted Think's duplicate adapter moduleVerification
pnpm run build: all 26 targets passedpnpm run check: exports, formatting, lint, and all 118 TypeScript projects passedpnpm exec nx affected -t test --base=origin/main: all 19 affected projects passedagent-think: 37 tests passedFixes #1938