-
Notifications
You must be signed in to change notification settings - Fork 20
feat: add provider-agnostic tool_web_search() and tool_web_fetch()
#248
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Conversation
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
16639ff to
96f4bd2
Compare
cpsievert
commented
Dec 31, 2025
29fb577 to
405ec43
Compare
Add built-in web search and URL fetch tools that work across providers: - tool_web_search(): Works with OpenAI, Anthropic, and Google - tool_web_fetch(): Works with Anthropic and Google Each provider automatically translates the tool configuration to its specific API format. Supports options like allowed_domains, blocked_domains, user_location, and max_uses where applicable. This is equivalent to tidyverse/ellmer#829 but with a cleaner provider-agnostic API (one function instead of separate functions per provider). 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <[email protected]>
GoogleSearch and UrlContext must be passed as keyword arguments to GoogleTool(), not directly to config.tools. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <[email protected]>
- Add _warn_unsupported() helper to reduce warning code duplication - Update examples to use generic domains (wikipedia.org, python.org) instead of Posit/Tidyverse-specific ones 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <[email protected]>
Add ContentWebSearchRequest, ContentWebSearchResults, ContentWebFetchRequest, and ContentWebFetchResults to represent built-in web tool interactions. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <[email protected]>
- Anthropic: Handle server_tool_use, web_search_tool_result, and web_fetch_tool_result content types - OpenAI: Handle web_search_call output type 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <[email protected]>
Handle citations_delta chunk type during streaming to accumulate citations on content blocks. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <[email protected]>
Update tool_web_fetch docstring to explain that Claude requires the anthropic-beta: web-fetch-2025-09-10 header. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <[email protected]>
Document the new tool_web_search() and tool_web_fetch() functions and associated content types. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <[email protected]>
- Add new "Built-in tools" section with tool_web_search and tool_web_fetch - Export new content types from chatlas.types module 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <[email protected]>
🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <[email protected]>
- Add Quick start section with MCP Fetch server example - Add Finding MCP servers section with awesome-mcp-servers link - Reorder to show Stdio before HTTP (more common for 3rd party) - Move "Building your own server" section later - Rename "Motivating example" to "Advanced example: Code execution" - Add callout linking to built-in tool_web_fetch/tool_web_search alternatives - Update tools.qmd link to point to quick start section 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <[email protected]>
The MCP Fetch server is run via `uvx mcp-server-fetch`, not npx. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <[email protected]>
OpenAI's function calling API doesn't support the "format": "uri" JSON Schema format used by the MCP Fetch server. Switch examples to use ChatAnthropic which has better MCP compatibility. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <[email protected]>
OpenAI's function calling API doesn't support JSON Schema format hints like "uri" or "date-time". Strip these from MCP tool schemas so they work across all providers. Also reverts docs to use ChatOpenAI for MCP Fetch examples since the fix enables cross-provider compatibility. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <[email protected]>
OpenAI requires all properties to be listed in the required array. Update sanitize_schema to add all property keys to required. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <[email protected]>
OpenAI requires all properties in the required array with strict mode. Optional parameters are indicated using anyOf with null type, matching how pydantic_function_tool generates schemas. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <[email protected]>
MCP tools use standard JSON Schema conventions where optional params are simply not in the required array. Setting strict=False for OpenAI allows this to work properly, so the LLM won't be forced to provide values for all parameters. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <[email protected]>
405ec43 to
9b39472
Compare
cpsievert
commented
Jan 2, 2026
cpsievert
commented
Jan 2, 2026
cpsievert
commented
Jan 2, 2026
Port integration tests from tidyverse/ellmer#829: - Add assert_tool_web_fetch and assert_tool_web_search helpers to conftest.py - Add test_anthropic_web_fetch and test_anthropic_web_search - Add test_google_web_fetch and test_google_web_search - Add test_openai_web_search (OpenAI doesn't support web_fetch) Fix Anthropic provider to handle web search/fetch content in multi-turn conversations by explicitly storing only API-input-accepted fields (the API response includes output-only fields like citations, text, url that aren't accepted when replaying turns). 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <[email protected]>
- ContentWebSearchRequest → ContentToolRequestSearch - ContentWebSearchResults → ContentToolResponseSearch - ContentWebFetchRequest → ContentToolRequestFetch - ContentWebFetchResults → ContentToolResponseFetch 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <[email protected]>
efda95c to
94b6723
Compare
The MCP tool compatibility improvements (strict=False, sanitize_schema with format removal, doc restructure) have been moved to a separate PR (feat/mcp-tool-compat branch). This PR now focuses solely on the built-in web search/fetch tools: - tool_web_search() and tool_web_fetch() functions - Content types for web search/fetch requests and results - Provider integration tests The callout tip about built-in tools is kept in mcp-tools.qmd to help users discover the simpler alternative to MCP Fetch. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <[email protected]>
58b1619 to
3fe8d30
Compare
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.
Add provider-agnostic
tool_web_search()andtool_web_fetch()functions that enable built-in web search and URL fetching capabilities across supported providers (pairs with tidyverse/ellmer#829).Supported providers
tool_web_search()tool_web_fetch()For providers without native fetch support (like OpenAI), use the MCP Fetch server via
register_mcp_tools_stdio_async(). (turns out this will require some fixes to the MCP tool logic, so this will come in a follow up PR)Key changes
tool_web_search()andtool_web_fetch()provide a unified interface that translates to each provider's native formatContentWebSearchRequest,ContentWebSearchResults,ContentWebFetchRequest,ContentWebFetchResultscapture web tool interactions in conversation historyExample usage
Test plan
TODO