Skip to contents

A tool that performs a web search and returns results. Uses DuckDuckGo's HTML search results by default.

Usage

tool_web_search(query, num_results = 10)

Format

A tool definition created with ellmer::tool().

Arguments

query

The search query (tool argument)

num_results

Maximum number of results to return (tool argument)

Value

When called directly, a character string containing formatted search results.

Details

This tool searches the web using DuckDuckGo and returns a list of results with titles, URLs, and snippets. For more sophisticated search needs, consider using a dedicated search API.

See also

Examples

if (FALSE) { # \dontrun{
agent <- Agent$new(
  chat = ellmer::chat("openai/gpt-5.6-luna"),
  tools = list(tool_web_search),
  permissions = Permissions(web = TRUE)
)
} # }