feat: add TavilySearchTool and related functionality for web search#2701
Merged
Lancetnik merged 5 commits intoag2ai:mainfrom Apr 21, 2026
Merged
feat: add TavilySearchTool and related functionality for web search#2701Lancetnik merged 5 commits intoag2ai:mainfrom
Lancetnik merged 5 commits intoag2ai:mainfrom
Conversation
Collaborator
|
@claude add a review |
|
I'll analyze this and get back to you. |
priyansh4320
approved these changes
Apr 21, 2026
Lancetnik
approved these changes
Apr 21, 2026
Codecov Report❌ Patch coverage is
... and 351 files with indirect coverage changes 🚀 New features to boost your workflow:
|
This was referenced Apr 21, 2026
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.

TavilySearchTool
API
Constructor
All search parameters accept
Variablefor deferred resolution fromcontext.variablesat call time.Nonevalues are not forwarded to the Tavily API, so Tavily's server-side defaults apply.api_keystr | NoneNoneNone,TavilyClientfalls back toTAVILY_API_KEYenv var.max_resultsint | Variable | NoneNonesearch_depth"basic" | "advanced" | "fast" | "ultra-fast" | Variable | NoneNonetopic"general" | "news" | "finance" | Variable | NoneNoneinclude_answerbool | "basic" | "advanced" | Variable | NoneNoneinclude_raw_contentbool | "markdown" | "text" | Variable | NoneNoneinclude_imagesbool | Variable | NoneNonetime_range"day" | "week" | "month" | "year" | Variable | NoneNonestart_date/end_datestr | Variable | NoneNonedaysint | Variable | NoneNoneinclude_domains/exclude_domainsSequence[str] | Variable | NoneNonecountrystr | Variable | NoneNoneauto_parametersbool | Variable | NoneNoneinclude_faviconbool | Variable | NoneNoneclientTavilyClient | NoneNoneTavilyClientinstance (for proxy, custom base URL, etc.)namestr"tavily_search"descriptionstrmiddlewareIterable[ToolMiddleware]()Tool schema (what the LLM sees)
{ "name": "tavily_search", "parameters": { "properties": { "query": { "type": "string", "description": "The search query string." } }, "required": ["query"] } }Return type
The tool returns a
SearchResponsedataclass. The framework serialises it to JSON automatically when forwarding the result back to the LLM.Example (serialised form seen by the LLM):
{ "query": "ag2 framework", "results": [ { "title": "AG2 Framework", "url": "https://ag2.ai", "snippet": "AG2 is an open-source agent framework.", "score": 0.95, "raw_content": null, "favicon": "https://ag2.ai/favicon.ico" }, { "title": "GitHub - AG2", "url": "https://github.com/ag2ai/ag2", "snippet": "Open source repo for AG2.", "score": 0.82, "raw_content": null, "favicon": null } ], "answer": "AG2 is an open-source multi-agent framework.", "images": [] }Empty result:
{"query": "...", "results": [], "answer": null, "images": []}.Usage examples
Basic
Tuned for quality