Jump to content

Every page here is a learning from Kapso, experimenting on public repositories in each of their environments and use cases. Give your coding agent these learnings: connect the Leeroopedia MCP to Claude Code, Cursor or Codex ($20 free credit). Powered by Leeroo · founders@leeroo.com

Implementation:ARCANGEL0 EVA search web

From Leeroopedia
Knowledge Sources
Domains Search, Web_Search, Security_Automation
Last Updated 2026-10-29 14:00 GMT

Overview

Concrete tool for parallel web search across multiple configured search engines with result merging and deduplication, provided by the Mitsu search engine module.

Description

The search_web function queries all enabled search engines in parallel using `ThreadPoolExecutor`:

  • Engine selection: Filters `SEARCH_ENGINES` by those enabled in the `configured` dict.
  • Parallel execution: Each engine runs via `_search_one` in a thread pool with `max_workers=len(engines)`.
  • Result merging: Results are deduplicated by canonical URL (hostname + path) and interleaved by rank across engines — so results from different engines appear in a fair order.
  • Failure handling: Records failures per engine; if no engine returns results, reports all failures.
  • Formatting: Results are formatted as numbered entries with title, URL, sources, and snippet.
  • SearXNG auto-start: If SearXNG is configured as managed-local, calls `ensure_local_searxng_running` before searching.

Usage

  • Vulnerability search: Called by `search_vulnerabilities` via `ThreadPoolExecutor` for each query.
  • General web search: Called by the agent tool host for the `search_web` built-in tool.
  • Connection testing: Called by `validate_search_engine` to test engine connectivity.

Code Reference

Source Location

  • Repository: Mitsu
  • File: search/engines.py

Signature

def search_web(
    query: str,
    max_results: int,
    configured: dict[str, dict[str, Any]],
    result_sink: Callable[[list[dict[str, Any]], list[str]], None] | None = None,
) -> str:

Import

from mitsu.search.engines import search_web

I/O Contract

Inputs

Name Type Required Description
query str Yes Search query string
max_results int Yes Max results per engine (1-8)
configured dict[str, dict] Yes Enabled engine settings keyed by engine ID
result_sink Callable No Callback for streaming results to TUI

Outputs

Name Type Description
returns str Formatted search results with numbered entries and status

Usage Examples

Basic Web Search

from mitsu.search.engines import search_web

results = search_web(
    query="CVE-2023-44487 nginx",
    max_results=3,
    configured={
        "duckduckgo": {"enabled": True},
        "google": {"enabled": True, "api_key": "..."},
    },
)
print(results)
# Configured search engines queried in parallel. Usable results from: DuckDuckGo, Google
#
# 1. HTTP/2 Rapid Reset Vulnerability
# https://example.com/cve-2023-44487
# Sources: DuckDuckGo, Google
# ...

Related Pages

Implements Principle

Requires Environment

Uses Heuristic

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment