Overview
Klaus integrates Tavily for web search, allowing Claude to verify claims, look up papers, and gather external context during conversations.WebSearch Class
TheWebSearch class wraps the Tavily API and formats results for Claude.
Constructor
config.TAVILY_API_KEY.
Methods
search(query: str, max_results: int = 5) -> str
Run a search and return formatted results as a string for Claude.
Search query string
Maximum number of results to return
Tool Definition
The search capability is exposed to Claude via theTOOL_DEFINITION dictionary:
Usage in Brain
TheBrain class in klaus/brain.py registers TOOL_DEFINITION with Claude and calls WebSearch.search() when Claude invokes the web_search tool.
Example tool use flow:
- User asks: “Who wrote the paper on neural scaling laws?”
- Claude decides to invoke
web_searchtool with query"neural scaling laws author" BraincallsWebSearch.search("neural scaling laws author")- Tavily returns results
- Claude receives formatted results and responds with the answer
Configuration
Set your Tavily API key in~/.klaus/config.toml:
.env:
Implementation Details
- Search depth: Uses
search_depth="advanced"for higher-quality results - Error handling: Returns error message string on API failure
- Result formatting: Each result includes title, URL, and content snippet, separated by
---
Source Reference
Seeklaus/search.py for the full implementation.