Overview
Web tools enable agents to search the web and retrieve page content. The search tool supports multiple backends with automatic fallback, while the fetch tool extracts readable text from HTML pages.Tools
web_search
Search the web and return a list of results with titles, URLs, and snippets.Search query
Maximum number of results to return (default 5, max 10)
Search Backends
Brave Search (Primary)
When a Brave API key is configured, the tool uses Brave Search API for fast, ad-free results:DuckDuckGo (Fallback)
If Brave is unavailable or fails, the tool automatically falls back to DuckDuckGo HTML scraping. No API key required.web_fetch
Fetch a URL and extract its main readable text content.URL to fetch (must start with http:// or https://)
Content Extraction
Theweb_fetch tool uses a minimal HTML-to-text converter that:
- Strips script/style tags: Removes JavaScript, CSS, and other non-readable elements
- Preserves structure: Adds line breaks for paragraphs, headings, and list items
- Collapses whitespace: Reduces multiple blank lines to single line breaks
- Skips navigation: Ignores nav, header, footer elements
text/htmlorapplication/xhtml: Extracts readable texttext/*,application/json,application/xml: Returns raw content- Binary files: Reports file type and size
Configuration
Timeouts
HTTP requests use the following timeout settings (defined in code):User Agent
All requests use a custom user agent to identify the bot:Redirects
The fetch tool follows up to 5 redirects automatically.Error Handling
Search Errors
Fetch Errors
HTTP errors:Best Practices
- Use specific queries for better search results
- Limit results to avoid excessive API usage (max 10)
- Check for errors in returned content before processing
- Prefer Brave for production (requires API key but more reliable)
- Handle timeouts gracefully for slow sites
Implementation
Defined ingrip/tools/web.py. Uses:
httpx.AsyncClientfor async HTTP requestsHTMLParsersubclass for text extraction- Regex-based DuckDuckGo result parsing
- Automatic fallback between search backends