agents.memory_reorganized.search.base

Base classes for search agents.

This module provides the foundation for all search agents in the memory system, with common functionality for memory integration, tool management, and structured outputs.

Classes

BaseSearchAgent

Abstract base class for all search agents.

SearchResponse

Base response model for all search agents.

Functions

extract_memory_items(memory_data)

Extract memory items from memory data structure.

format_search_context(query, context)

Format search context for agents (module-level utility function).

get_response_model()

Get the response model for search agents.

get_search_instructions()

Get generic search instructions.

get_system_prompt()

Get generic system prompt for search agents.

Module Contents

class agents.memory_reorganized.search.base.BaseSearchAgent(name, engine, search_tools=None, **kwargs)

Bases: haive.agents.react.agent.ReactAgent, abc.ABC

Abstract base class for all search agents.

Provides common functionality for memory integration, tool management, and structured output formatting for search operations.

Initialize the search agent.

Parameters:
  • name (str) – Unique identifier for the agent

  • engine (haive.core.engine.aug_llm.AugLLMConfig) – LLM configuration for the agent

  • search_tools (list[langchain_core.tools.Tool] | None) – Optional list of search tools to use

  • **kwargs – Additional arguments passed to parent class

extract_memory_items(query, response)

Extract memory items from search interaction.

Parameters:
  • query (str) – The search query

  • response (str) – The search response

Returns:

List of memory items to store

Return type:

list[dict[str, Any]]

format_search_context(query, context)

Format search context for the agent.

Parameters:
  • query (str) – The user’s search query

  • context (dict[str, Any]) – Additional context including memory, preferences, etc.

Returns:

Formatted context string for the agent

Return type:

str

abstractmethod get_response_model()

Get the structured response model for this search agent.

Return type:

type[SearchResponse]

abstractmethod get_search_instructions()

Get specific search instructions for this agent type.

Return type:

str

abstractmethod get_system_prompt()

Get the system prompt template for this search agent.

Return type:

str

Process a search query with memory integration.

Parameters:
  • query (str) – The search query

  • context (dict[str, Any] | None) – Optional context including memory and preferences

  • save_to_memory (bool) – Whether to save results to memory

Returns:

Structured search response

Return type:

SearchResponse

class agents.memory_reorganized.search.base.SearchResponse(/, **data)

Bases: pydantic.BaseModel

Base response model for all search agents.

Create a new model by parsing and validating input data from keyword arguments.

Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.

self is explicitly positional-only to allow self as a field name.

Parameters:

data (Any)

agents.memory_reorganized.search.base.extract_memory_items(memory_data)

Extract memory items from memory data structure.

Parameters:

memory_data (Any) – Raw memory data from various sources

Returns:

List of formatted memory items as strings

Return type:

list[str]

agents.memory_reorganized.search.base.format_search_context(query, context)

Format search context for agents (module-level utility function).

Parameters:
  • query (str) – The user’s search query

  • context (dict[str, Any]) – Additional context including memory, preferences, etc.

Returns:

Formatted context string for the agent

Return type:

str

agents.memory_reorganized.search.base.get_response_model()

Get the response model for search agents.

Return type:

type[SearchResponse]

agents.memory_reorganized.search.base.get_search_instructions()

Get generic search instructions.

Return type:

str

agents.memory_reorganized.search.base.get_system_prompt()

Get generic system prompt for search agents.

Return type:

str