Returns a list of tools for web operations. When a chat object is provided,
automatically selects the best tools for that provider:
Claude (Anthropic): Uses native
claude_tool_web_search()andclaude_tool_web_fetch()for higher quality results (requires admin enablement and incurs extra cost)Google (Gemini/Vertex): Uses native
google_tool_web_search()andgoogle_tool_web_fetch()OpenAI: Uses native
openai_tool_web_search()Other providers: Falls back to universal tools using httr2 and DuckDuckGo
Without a chat argument, returns universal tools that work with any provider.
Examples
if (FALSE) { # \dontrun{
# Universal tools (work with any provider)
agent <- Agent$new(
chat = ellmer::chat_ollama(),
tools = tools_web(),
permissions = Permissions$new(web = TRUE)
)
# Provider-specific tools (auto-detected)
chat <- ellmer::chat_claude()
agent <- Agent$new(
chat = chat,
tools = tools_web(chat), # Uses Claude's native web tools
permissions = Permissions$new(web = TRUE)
)
# Force universal tools even with Claude
agent <- Agent$new(
chat = chat,
tools = tools_web(chat, use_native = FALSE),
permissions = Permissions$new(web = TRUE)
)
} # }