Web Tools
The WebToolProvider provides web fetching and search capabilities.
WebToolProvider
stirrup.tools.web.WebToolProvider
Bases: ToolProvider
Provides web tools (web_fetch, web_search) with managed HTTP client lifecycle.
WebToolProvider implements the Tool lifecycle protocol (has_lifecycle=True), so it can be used directly in Agent's tools list. It creates an httpx.AsyncClient on aenter and returns the web tools.
Usage as Tool in Agent (preferred): from stirrup.clients.chat_completions_client import ChatCompletionsClient
client = ChatCompletionsClient(model="gpt-5")
agent = Agent(
client=client,
name="assistant",
tools=[LocalCodeExecToolProvider(), WebToolProvider(), CALCULATOR_TOOL],
)
async with agent.session(output_dir="./output") as session:
await session.run("Search the web and fetch a page")
Standalone usage
async with WebToolProvider() as provider: tools = provider.get_tools()
Initialize WebToolProvider.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
timeout
|
float
|
HTTP timeout in seconds (default: 180) |
60 * 3
|
brave_api_key
|
str | None
|
Brave Search API key for web_search tool. If None, uses BRAVE_API_KEY environment variable. Web search is only available if API key is provided. |
None
|
Source code in src/stirrup/tools/web.py
__aenter__
async
Enter async context: create HTTP client and return web tools.
Returns:
| Type | Description |
|---|---|
list[Tool[Any, Any]]
|
List of Tool objects (web_fetch, and web_search if API key available). |
Source code in src/stirrup/tools/web.py
__aexit__
async
__aexit__(
exc_type: type[BaseException] | None,
exc_val: BaseException | None,
exc_tb: TracebackType | None,
) -> None
Exit async context: close HTTP client.
Source code in src/stirrup/tools/web.py
Web Fetch Tool
Fetches a web page and returns its content as markdown.
stirrup.tools.web.FetchWebPageParams
Web Search Tool
Searches the web using the Brave Search API.
Note
Requires BRAVE_API_KEY environment variable.