Undeprecate client tool APIs for SDK/platform use cases#982
Merged
threepointone merged 2 commits intomainfrom Feb 24, 2026
Merged
Undeprecate client tool APIs for SDK/platform use cases#982threepointone merged 2 commits intomainfrom
threepointone merged 2 commits intomainfrom
Conversation
Add a new examples/dynamic-tools demo (client UI, server agent, build configs, and README) demonstrating the SDK/platform pattern for dynamic client-defined tools. Update docs to document the `tools` option and show server+client usage with createToolsFromClientSchemas(). Rework packages/ai-chat to stop treating client tool schemas as deprecated: remove one-shot deprecation warnings, clarify comments/type docs to recommend server-side `tool()` for most apps while supporting dynamic client tools for SDKs/platforms, and adjust useAgentChat logic (tools handling and toolsRequiringConfirmation) accordingly. package-lock.json updated to include the new example.
🦋 Changeset detectedLatest commit: ef7e933 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
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 |
Undeprecate client tool APIs (createToolsFromClientSchemas, clientTools, AITool, extractClientToolSchemas, and the tools option on useAgentChat) to support SDK/platform use cases where tools are defined dynamically at runtime. Also fixes a spurious detectToolsRequiringConfirmation deprecation warning when using the tools option.
commit: |
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.
Motivation
Closes #981.
The client tool APIs (
createToolsFromClientSchemas,clientTools,AITool,extractClientToolSchemas, and thetoolsoption onuseAgentChat) were deprecated in favour of server-sidetool()definitions. However, this breaks legitimate use cases for SDKs and platforms where the tool surface is determined dynamically by the embedding application at runtime — the server does not know which tools exist at deploy time.The server-side
tool()pattern is the right default for most apps (full Zod type safety, simpler code), but deprecating the only mechanism for dynamic tool registration was too aggressive.What changed
Package code (
packages/ai-chat/src/)No breaking changes. No signature changes. All 218 tests pass.
index.ts@deprecatedtags fromClientToolSchema,clientToolsonOnChatMessageOptions, andcreateToolsFromClientSchemas()warnDeprecatedcallswarnDeprecatedhelper and_deprecationWarningssetreact.tsx@deprecatedtags fromAITool,ClientToolSchema,extractClientToolSchemas(), andtoolsonUseAgentChatOptionswarnDeprecatedcalls for these APIsdetectToolsRequiringConfirmationlogic insideuseAgentChatto stop emitting a spurious deprecation warning when users passtools(the non-deprecated option). The detection logic is identical — tools withoutexecuteare treated as requiring confirmation — but theconsole.warnno longer fires unless users explicitly call the deprecated function or pass the deprecatedtoolsRequiringConfirmationoption.New example (
examples/dynamic-tools/)A full-stack example demonstrating the SDK/platform pattern:
createToolsFromClientSchemas(options?.clientTools)— no tools defined at deploy timeDocs
docs/chat-agents.md— Addedtoolsoption touseAgentChatoptions table (was missing), added "Dynamic Client Tools (SDK/Platform Pattern)" subsection with code examples, linked new exampledocs/migration-to-ai-sdk-v6.md— Reframed section 3 as "server-side tools (recommended)" with a new "Dynamic client tools" subsection. Trimmed deprecated table to only actually-deprecated APIs. Added "Not deprecated" callout. Updated checklist.Cloudflare docs (separate repo, separate PR needed)
src/content/docs/agents/api-reference/chat-agents.mdxincloudflare/cloudflare-docs— RemovedcreateToolsFromClientSchemas(),extractClientToolSchemas(), andtoolsoption from deprecated table. Added "Not deprecated" note.Notes for reviewers
console.warncalls.detectToolsRequiringConfirmationinlining (react.tsx ~line 422) is the only non-trivial code change. The logic is identical to the original function, just without the deprecation warning wrapper. The original function is still exported and still deprecated for direct callers.toolsRequiringConfirmation,experimental_automaticToolResolution,addToolResult,detectToolsRequiringConfirmation— these are unchanged.ai-chatandplaygroundexamples already use the server-side pattern. The newdynamic-toolsexample is the dedicated reference for the client-defined pattern.Verification
npm run build✅npm run check✅ (44 projects typecheck, formatting clean, exports valid)npm run test✅ (24 test files, 218 tests pass)