Search Tools
File: assistant/search_tools.go (248 lines)
The search system provides multi-source web search with automatic fallback chains. It powers the websearch and news_summary tools used by agents for real-time information retrieval.
Architecture
WebSearchTool() / GetNewsSummaryTool()
↓
Tier 1: Perplexity Direct API (sonar-pro)
↓ (on failure)
Tier 2: OpenRouter (perplexity/llama-3.1-sonar-small-128k-online)
↓ (on failure)
Tier 3: Brave Web Search (shell script tool)
↓ (all fail)
Return error
Search Functions
WebSearchTool
WebSearchTool(session, args) — General web search.
- Parameters:
{query: string} - Tier 1: Direct Perplexity API via
NewPerplexityClient().QueryPerplexityDirect() - Tier 2: OpenRouter with
perplexity/llama-3.1-sonar-small-128k-online - Tier 3: Falls back to
brave_web_searchshell tool viasession.ExecuteTool() - Timeout: 60 seconds per search context
GetNewsSummaryTool
GetNewsSummaryTool(session, args) — Category-specific news search.
- Parameters:
{category: string, topic: string} - Tier 1: Direct Perplexity with
sonar-promodel - Tier 2: OpenRouter with
perplexity/sonar-pro - Tier 3: Brave search
- Same 60s timeout
NewsDeepDiveTool
NewsDeepDiveTool(session, args) — Multi-stage news investigation.
- Parameters:
{topic: string} - Stage 1: Factual search via Perplexity Direct (
sonar-pro) - Stage 2: Social sentiment analysis via Grok-2 model
- Stage 3: Nikki persona synthesis combining both sources
- Output: Structured "Deep Dive Report" with THE SITUATION, THE PUBLIC PULSE, MY ANALYSIS sections
Perplexity Client
File: assistant/perplexity_client.go
| Component | Details |
|---|---|
PerplexityClient |
HTTP client with 60s timeout |
| Base URL | https://api.perplexity.ai |
QueryPerplexityDirect() |
Direct query using sonar-pro model |
GlobalPerplexityQuery() |
Convenience wrapper for direct access without session |
Note: Perplexity is NOT registered in the llmClients map. It's instantiated directly when needed for search operations.
Observability Integration
All search operations log provider metrics via GlobalObservabilityDB.LogProviderMetric(), tracking success/failure rates and latency per provider tier.
See also: LLM Providers