-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Add WebFetchTool builtin tool support #3427
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
base: main
Are you sure you want to change the base?
Changes from 10 commits
9a92f05
8a0bbcc
3e36dc5
a95b249
f72bbe8
726957b
4ddee67
4d5da14
31dbe36
cd8b04b
4e54dfb
d8ef825
f8f9cd5
ba7f1fd
1e59fce
89751ce
b054020
ced98b4
e8f7a25
17fb30c
c048d15
52f2f86
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -315,9 +315,9 @@ allowing it to pull up-to-date information from the web. | |
|
|
||
| | Provider | Supported | Notes | | ||
| |----------|-----------|-------| | ||
| | Anthropic | ✅ | Full feature support. Uses Anthropic's [Web Fetch Tool](https://docs.claude.com/en/docs/agents-and-tools/tool-use/web-fetch-tool) internally to retrieve URL contents. | | ||
| | Google | ✅ | No [`BuiltinToolCallPart`][pydantic_ai.messages.BuiltinToolCallPart] or [`BuiltinToolReturnPart`][pydantic_ai.messages.BuiltinToolReturnPart] is currently generated; please submit an issue if you need this. Using built-in tools and function tools (including [output tools](output.md#tool-output)) at the same time is not supported; to use structured output, use [`PromptedOutput`](output.md#prompted-output) instead. | | ||
| | OpenAI | ❌ | | | ||
| | Anthropic | ❌ | | | ||
| | Groq | ❌ | | | ||
| | Bedrock | ❌ | | | ||
| | Mistral | ❌ | | | ||
|
|
@@ -327,7 +327,23 @@ allowing it to pull up-to-date information from the web. | |
|
|
||
| ### Usage | ||
|
|
||
| ```py {title="url_context_basic.py"} | ||
| ```py {title="url_context_anthropic.py"} | ||
| from pydantic_ai import Agent, UrlContextTool | ||
|
|
||
| agent = Agent('anthropic:claude-sonnet-4-0', builtin_tools=[UrlContextTool()]) | ||
|
|
||
| result = agent.run_sync('What is the first sentence on https://ai.pydantic.dev?') | ||
| print(result.output) | ||
| """ | ||
| Pydantic AI is a Python agent framework designed to make it less painful to build production grade applications with Generative AI. | ||
| """ | ||
| ``` | ||
|
|
||
| _(This example is complete, it can be run "as is")_ | ||
|
|
||
| With Google, you can also use `UrlContextTool`: | ||
|
||
|
|
||
| ```py {title="url_context_google.py"} | ||
| from pydantic_ai import Agent, UrlContextTool | ||
|
|
||
| agent = Agent('google-gla:gemini-2.5-flash', builtin_tools=[UrlContextTool()]) | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -171,6 +171,7 @@ class UrlContextTool(AbstractBuiltinTool): | |
|
|
||
| Supported by: | ||
|
|
||
| * Anthropic | ||
| """ | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To answer your question in the comment: let's rename the entire thing to
WebFetchTool, and keepUrlContextToolaround only as an alias with a deprecation warning.