Search
SearXNG-backed search, phased search-agent execution, and deep research integration.
Search combines query planning, multi-query execution, URL selection, scraping, and answer synthesis.
Feature dependency
Search quality depends on both feature flags and deployed service availability. Keep FEATURE_* and SERVICE_* toggles aligned.
Core Components
- Search API client:
searchSearxng(...)inapps/app/src/lib/searxng.ts - Search tool orchestration:
performSearch(...)inapps/app/src/lib/ai/tools.ts - Search planning + phases:
executeSearchAgent(...)insearch-agent-handler.ts - Deep research flow:
handleDeepSearch(...)indeep-search-handler.ts - Search decision model:
classifySearchRequest(...)insearch-classifier.ts
Standard Search Flow
Classify intent
Classifier determines whether search is needed and which mode to execute.
Execute search phases
Planner builds queries, search client executes them, and selector/scraper gather relevant evidence.
Synthesize response
Model produces the final answer using retrieved context and emits phase status updates.
Search-phase statuses emitted include: planning, searching, selecting, scraping, and answering.
Context-Filtered Search
performSearch(...) supports context-based site filtering:
- selected search contexts map to site lists
- query can be augmented with
site:filters - no filter for full internet context
Limits in implementation:
- max queries per batch:
5 - default max results per query:
5
Environment Configuration
SEARXNG_URL=http://localhost:8080
SEARXNG_ENGINES=Feature and service controls:
FEATURE_SEARCH_ENABLED=true
FEATURE_DEEP_SEARCH_ENABLED=true
SERVICE_SEARXNG_AVAILABLE=true
SERVICE_BROWSERUSE_AVAILABLE=trueFailure and Degradation Behavior
- if search/scrape fails inside agent flow, fallback answer path is used with a verification caveat
- if search services are intentionally disabled, keep feature/service flags aligned