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:ANative Lab EvoAgentX SearchBase

From Leeroopedia
Knowledge Sources
Domains Tools, Search
Last Updated 2026-10-21 00:00 GMT

Overview

Concrete base class for search tools that retrieve information from various sources with HTML content extraction.

Description

The SearchBase class provides common functionality for search operations across different search providers. It extends BaseModule and includes HTML-to-text conversion via `html2text`, content truncation by word count, and page scraping with `BeautifulSoup`. Subclasses (DuckDuckGo, Google, SerpAPI, Serper, Exa, Wikipedia) extend this base to implement provider-specific search logic. The shared infrastructure handles content extraction, truncation, and web page scraping.

Usage

  • Custom search tools: Subclass `SearchBase` to implement provider-specific search logic.
  • Content extraction: Use `_scrape_page()` to fetch and extract content from web pages.
  • Content truncation: Use `_truncate_content()` to limit content to a maximum word count.

Code Reference

Source Location

Signature

class SearchBase(BaseModule):
    num_search_pages: Optional[int] = Field(default=5, description="Number of search results to retrieve")
    max_content_words: Optional[int] = Field(default=None, description="Maximum number of words in content")

    def __init__(
        self,
        name: str = "SearchBase",
        num_search_pages: Optional[int] = 5,
        max_content_words: Optional[int] = None,
        **kwargs
    )

    def _truncate_content(self, content: str, max_words: Optional[int] = None) -> str
    def _scrape_page(self, url: str) -> Tuple[Optional[str], Optional[str]]

Import

from evoagentx.tools.search_base import SearchBase

I/O Contract

Inputs

Name Type Required Description
num_search_pages int No Number of results to retrieve (default 5)
max_content_words int No Max words in content (default None = no limit)

Outputs

Name Type Description
_scrape_page returns Tuple[str, str] (title, main textual content) from a web page
_truncate_content returns str Truncated content with ellipsis if truncated

Usage Examples

Scrape and Truncate Content

from evoagentx.tools.search_base import SearchBase

search = SearchBase(name="my_search", num_search_pages=3, max_content_words=500)

# Scrape a web page
title, content = search._scrape_page("https://en.wikipedia.org/wiki/Python_(programming_language)")
print(f"Title: {title}")
print(f"Content (truncated): {content[:200]}")

Related Pages

Implements Principle

Requires Environment

Page Connections

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