diff --git a/CHANGELOG.md b/CHANGELOG.md index 42af325..4f8a295 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,21 @@ and this project adheres to [Semantic Versioning](https://semver.org/). ## [Unreleased] +## [0.0.6] - 2026-05-20 + +### Breaking + +- Removed `create_memory_mcp_toolset()` and all MCP wrapper constants + (`ALL_MCP_TOOLS`, `MCP_TOOL_*`) from the package. Use ADK's native + `McpToolset` with `SseConnectionParams` pointed at the Agent Memory + Server `/sse` endpoint instead. This aligns AMS MCP wiring with the + standard pattern used by all other ADK catalog integrations. + +### Changed + +- Updated `fitness_coach_mcp` example to use native `McpToolset` + + `SseConnectionParams` directly. + ## [0.0.5] - 2026-05-19 ### Breaking diff --git a/README.md b/README.md index b5a319d..f759fd6 100644 --- a/README.md +++ b/README.md @@ -30,7 +30,6 @@ | **Sessions** (`RedisWorkingMemorySessionService`) | `BaseSessionService` with auto-summarization and context-window management | Agent Memory Server (REST) | | **Long-term memory** (`RedisLongTermMemoryService`) | `BaseMemoryService` with semantic search and recency boosting | Agent Memory Server (REST) | | **Memory tools** (`SearchMemoryTool`, `CreateMemoryTool`, ...) | LLM-controlled memory operations | Agent Memory Server (REST) | -| **AMS MCP toolset** (`create_memory_mcp_toolset`) | Exposes `search_long_term_memory`, `create_long_term_memories`, `edit_long_term_memory`, `delete_long_term_memories`, `get_long_term_memory`, `memory_prompt`, and `set_working_memory` over SSE | Agent Memory Server (MCP) | | **RedisVL MCP** (native `McpToolset` against `rvl mcp`) |
cache
+
+
+¶Semantic caching for ADK agents using Redis.
+ + + + + + + + + + + LLMResponseCache
+
+
+¶LLMResponseCache(provider: BaseCacheProvider, config: Optional[LLMResponseCacheConfig] = None)
+Cache service for LLM responses.
+This service caches LLM responses using semantic similarity matching. +It can be configured to only cache first messages in a session to +reduce API costs for common initial queries.
+ +Initialize the LLM response cache.
+ + +Parameters:
+| Name | +Type | +Description | +Default | +
|---|---|---|---|
+ provider
+ |
+
+ BaseCacheProvider
+ |
+
+
+
+ The cache provider to use for storage. + |
+ + required + | +
+ config
+ |
+
+ Optional[LLMResponseCacheConfig]
+ |
+
+
+
+ Configuration for caching behavior. + |
+
+ None
+ |
+
src/adk_redis/cache/llm_cache.py before_model_callback
+
+
+
+ async
+
+
+¶before_model_callback(callback_context: CallbackContext, llm_request: LlmRequest) -> Optional[LlmResponse]
+Check cache before making LLM call.
+ + +Parameters:
+| Name | +Type | +Description | +Default | +
|---|---|---|---|
+ callback_context
+ |
+
+ CallbackContext
+ |
+
+
+
+ The callback context with session info. + |
+ + required + | +
+ llm_request
+ |
+
+ LlmRequest
+ |
+
+
+
+ The LLM request being made. + |
+ + required + | +
Returns:
+| Type | +Description | +
|---|---|
+ Optional[LlmResponse]
+ |
+
+
+
+ LlmResponse if cache hit, None to proceed with LLM call. + |
+
src/adk_redis/cache/llm_cache.py after_model_callback
+
+
+
+ async
+
+
+¶after_model_callback(callback_context: CallbackContext, llm_response: LlmResponse) -> Optional[LlmResponse]
+Store response in cache after LLM call.
+ + +Parameters:
+| Name | +Type | +Description | +Default | +
|---|---|---|---|
+ callback_context
+ |
+
+ CallbackContext
+ |
+
+
+
+ The callback context with session info. + |
+ + required + | +
+ llm_response
+ |
+
+ LlmResponse
+ |
+
+
+
+ The LLM response to cache. + |
+ + required + | +
Returns:
+| Type | +Description | +
|---|---|
+ Optional[LlmResponse]
+ |
+
+
+
+ None to pass through the original response. + |
+
src/adk_redis/cache/llm_cache.py LLMResponseCacheConfig
+
+
+¶
+ Bases: BaseModel
Configuration for LLM response caching.
+ + +Attributes:
+| Name | +Type | +Description | +
|---|---|---|
first_message_only |
+
+ bool
+ |
+
+
+
+ Only cache first message in session. + |
+
include_app_name |
+
+ bool
+ |
+
+
+
+ Include app name in cache key. + |
+
include_user_id |
+
+ bool
+ |
+
+
+
+ Include user ID in cache key. + |
+
include_session_id |
+
+ bool
+ |
+
+
+
+ Include session ID in cache key. + |
+
BaseCacheProvider
+
+
+¶
+ Bases: ABC
Abstract base class for cache providers.
+ + + + + + + + + + + + check
+
+
+
+ abstractmethod
+ async
+
+
+¶check(prompt: str, **kwargs: Any) -> Optional[CacheEntry]
+Check if a semantically similar prompt exists in the cache.
+ + + + store
+
+
+
+ abstractmethod
+ async
+
+
+¶store(prompt: str, response: str, metadata: Optional[dict[str, Any]] = None, **kwargs: Any) -> None
+Store a prompt-response pair in the cache.
+ + + + clear
+
+
+
+ abstractmethod
+ async
+
+
+¶ close
+
+
+
+ abstractmethod
+ async
+
+
+¶ CacheEntry
+
+
+
+ dataclass
+
+
+¶CacheEntry(prompt: str, response: str, distance: Optional[float] = None, metadata: Optional[dict[str, Any]] = None)
+Represents a cached entry.
+ + + + + + + + + + + + LangCacheProvider
+
+
+¶LangCacheProvider(config: LangCacheProviderConfig)
+
+ Bases: BaseCacheProvider
Cache provider using Redis LangCache (managed semantic cache service).
+LangCache is a managed semantic caching service that handles embedding +generation, storage, and retrieval. Unlike RedisVLCacheProvider, it does +not require a local vectorizer — embeddings are handled server-side.
+Requires redisvl>=0.11.1 with LangCache support.
+ +Initialize the LangCache cache provider.
+ + +Parameters:
+| Name | +Type | +Description | +Default | +
|---|---|---|---|
+ config
+ |
+
+ LangCacheProviderConfig
+ |
+
+
+
+ Configuration for the LangCache provider. + |
+ + required + | +
Raises:
+| Type | +Description | +
|---|---|
+ ImportError
+ |
+
+
+
+ If redisvl>=0.11.1 is not installed. + |
+
src/adk_redis/cache/_provider.py check
+
+
+
+ async
+
+
+¶check(prompt: str, **kwargs: Any) -> Optional[CacheEntry]
+Check for a semantically similar prompt in LangCache.
+ + +Parameters:
+| Name | +Type | +Description | +Default | +
|---|---|---|---|
+ prompt
+ |
+
+ str
+ |
+
+
+
+ The prompt to check. + |
+ + required + | +
+ **kwargs
+ |
+
+ Any
+ |
+
+
+
+ Additional keyword arguments (e.g., distance_threshold). + |
+
+ {}
+ |
+
Returns:
+| Type | +Description | +
|---|---|
+ Optional[CacheEntry]
+ |
+
+
+
+ A CacheEntry if a cache hit is found, None otherwise. + |
+
src/adk_redis/cache/_provider.py store
+
+
+
+ async
+
+
+¶store(prompt: str, response: str, metadata: Optional[dict[str, Any]] = None, **kwargs: Any) -> None
+Store a prompt-response pair in LangCache.
+ + +Parameters:
+| Name | +Type | +Description | +Default | +
|---|---|---|---|
+ prompt
+ |
+
+ str
+ |
+
+
+
+ The prompt text. + |
+ + required + | +
+ response
+ |
+
+ str
+ |
+
+
+
+ The response text. + |
+ + required + | +
+ metadata
+ |
+
+ Optional[dict[str, Any]]
+ |
+
+
+
+ Optional metadata to store alongside the entry. + |
+
+ None
+ |
+
+ **kwargs
+ |
+
+ Any
+ |
+
+
+
+ Additional keyword arguments (e.g., ttl). + |
+
+ {}
+ |
+
src/adk_redis/cache/_provider.py clear
+
+
+
+ async
+
+
+¶ close
+
+
+
+ async
+
+
+¶Close the LangCache provider and release resources.
+ + + + LangCacheProviderConfig
+
+
+¶
+ Bases: BaseModel
Configuration for LangCache (managed semantic cache) provider.
+LangCache is a managed semantic caching service provided by Redis. +It requires a cache_id and api_key from the LangCache service.
+ + + + + + + + + + + + RedisVLCacheProvider
+
+
+¶RedisVLCacheProvider(config: RedisVLCacheProviderConfig, vectorizer: Any)
+
+ Bases: BaseCacheProvider
Cache provider using RedisVL's SemanticCache.
+ +Initialize the RedisVL cache provider.
+ + + + + + + + +src/adk_redis/cache/_provider.py check
+
+
+
+ async
+
+
+¶check(prompt: str, **kwargs: Any) -> Optional[CacheEntry]
+Check for a semantically similar prompt in the cache.
+ + +src/adk_redis/cache/_provider.py store
+
+
+
+ async
+
+
+¶store(prompt: str, response: str, metadata: Optional[dict[str, Any]] = None, **kwargs: Any) -> None
+Store a prompt-response pair in the cache.
+ + +src/adk_redis/cache/_provider.py clear
+
+
+
+ async
+
+
+¶ close
+
+
+
+ async
+
+
+¶Close the cache provider and release resources.
+ + +src/adk_redis/cache/_provider.py RedisVLCacheProviderConfig
+
+
+¶
+ Bases: BaseModel
Configuration for RedisVL cache provider.
+ + + + + + + + + + + + ToolCache
+
+
+¶ToolCache(provider: BaseCacheProvider, config: Optional[ToolCacheConfig] = None)
+Cache service for tool call results.
+This service caches tool results using semantic similarity matching +on the tool name and arguments. It can be configured to only cache +specific tools.
+ +Initialize the tool cache.
+ + +Parameters:
+| Name | +Type | +Description | +Default | +
|---|---|---|---|
+ provider
+ |
+
+ BaseCacheProvider
+ |
+
+
+
+ The cache provider to use for storage. + |
+ + required + | +
+ config
+ |
+
+ Optional[ToolCacheConfig]
+ |
+
+
+
+ Configuration for caching behavior. + |
+
+ None
+ |
+
src/adk_redis/cache/tool_cache.py before_tool_callback
+
+
+
+ async
+
+
+¶before_tool_callback(tool: BaseTool, args: Dict[str, Any], tool_context: ToolContext) -> Optional[Dict[str, Any]]
+Check cache before executing tool.
+ + +Parameters:
+| Name | +Type | +Description | +Default | +
|---|---|---|---|
+ tool
+ |
+
+ BaseTool
+ |
+
+
+
+ The tool being called. + |
+ + required + | +
+ args
+ |
+
+ Dict[str, Any]
+ |
+
+
+
+ The arguments for the tool call. + |
+ + required + | +
+ tool_context
+ |
+
+ ToolContext
+ |
+
+
+
+ The tool context with session info. + |
+ + required + | +
Returns:
+| Type | +Description | +
|---|---|
+ Optional[Dict[str, Any]]
+ |
+
+
+
+ Dict if cache hit (skips tool execution), None to proceed. + |
+
src/adk_redis/cache/tool_cache.py after_tool_callback
+
+
+
+ async
+
+
+¶after_tool_callback(tool: BaseTool, args: Dict[str, Any], tool_context: ToolContext, tool_response: Dict[str, Any]) -> Optional[Dict[str, Any]]
+Store tool result in cache after execution.
+ + +Parameters:
+| Name | +Type | +Description | +Default | +
|---|---|---|---|
+ tool
+ |
+
+ BaseTool
+ |
+
+
+
+ The tool that was called. + |
+ + required + | +
+ args
+ |
+
+ Dict[str, Any]
+ |
+
+
+
+ The arguments used for the tool call. + |
+ + required + | +
+ tool_context
+ |
+
+ ToolContext
+ |
+
+
+
+ The tool context with session info. + |
+ + required + | +
+ tool_response
+ |
+
+ Dict[str, Any]
+ |
+
+
+
+ The result from the tool execution. + |
+ + required + | +
Returns:
+| Type | +Description | +
|---|---|
+ Optional[Dict[str, Any]]
+ |
+
+
+
+ None to pass through the original response. + |
+
src/adk_redis/cache/tool_cache.py ToolCacheConfig
+
+
+¶
+ Bases: BaseModel
Configuration for tool result caching.
+ + +Attributes:
+| Name | +Type | +Description | +
|---|---|---|
tool_names |
+
+ Optional[Set[str]]
+ |
+
+
+
+ Set of tool names to cache. None means cache all tools. + |
+
include_app_name |
+
+ bool
+ |
+
+
+
+ Include app name in cache key. + |
+
include_user_id |
+
+ bool
+ |
+
+
+
+ Include user ID in cache key. + |
+
include_session_id |
+
+ bool
+ |
+
+
+
+ Include session ID in cache key. + |
+
create_llm_cache_callbacks
+
+
+¶create_llm_cache_callbacks(cache: LLMResponseCache) -> Tuple[BeforeModelCallback, AfterModelCallback]
+Create callback functions for LLM response caching.
+This factory function wraps the LLMResponseCache methods into standalone +callback functions compatible with ADK's Agent constructor.
+ + +Parameters:
+| Name | +Type | +Description | +Default | +
|---|---|---|---|
+ cache
+ |
+
+ LLMResponseCache
+ |
+
+
+
+ The LLMResponseCache instance to use. + |
+ + required + | +
Returns:
+| Type | +Description | +
|---|---|
+ Tuple[BeforeModelCallback, AfterModelCallback]
+ |
+
+
+
+ A tuple of (before_model_callback, after_model_callback) functions. + |
+
src/adk_redis/cache/callbacks.py create_tool_cache_callbacks
+
+
+¶create_tool_cache_callbacks(cache: ToolCache) -> Tuple[BeforeToolCallback, AfterToolCallback]
+Create callback functions for tool result caching.
+This factory function wraps the ToolCache methods into standalone +callback functions compatible with ADK's Agent constructor.
+ + +Parameters:
+| Name | +Type | +Description | +Default | +
|---|---|---|---|
+ cache
+ |
+
+ ToolCache
+ |
+
+
+
+ The ToolCache instance to use. + |
+ + required + | +
Returns:
+| Type | +Description | +
|---|---|
+ Tuple[BeforeToolCallback, AfterToolCallback]
+ |
+
+
+
+ A tuple of (before_tool_callback, after_tool_callback) functions. + |
+
src/adk_redis/cache/callbacks.pyAuto-generated reference for the adk_redis package, generated from
+Google-style docstrings via mkdocstrings.
memory
+
+
+¶Redis memory services for ADK.
+ + + + + + + + + + + RedisLongTermMemoryService
+
+
+¶RedisLongTermMemoryService(config: RedisLongTermMemoryServiceConfig | None = None)
+
+ Bases: BaseMemoryService
Long-term memory service implementation using Redis Agent Memory Server.
+This service provides production-grade memory capabilities including: +- Two-tier memory architecture (working memory + long-term memory) +- Automatic memory extraction (semantic facts, episodic events, preferences) +- Topic and entity extraction +- Auto-summarization when context window is exceeded +- Recency-boosted semantic search +- Deduplication and memory compaction +- https://github.com/redis/agent-memory-server
+Requires the agent-memory-client package to be installed.
from adk_redis import (
+ RedisLongTermMemoryService,
+ RedisLongTermMemoryServiceConfig,
+)
+
+config = RedisLongTermMemoryServiceConfig(
+ api_base_url="http://localhost:8000",
+ default_namespace="my_app",
+ recency_boost=True,
+)
+memory_service = RedisLongTermMemoryService(config=config)
+
+# Use with ADK agent
+agent = Agent(
+ name="my_agent",
+ memory_service=memory_service,
+)
+Initialize the Redis Long-Term Memory Service.
+ + +Parameters:
+| Name | +Type | +Description | +Default | +
|---|---|---|---|
+ config
+ |
+
+ RedisLongTermMemoryServiceConfig | None
+ |
+
+
+
+ Configuration for the service. If None, uses defaults. + |
+
+ None
+ |
+
Raises:
+| Type | +Description | +
|---|---|
+ ImportError
+ |
+
+
+
+ If agent-memory-client package is not installed. + |
+
src/adk_redis/memory/long_term_memory.py add_session_to_memory
+
+
+
+ async
+
+
+¶Add a session's events to the Agent Memory Server.
+Converts ADK Session events to WorkingMemory messages and stores them +in the Agent Memory Server. The server will automatically: +- Extract semantic and episodic memories based on the configured strategy +- Perform topic and entity extraction +- Summarize context when the token limit is exceeded +- Promote memories to long-term storage via background tasks
+ + +Parameters:
+| Name | +Type | +Description | +Default | +
|---|---|---|---|
+ session
+ |
+
+ 'Session'
+ |
+
+
+
+ The ADK Session containing events to store. + |
+ + required + | +
src/adk_redis/memory/long_term_memory.py search_memory
+
+
+
+ async
+
+
+¶Search for memories using the Agent Memory Server.
+Performs semantic search against long-term memory with optional +recency boosting. Results are filtered by namespace (derived from +app_name) and user_id.
+ + +Parameters:
+| Name | +Type | +Description | +Default | +
|---|---|---|---|
+ app_name
+ |
+
+ str
+ |
+
+
+
+ The application name (used as namespace if not configured). + |
+ + required + | +
+ user_id
+ |
+
+ str
+ |
+
+
+
+ The user ID to filter memories. + |
+ + required + | +
+ query
+ |
+
+ str
+ |
+
+
+
+ The search query for semantic matching. + |
+ + required + | +
Returns:
+| Type | +Description | +
|---|---|
+ SearchMemoryResponse
+ |
+
+
+
+ SearchMemoryResponse containing matching MemoryEntry objects. + |
+
src/adk_redis/memory/long_term_memory.py close
+
+
+
+ async
+
+
+¶Close the memory service and cleanup resources.
+ + +src/adk_redis/memory/long_term_memory.py RedisLongTermMemoryServiceConfig
+
+
+¶
+ Bases: BaseModel
Configuration for Redis Long-Term Memory Service.
+ + +Attributes:
+| Name | +Type | +Description | +
|---|---|---|
api_base_url |
+
+ str
+ |
+
+
+
+ Base URL of the Agent Memory Server. + |
+
timeout |
+
+ float
+ |
+
+
+
+ HTTP request timeout in seconds. + |
+
default_namespace |
+
+ str | None
+ |
+
+
+
+ Default namespace for memory operations. + |
+
search_top_k |
+
+ int
+ |
+
+
+
+ Maximum number of memories to retrieve per search. + |
+
distance_threshold |
+
+ float | None
+ |
+
+
+
+ Maximum distance threshold for search results (0.0-1.0). + |
+
recency_boost |
+
+ bool
+ |
+
+
+
+ Enable recency-aware re-ranking of search results. + |
+
semantic_weight |
+
+ float
+ |
+
+
+
+ Weight for semantic similarity in recency boosting (0.0-1.0). + |
+
recency_weight |
+
+ float
+ |
+
+
+
+ Weight for recency score in recency boosting (0.0-1.0). + |
+
freshness_weight |
+
+ float
+ |
+
+
+
+ Weight for freshness component within recency score. + |
+
novelty_weight |
+
+ float
+ |
+
+
+
+ Weight for novelty component within recency score. + |
+
half_life_last_access_days |
+
+ float
+ |
+
+
+
+ Half-life in days for last_accessed decay. + |
+
half_life_created_days |
+
+ float
+ |
+
+
+
+ Half-life in days for created_at decay. + |
+
extraction_strategy |
+
+ Literal['discrete', 'summary', 'preferences', 'custom']
+ |
+
+
+
+ Memory extraction strategy (discrete, summary, preferences, custom). + |
+
extraction_strategy_config |
+
+ dict[str, Any]
+ |
+
+
+
+ Additional configuration for the extraction strategy. + |
+
model_name |
+
+ str | None
+ |
+
+
+
+ Model name for context window management and summarization. + |
+
context_window_max |
+
+ int | None
+ |
+
+
+
+ Maximum context window tokens (overrides model default). + |
+
sessions
+
+
+¶Redis session services for ADK.
+ + + + + + + + + + + RedisWorkingMemorySessionService
+
+
+¶RedisWorkingMemorySessionService(config: RedisWorkingMemorySessionServiceConfig | None = None)
+
+ Bases: BaseSessionService
Session service using Redis Agent Memory Server's Working Memory API.
+This service provides session management backed by Agent Memory Server: +- Session storage in Working Memory +- Automatic context summarization when token limit exceeded +- Background memory extraction to Long-Term Memory +- Incremental message appending +- https://github.com/redis/agent-memory-server
+Requires the agent-memory-client package to be installed.
from adk_redis import (
+ RedisWorkingMemorySessionService,
+ RedisWorkingMemorySessionServiceConfig,
+)
+
+config = RedisWorkingMemorySessionServiceConfig(
+ api_base_url="http://localhost:8000",
+ default_namespace="my_app",
+)
+session_service = RedisWorkingMemorySessionService(config=config)
+
+# Use with ADK runner
+runner = Runner(
+ agent=agent,
+ session_service=session_service,
+)
+Initialize the Redis Working Memory Session Service.
+ + +Parameters:
+| Name | +Type | +Description | +Default | +
|---|---|---|---|
+ config
+ |
+
+ RedisWorkingMemorySessionServiceConfig | None
+ |
+
+
+
+ Configuration for the service. If None, uses defaults. + |
+
+ None
+ |
+
src/adk_redis/sessions/working_memory.py create_session
+
+
+
+ async
+
+
+¶create_session(*, app_name: str, user_id: str, state: dict[str, Any] | None = None, session_id: str | None = None) -> Session
+Create a new session in Working Memory.
+Uses get_or_create_working_memory to prevent accidental overwrites +of existing sessions.
+ + +Parameters:
+| Name | +Type | +Description | +Default | +
|---|---|---|---|
+ app_name
+ |
+
+ str
+ |
+
+
+
+ Application name (used as namespace if not configured). + |
+ + required + | +
+ user_id
+ |
+
+ str
+ |
+
+
+
+ User identifier. + |
+ + required + | +
+ state
+ |
+
+ dict[str, Any] | None
+ |
+
+
+
+ Initial session state. + |
+
+ None
+ |
+
+ session_id
+ |
+
+ str | None
+ |
+
+
+
+ Optional session ID (generated if not provided). + |
+
+ None
+ |
+
Returns:
+| Type | +Description | +
|---|---|
+ Session
+ |
+
+
+
+ The created Session. + |
+
src/adk_redis/sessions/working_memory.py198 +199 +200 +201 +202 +203 +204 +205 +206 +207 +208 +209 +210 +211 +212 +213 +214 +215 +216 +217 +218 +219 +220 +221 +222 +223 +224 +225 +226 +227 +228 +229 +230 +231 +232 +233 +234 +235 +236 +237 +238 +239 +240 +241 +242 +243 +244 +245 +246 +247 +248 +249 +250 +251 +252 +253 +254 +255 +256 +257 +258 +259 +260 +261 +262 +263 +264 +265 +266 +267 +268 +269 +270 +271 +272 +273 +274 +275 +276 | |
get_session
+
+
+
+ async
+
+
+¶get_session(*, app_name: str, user_id: str, session_id: str, config: GetSessionConfig | None = None) -> Session | None
+Retrieve a session from Working Memory.
+Uses get_or_create_working_memory and checks if session was newly created +to determine if it exists. Passes model_name and context_window_max to +enable automatic context summarization when token limit is exceeded.
+NOTE: For ADK Runner compatibility, this method now returns the session +even if it was just created. The Runner expects get_session to either +return an existing session OR return a newly created empty session. +Returning None causes the Runner to fail with "Session not found".
+ + +Parameters:
+| Name | +Type | +Description | +Default | +
|---|---|---|---|
+ app_name
+ |
+
+ str
+ |
+
+
+
+ Application name. + |
+ + required + | +
+ user_id
+ |
+
+ str
+ |
+
+
+
+ User identifier. + |
+ + required + | +
+ session_id
+ |
+
+ str
+ |
+
+
+
+ Session ID to retrieve. + |
+ + required + | +
+ config
+ |
+
+ GetSessionConfig | None
+ |
+
+
+
+ Optional configuration for filtering events. + |
+
+ None
+ |
+
Returns:
+| Type | +Description | +
|---|---|
+ Session | None
+ |
+
+
+
+ The Session (existing or newly created). + |
+
src/adk_redis/sessions/working_memory.py278 +279 +280 +281 +282 +283 +284 +285 +286 +287 +288 +289 +290 +291 +292 +293 +294 +295 +296 +297 +298 +299 +300 +301 +302 +303 +304 +305 +306 +307 +308 +309 +310 +311 +312 +313 +314 +315 +316 +317 +318 +319 +320 +321 +322 +323 +324 +325 +326 +327 +328 +329 +330 +331 +332 +333 +334 +335 +336 +337 +338 +339 +340 +341 | |
list_sessions
+
+
+
+ async
+
+
+¶List all sessions for a user from Working Memory.
+ + +Parameters:
+| Name | +Type | +Description | +Default | +
|---|---|---|---|
+ app_name
+ |
+
+ str
+ |
+
+
+
+ Application name. + |
+ + required + | +
+ user_id
+ |
+
+ str | None
+ |
+
+
+
+ User identifier (required for this implementation). + |
+
+ None
+ |
+
Returns:
+| Type | +Description | +
|---|---|
+ ListSessionsResponse
+ |
+
+
+
+ ListSessionsResponse containing sessions (without events). + |
+
Raises:
+| Type | +Description | +
|---|---|
+ ValueError
+ |
+
+
+
+ If user_id is not provided. + |
+
src/adk_redis/sessions/working_memory.py delete_session
+
+
+
+ async
+
+
+¶Delete a session from Working Memory.
+ + +Parameters:
+| Name | +Type | +Description | +Default | +
|---|---|---|---|
+ app_name
+ |
+
+ str
+ |
+
+
+
+ Application name. + |
+ + required + | +
+ user_id
+ |
+
+ str
+ |
+
+
+
+ User identifier. + |
+ + required + | +
+ session_id
+ |
+
+ str
+ |
+
+
+
+ Session ID to delete. + |
+ + required + | +
src/adk_redis/sessions/working_memory.py append_event
+
+
+
+ async
+
+
+¶Append an event to the session in Working Memory.
+Uses the incremental append API to add a single message without +resending the full conversation history.
+ + +Parameters:
+| Name | +Type | +Description | +Default | +
|---|---|---|---|
+ session
+ |
+
+ Session
+ |
+
+
+
+ The session to append to. + |
+ + required + | +
+ event
+ |
+
+ Event
+ |
+
+
+
+ The event to append. + |
+ + required + | +
Returns:
+| Type | +Description | +
|---|---|
+ Event
+ |
+
+
+
+ The appended event. + |
+
src/adk_redis/sessions/working_memory.py close
+
+
+
+ async
+
+
+¶ RedisWorkingMemorySessionServiceConfig
+
+
+¶
+ Bases: BaseModel
Configuration for Redis Working Memory Session Service.
+ + +Attributes:
+| Name | +Type | +Description | +
|---|---|---|
api_base_url |
+
+ str
+ |
+
+
+
+ Base URL of the Agent Memory Server. + |
+
timeout |
+
+ float
+ |
+
+
+
+ HTTP request timeout in seconds. + |
+
default_namespace |
+
+ str | None
+ |
+
+
+
+ Default namespace for session operations. + |
+
model_name |
+
+ str | None
+ |
+
+
+
+ Model name for context window management and summarization. + |
+
context_window_max |
+
+ int | None
+ |
+
+
+
+ Maximum context window tokens. + |
+
extraction_strategy |
+
+ Literal['discrete', 'summary', 'preferences', 'custom']
+ |
+
+
+
+ Memory extraction strategy. + |
+
extraction_strategy_config |
+
+ dict[str, Any]
+ |
+
+
+
+ Additional config for extraction strategy. + |
+
session_ttl_seconds |
+
+ int | None
+ |
+
+
+
+ Optional TTL for session expiration. + |
+
tools
+
+
+¶Redis tools for ADK.
+ + + + + + + + + + + CreateMemoryTool
+
+
+¶CreateMemoryTool(*, config: MemoryToolConfig | None = None, name: str = 'create_memory', description: str = 'Creates a new long-term memory. Use this when the user asks you to remember something.')
+
+ Bases: BaseMemoryTool
Tool for creating new long-term memories.
+This tool allows the LLM to explicitly store information in long-term memory. +Use this when the user asks to remember something specific.
+ + +Initialize the Create Memory Tool.
+ + +Parameters:
+| Name | +Type | +Description | +Default | +
|---|---|---|---|
+ config
+ |
+
+ MemoryToolConfig | None
+ |
+
+
+
+ Configuration for the tool. If None, uses defaults. + |
+
+ None
+ |
+
+ name
+ |
+
+ str
+ |
+
+
+
+ The name of the tool (exposed to LLM). + |
+
+ 'create_memory'
+ |
+
+ description
+ |
+
+ str
+ |
+
+
+
+ The description of the tool (exposed to LLM). + |
+
+ 'Creates a new long-term memory. Use this when the user asks you to remember something.'
+ |
+
src/adk_redis/tools/memory/create.py run_async
+
+
+
+ async
+
+
+¶Create a new long-term memory.
+ + +Parameters:
+| Name | +Type | +Description | +Default | +
|---|---|---|---|
+ content
+ |
+ + | +
+
+
+ The content of the memory to store. + |
+ + required + | +
+ topics
+ |
+ + | +
+
+
+ Optional list of topics/tags. + |
+ + required + | +
+ memory_type
+ |
+ + | +
+
+
+ Type of memory (semantic, episodic, message). + |
+ + required + | +
+ namespace
+ |
+ + | +
+
+
+ Optional namespace override. + |
+ + required + | +
+ user_id
+ |
+ + | +
+
+
+ Optional user ID override. + |
+ + required + | +
Returns:
+| Type | +Description | +
|---|---|
+ dict[str, Any]
+ |
+
+
+
+ A dictionary with status and memory_id. + |
+
src/adk_redis/tools/memory/create.py114 +115 +116 +117 +118 +119 +120 +121 +122 +123 +124 +125 +126 +127 +128 +129 +130 +131 +132 +133 +134 +135 +136 +137 +138 +139 +140 +141 +142 +143 +144 +145 +146 +147 +148 +149 +150 +151 +152 +153 +154 +155 +156 +157 +158 +159 +160 +161 +162 +163 +164 +165 +166 +167 +168 +169 +170 +171 +172 +173 +174 +175 +176 +177 +178 +179 +180 +181 +182 +183 +184 +185 +186 +187 +188 +189 | |
DeleteMemoryTool
+
+
+¶DeleteMemoryTool(*, config: MemoryToolConfig | None = None, name: str = 'delete_memory', description: str = 'Deletes one or more long-term memories by ID. Use this when the user asks you to forget something.')
+
+ Bases: BaseMemoryTool
Tool for deleting long-term memories.
+This tool allows the LLM to delete specific memories by ID. +Use this when the user asks to forget something.
+ + +Initialize the Delete Memory Tool.
+ + +Parameters:
+| Name | +Type | +Description | +Default | +
|---|---|---|---|
+ config
+ |
+
+ MemoryToolConfig | None
+ |
+
+
+
+ Configuration for the tool. If None, uses defaults. + |
+
+ None
+ |
+
+ name
+ |
+
+ str
+ |
+
+
+
+ The name of the tool (exposed to LLM). + |
+
+ 'delete_memory'
+ |
+
+ description
+ |
+
+ str
+ |
+
+
+
+ The description of the tool (exposed to LLM). + |
+
+ 'Deletes one or more long-term memories by ID. Use this when the user asks you to forget something.'
+ |
+
src/adk_redis/tools/memory/delete.py run_async
+
+
+
+ async
+
+
+¶Delete long-term memories by ID.
+ + +Parameters:
+| Name | +Type | +Description | +Default | +
|---|---|---|---|
+ memory_ids
+ |
+ + | +
+
+
+ List of memory IDs to delete. + |
+ + required + | +
+ namespace
+ |
+ + | +
+
+
+ Optional namespace override. + |
+ + required + | +
+ user_id
+ |
+ + | +
+
+
+ Optional user ID override. + |
+ + required + | +
Returns:
+| Type | +Description | +
|---|---|
+ dict[str, Any]
+ |
+
+
+
+ A dictionary with status and deleted_count. + |
+
src/adk_redis/tools/memory/delete.py GetMemoryTool
+
+
+¶GetMemoryTool(*, config: MemoryToolConfig | None = None, name: str = 'get_memory', description: str = 'Retrieves a specific long-term memory by its ID. Use this when you need the full details of a known memory.')
+
+ Bases: BaseMemoryTool
Tool for retrieving a specific long-term memory by ID.
+This tool allows the LLM to retrieve a specific memory when it knows +the memory ID. Use this when you need to access the full details of +a memory that was previously found via search.
+ + +Initialize the Get Memory Tool.
+ + +Parameters:
+| Name | +Type | +Description | +Default | +
|---|---|---|---|
+ config
+ |
+
+ MemoryToolConfig | None
+ |
+
+
+
+ Configuration for the tool. If None, uses defaults. + |
+
+ None
+ |
+
+ name
+ |
+
+ str
+ |
+
+
+
+ The name of the tool (exposed to LLM). + |
+
+ 'get_memory'
+ |
+
+ description
+ |
+
+ str
+ |
+
+
+
+ The description of the tool (exposed to LLM). + |
+
+ 'Retrieves a specific long-term memory by its ID. Use this when you need the full details of a known memory.'
+ |
+
src/adk_redis/tools/memory/get.py run_async
+
+
+
+ async
+
+
+¶Retrieve a specific memory by ID.
+ + +Parameters:
+| Name | +Type | +Description | +Default | +
|---|---|---|---|
+ memory_id
+ |
+ + | +
+
+
+ The unique ID of the memory to retrieve. + |
+ + required + | +
Returns:
+| Type | +Description | +
|---|---|
+ dict[str, Any]
+ |
+
+
+
+ A dictionary with status and memory details. + |
+
src/adk_redis/tools/memory/get.py MemoryPromptTool
+
+
+¶MemoryPromptTool(*, config: MemoryToolConfig | None = None, name: str = 'memory_prompt', description: str = 'Enriches a prompt with relevant memories from long-term storage. Use this to provide personalized context based on past interactions.')
+
+ Bases: BaseMemoryTool
Tool for enriching prompts with relevant memories.
+This tool searches long-term memory for relevant context and enriches +a system prompt with the retrieved memories. It's useful for providing +the LLM with personalized context based on past interactions.
+ + +Initialize the Memory Prompt Tool.
+ + +Parameters:
+| Name | +Type | +Description | +Default | +
|---|---|---|---|
+ config
+ |
+
+ MemoryToolConfig | None
+ |
+
+
+
+ Configuration for the tool. If None, uses defaults. + |
+
+ None
+ |
+
+ name
+ |
+
+ str
+ |
+
+
+
+ The name of the tool (exposed to LLM). + |
+
+ 'memory_prompt'
+ |
+
+ description
+ |
+
+ str
+ |
+
+
+
+ The description of the tool (exposed to LLM). + |
+
+ 'Enriches a prompt with relevant memories from long-term storage. Use this to provide personalized context based on past interactions.'
+ |
+
src/adk_redis/tools/memory/prompt.py run_async
+
+
+
+ async
+
+
+¶Enrich a prompt with relevant memories.
+ + +Parameters:
+| Name | +Type | +Description | +Default | +
|---|---|---|---|
+ query
+ |
+ + | +
+
+
+ The query to search for relevant memories. + |
+ + required + | +
+ system_prompt
+ |
+ + | +
+
+
+ Optional base system prompt to enrich. + |
+ + required + | +
+ namespace
+ |
+ + | +
+
+
+ Optional namespace override. + |
+ + required + | +
+ user_id
+ |
+ + | +
+
+
+ Optional user ID override. + |
+ + required + | +
Returns:
+| Type | +Description | +
|---|---|
+ dict[str, Any]
+ |
+
+
+
+ A dictionary with status and enriched_prompt. + |
+
src/adk_redis/tools/memory/prompt.py MemoryToolConfig
+
+
+¶
+ Bases: BaseModel
Shared configuration for all Redis Agent Memory tools.
+This configuration is used by all memory tools to connect to the +Agent Memory Server and manage memory operations.
+ + +Attributes:
+| Name | +Type | +Description | +
|---|---|---|
api_base_url |
+
+ str
+ |
+
+
+
+ Base URL of the Agent Memory Server. + |
+
timeout |
+
+ float
+ |
+
+
+
+ HTTP request timeout in seconds. + |
+
default_namespace |
+
+ str
+ |
+
+
+
+ Default namespace for memory operations. + |
+
default_user_id |
+
+ str | None
+ |
+
+
+
+ Default user ID for memory operations (optional). + |
+
search_top_k |
+
+ int
+ |
+
+
+
+ Default maximum number of memories to retrieve. + |
+
distance_threshold |
+
+ float | None
+ |
+
+
+
+ Maximum distance threshold for search (0.0-1.0). + |
+
recency_boost |
+
+ bool
+ |
+
+
+
+ Enable recency-aware re-ranking of search results. + |
+
semantic_weight |
+
+ float
+ |
+
+
+
+ Weight for semantic similarity (0.0-1.0). + |
+
recency_weight |
+
+ float
+ |
+
+
+
+ Weight for recency score (0.0-1.0). + |
+
freshness_weight |
+
+ float
+ |
+
+
+
+ Weight for freshness within recency score. + |
+
novelty_weight |
+
+ float
+ |
+
+
+
+ Weight for novelty within recency score. + |
+
half_life_last_access_days |
+
+ float
+ |
+
+
+
+ Half-life in days for last_accessed decay. + |
+
half_life_created_days |
+
+ float
+ |
+
+
+
+ Half-life in days for created_at decay. + |
+
deduplicate |
+
+ bool
+ |
+
+
+
+ Enable deduplication when creating memories. + |
+
SearchMemoryTool
+
+
+¶SearchMemoryTool(*, config: MemoryToolConfig | None = None, name: str = 'search_memory', description: str = 'Searches long-term memory for relevant information. Use this to recall facts, preferences, or past interactions.')
+
+ Bases: BaseMemoryTool
Tool for searching long-term memories.
+This tool performs semantic search against long-term memory with optional +recency boosting. Use this when the LLM needs to recall specific information +from past interactions.
+ + +from adk_redis.tools.memory import SearchMemoryTool, MemoryToolConfig
+
+config = MemoryToolConfig(
+ api_base_url="http://localhost:8000",
+ default_namespace="my_app",
+ recency_boost=True,
+)
+tool = SearchMemoryTool(config=config)
+
+# Use with ADK agent
+agent = Agent(
+ name="my_agent",
+ tools=[tool],
+)
+Initialize the Search Memory Tool.
+ + +Parameters:
+| Name | +Type | +Description | +Default | +
|---|---|---|---|
+ config
+ |
+
+ MemoryToolConfig | None
+ |
+
+
+
+ Configuration for the tool. If None, uses defaults. + |
+
+ None
+ |
+
+ name
+ |
+
+ str
+ |
+
+
+
+ The name of the tool (exposed to LLM). + |
+
+ 'search_memory'
+ |
+
+ description
+ |
+
+ str
+ |
+
+
+
+ The description of the tool (exposed to LLM). + |
+
+ 'Searches long-term memory for relevant information. Use this to recall facts, preferences, or past interactions.'
+ |
+
src/adk_redis/tools/memory/search.py run_async
+
+
+
+ async
+
+
+¶Search for relevant memories.
+ + +Parameters:
+| Name | +Type | +Description | +Default | +
|---|---|---|---|
+ query
+ |
+ + | +
+
+
+ The search query. + |
+ + required + | +
+ limit
+ |
+ + | +
+
+
+ Maximum number of memories to return. + |
+ + required + | +
+ namespace
+ |
+ + | +
+
+
+ Optional namespace override. + |
+ + required + | +
+ user_id
+ |
+ + | +
+
+
+ Optional user ID override. + |
+ + required + | +
Returns:
+| Type | +Description | +
|---|---|
+ dict[str, Any]
+ |
+
+
+
+ A dictionary with status and list of memories. + |
+
src/adk_redis/tools/memory/search.py108 +109 +110 +111 +112 +113 +114 +115 +116 +117 +118 +119 +120 +121 +122 +123 +124 +125 +126 +127 +128 +129 +130 +131 +132 +133 +134 +135 +136 +137 +138 +139 +140 +141 +142 +143 +144 +145 +146 +147 +148 +149 +150 +151 +152 +153 +154 +155 +156 +157 +158 +159 +160 +161 +162 +163 +164 +165 +166 +167 +168 +169 +170 +171 +172 +173 +174 | |
UpdateMemoryTool
+
+
+¶UpdateMemoryTool(*, config: MemoryToolConfig | None = None, name: str = 'update_memory', description: str = 'Updates an existing long-term memory. Use this when the user asks to modify or correct stored information.')
+
+ Bases: BaseMemoryTool
Tool for updating existing long-term memories.
+This tool allows the LLM to modify the content or metadata of existing memories. +Use this when the user asks to update or correct previously stored information.
+ + +Initialize the Update Memory Tool.
+ + +Parameters:
+| Name | +Type | +Description | +Default | +
|---|---|---|---|
+ config
+ |
+
+ MemoryToolConfig | None
+ |
+
+
+
+ Configuration for the tool. If None, uses defaults. + |
+
+ None
+ |
+
+ name
+ |
+
+ str
+ |
+
+
+
+ The name of the tool (exposed to LLM). + |
+
+ 'update_memory'
+ |
+
+ description
+ |
+
+ str
+ |
+
+
+
+ The description of the tool (exposed to LLM). + |
+
+ 'Updates an existing long-term memory. Use this when the user asks to modify or correct stored information.'
+ |
+
src/adk_redis/tools/memory/update.py run_async
+
+
+
+ async
+
+
+¶Update an existing long-term memory.
+ + +Parameters:
+| Name | +Type | +Description | +Default | +
|---|---|---|---|
+ memory_id
+ |
+ + | +
+
+
+ The ID of the memory to update. + |
+ + required + | +
+ content
+ |
+ + | +
+
+
+ New content for the memory. + |
+ + required + | +
+ topics
+ |
+ + | +
+
+
+ New list of topics/tags. + |
+ + required + | +
+ namespace
+ |
+ + | +
+
+
+ Optional namespace override. + |
+ + required + | +
+ user_id
+ |
+ + | +
+
+
+ Optional user ID override. + |
+ + required + | +
Returns:
+| Type | +Description | +
|---|---|
+ dict[str, Any]
+ |
+
+
+
+ A dictionary with status and updated memory info. + |
+
src/adk_redis/tools/memory/update.py BaseRedisSearchTool
+
+
+¶BaseRedisSearchTool(*, name: str, description: str, index: SearchIndex | AsyncSearchIndex, return_fields: list[str] | None = None)
+
+ Bases: BaseTool
Base class for ALL Redis search tools using RedisVL.
+This class provides common functionality shared by all Redis search tools: +- Index management (sync and async) +- Query execution with proper async handling +- Standard response formatting +- Error handling
+Subclasses should use _run_search to execute queries with consistent
+error handling and response formatting.
Initialize the base Redis search tool.
+ + +Parameters:
+| Name | +Type | +Description | +Default | +
|---|---|---|---|
+ name
+ |
+
+ str
+ |
+
+
+
+ The name of the tool (exposed to LLM). + |
+ + required + | +
+ description
+ |
+
+ str
+ |
+
+
+
+ The description of the tool (exposed to LLM). + |
+ + required + | +
+ index
+ |
+
+ SearchIndex | AsyncSearchIndex
+ |
+
+
+
+ The RedisVL SearchIndex or AsyncSearchIndex to query. + |
+ + required + | +
+ return_fields
+ |
+
+ list[str] | None
+ |
+
+
+
+ Optional list of fields to return in results. + |
+
+ None
+ |
+
src/adk_redis/tools/search/_base.py RedisAggregatedHybridQueryConfig
+
+
+¶
+ Bases: BaseModel
Configuration for aggregated (client-side) Redis hybrid search queries.
+.. deprecated:: + This config is for older Redis/RedisVL versions. For newer setups + (RedisVL >= 0.13.0, Redis >= 8.4.0), prefer RedisHybridQueryConfig + which uses native server-side hybrid search for better performance.
+This config uses AggregateHybridQuery which performs client-side hybrid +search using FT.AGGREGATE with weighted score combination. It works with +any Redis version that has RediSearch installed.
+ + +Attributes:
+| Name | +Type | +Description | +
|---|---|---|
text_field_name |
+
+ str
+ |
+
+
+
+ Name of the text field for BM25 search. + |
+
vector_field_name |
+
+ str
+ |
+
+
+
+ Name of the vector field for similarity search. + |
+
text_scorer |
+
+ str
+ |
+
+
+
+ Text scoring algorithm (default: "BM25STD"). + |
+
alpha |
+
+ float
+ |
+
+
+
+ Weight for text score (default: 0.7). Higher values favor +text matching over vector similarity. Combined score is: +alpha * text_score + (1 - alpha) * vector_score + |
+
num_results |
+
+ int
+ |
+
+
+
+ Number of results to return. + |
+
dtype |
+
+ str
+ |
+
+
+
+ Data type of the vector. + |
+
stopwords |
+
+ str | set[str] | None
+ |
+
+
+
+ Stopwords to remove from query. + |
+
dialect |
+
+ int
+ |
+
+
+
+ RediSearch query dialect version. + |
+
text_weights |
+
+ dict[str, float] | None
+ |
+
+
+
+ Optional field weights for text scoring. + |
+
to_query_kwargs
+
+
+¶to_query_kwargs(text: str, vector: list[float], return_fields: list[str] | None = None, filter_expression: Any | None = None) -> dict[str, Any]
+Convert config to AggregateHybridQuery kwargs.
+ + +Parameters:
+| Name | +Type | +Description | +Default | +
|---|---|---|---|
+ text
+ |
+
+ str
+ |
+
+
+
+ The query text for BM25 matching. + |
+ + required + | +
+ vector
+ |
+
+ list[float]
+ |
+
+
+
+ The query vector embedding. + |
+ + required + | +
+ return_fields
+ |
+
+ list[str] | None
+ |
+
+
+
+ Optional list of fields to return. + |
+
+ None
+ |
+
+ filter_expression
+ |
+
+ Any | None
+ |
+
+
+
+ Optional filter expression to apply. + |
+
+ None
+ |
+
Returns:
+| Type | +Description | +
|---|---|
+ dict[str, Any]
+ |
+
+
+
+ Dictionary of kwargs suitable for AggregateHybridQuery constructor. + |
+
src/adk_redis/tools/search/_config.py RedisHybridQueryConfig
+
+
+¶
+ Bases: BaseModel
Configuration for native Redis hybrid search queries.
+Uses Redis's native FT.HYBRID command for server-side hybrid search +combining semantic vector similarity with keyword-based BM25 text matching.
+ + +For older Redis/RedisVL versions, use RedisAggregatedHybridQueryConfig instead.
+ + +from adk_redis import (
+ RedisHybridSearchTool,
+ RedisHybridQueryConfig,
+)
+
+config = RedisHybridQueryConfig(
+ text_field_name="content",
+ combination_method="LINEAR",
+ linear_alpha=0.7, # 70% text, 30% vector
+)
+tool = RedisHybridSearchTool(index=index, vectorizer=vectorizer, config=config)
+Attributes:
+| Name | +Type | +Description | +
|---|---|---|
text_field_name |
+
+ str
+ |
+
+
+
+ Name of the text field for BM25 search. + |
+
vector_field_name |
+
+ str
+ |
+
+
+
+ Name of the vector field for similarity search. + |
+
vector_param_name |
+
+ str
+ |
+
+
+
+ Name of the parameter substitution for vector blob. + |
+
text_scorer |
+
+ str
+ |
+
+
+
+ Text scoring algorithm (default: "BM25STD"). + |
+
yield_text_score_as |
+
+ str | None
+ |
+
+
+
+ Field name to yield the text score as. + |
+
vector_search_method |
+
+ str | None
+ |
+
+
+
+ Vector search method - "KNN" or "RANGE". + |
+
knn_ef_runtime |
+
+ int
+ |
+
+
+
+ Exploration factor for HNSW when using KNN. + |
+
range_radius |
+
+ float | None
+ |
+
+
+
+ Search radius when using RANGE vector search. + |
+
range_epsilon |
+
+ float
+ |
+
+
+
+ Epsilon for RANGE search accuracy. + |
+
yield_vsim_score_as |
+
+ str | None
+ |
+
+
+
+ Field name to yield vector similarity score as. + |
+
combination_method |
+
+ str | None
+ |
+
+
+
+ Score combination method - "RRF" or "LINEAR". + |
+
linear_alpha |
+
+ float
+ |
+
+
+
+ Weight of text score when using LINEAR (0.0-1.0). + |
+
rrf_window |
+
+ int
+ |
+
+
+
+ Window size for RRF combination. + |
+
rrf_constant |
+
+ int
+ |
+
+
+
+ Constant for RRF combination. + |
+
yield_combined_score_as |
+
+ str | None
+ |
+
+
+
+ Field name to yield combined score as. + |
+
num_results |
+
+ int
+ |
+
+
+
+ Number of results to return. + |
+
dtype |
+
+ str
+ |
+
+
+
+ Data type of the vector. + |
+
stopwords |
+
+ str | set[str] | None
+ |
+
+
+
+ Stopwords to remove from query. + |
+
text_weights |
+
+ dict[str, float] | None
+ |
+
+
+
+ Optional field weights for text scoring. + |
+
to_query_kwargs
+
+
+¶to_query_kwargs(text: str, vector: list[float], return_fields: list[str] | None = None, filter_expression: Any | None = None) -> dict[str, Any]
+Convert config to native HybridQuery kwargs.
+ + +Parameters:
+| Name | +Type | +Description | +Default | +
|---|---|---|---|
+ text
+ |
+
+ str
+ |
+
+
+
+ The query text for BM25 matching. + |
+ + required + | +
+ vector
+ |
+
+ list[float]
+ |
+
+
+
+ The query vector embedding. + |
+ + required + | +
+ return_fields
+ |
+
+ list[str] | None
+ |
+
+
+
+ Optional list of fields to return. + |
+
+ None
+ |
+
+ filter_expression
+ |
+
+ Any | None
+ |
+
+
+
+ Optional filter expression to apply. + |
+
+ None
+ |
+
Returns:
+| Type | +Description | +
|---|---|
+ dict[str, Any]
+ |
+
+
+
+ Dictionary of kwargs suitable for HybridQuery constructor. + |
+
src/adk_redis/tools/search/_config.py RedisHybridSearchTool
+
+
+¶RedisHybridSearchTool(*, index: SearchIndex | AsyncSearchIndex, vectorizer: BaseVectorizer, config: RedisHybridQueryConfig | RedisAggregatedHybridQueryConfig | None = None, return_fields: list[str] | None = None, filter_expression: Any | None = None, name: str = 'redis_hybrid_search', description: str = 'Search using both semantic similarity and keyword matching.')
+
+ Bases: VectorizedSearchTool
Hybrid search tool combining vector similarity and BM25 text search.
+This tool performs a hybrid search that combines semantic vector similarity +with keyword-based BM25 text matching. It automatically detects the installed +RedisVL version and uses the appropriate implementation:
+Example (native mode - RedisVL >= 0.13.0): +
from adk_redis import (
+ RedisHybridSearchTool,
+ RedisHybridQueryConfig,
+)
+
+config = RedisHybridQueryConfig(
+ text_field_name="content",
+ combination_method="LINEAR",
+ linear_alpha=0.7, # 70% text, 30% vector
+)
+tool = RedisHybridSearchTool(
+ index=index,
+ vectorizer=vectorizer,
+ config=config,
+)
+Example (aggregate mode - older versions): +
from adk_redis import (
+ RedisHybridSearchTool,
+ RedisAggregatedHybridQueryConfig,
+)
+
+config = RedisAggregatedHybridQueryConfig(
+ text_field_name="content",
+ alpha=0.7, # 70% text, 30% vector
+)
+tool = RedisHybridSearchTool(
+ index=index,
+ vectorizer=vectorizer,
+ config=config,
+)
+Initialize the hybrid search tool.
+ + +Parameters:
+| Name | +Type | +Description | +Default | +
|---|---|---|---|
+ index
+ |
+
+ SearchIndex | AsyncSearchIndex
+ |
+
+
+
+ The RedisVL SearchIndex or AsyncSearchIndex to query. + |
+ + required + | +
+ vectorizer
+ |
+
+ BaseVectorizer
+ |
+
+
+
+ The vectorizer for embedding queries. + |
+ + required + | +
+ config
+ |
+
+ RedisHybridQueryConfig | RedisAggregatedHybridQueryConfig | None
+ |
+
+
+
+ Configuration for query parameters. Can be either: +- RedisHybridQueryConfig: For native FT.HYBRID (RedisVL >= 0.13.0) +- RedisAggregatedHybridQueryConfig: For client-side hybrid (older) +If None, auto-detects based on installed RedisVL version. + |
+
+ None
+ |
+
+ return_fields
+ |
+
+ list[str] | None
+ |
+
+
+
+ Optional list of fields to return in results. + |
+
+ None
+ |
+
+ filter_expression
+ |
+
+ Any | None
+ |
+
+
+
+ Optional filter expression to narrow results. + |
+
+ None
+ |
+
+ name
+ |
+
+ str
+ |
+
+
+
+ The name of the tool (exposed to LLM). + |
+
+ 'redis_hybrid_search'
+ |
+
+ description
+ |
+
+ str
+ |
+
+
+
+ The description of the tool (exposed to LLM). + |
+
+ 'Search using both semantic similarity and keyword matching.'
+ |
+
Raises:
+| Type | +Description | +
|---|---|
+ ValueError
+ |
+
+
+
+ If RedisHybridQueryConfig is used with RedisVL < 0.13.0. + |
+
Warns:
+| Type | +Description | +
|---|---|
+ DeprecationWarning
+ |
+
+
+
+ If RedisAggregatedHybridQueryConfig is used when +native hybrid is available (RedisVL >= 0.13.0). + |
+
src/adk_redis/tools/search/hybrid.py207 +208 +209 +210 +211 +212 +213 +214 +215 +216 +217 +218 +219 +220 +221 +222 +223 +224 +225 +226 +227 +228 +229 +230 +231 +232 +233 +234 +235 +236 +237 +238 +239 +240 +241 +242 +243 +244 +245 +246 +247 +248 +249 +250 +251 +252 +253 +254 +255 +256 +257 +258 +259 +260 +261 +262 +263 +264 +265 +266 +267 +268 +269 +270 +271 +272 +273 +274 +275 +276 +277 +278 +279 +280 | |
run_async
+
+
+
+ async
+
+
+¶Execute the vector-based search query.
+ + +Parameters:
+| Name | +Type | +Description | +Default | +
|---|---|---|---|
+ args
+ |
+
+ dict[str, Any]
+ |
+
+
+
+ Arguments from the LLM, must include 'query'. + |
+ + required + | +
+ tool_context
+ |
+
+ ToolContext
+ |
+
+
+
+ The tool execution context. + |
+ + required + | +
Returns:
+| Type | +Description | +
|---|---|
+ dict[str, Any]
+ |
+
+
+
+ A dictionary with status, count, and results. + |
+
src/adk_redis/tools/search/_base.py RedisRangeQueryConfig
+
+
+¶
+ Bases: BaseModel
Configuration for Redis vector range search queries.
+Range search finds all documents within a specified distance threshold +from the query vector, rather than returning a fixed number of results.
+ + +Attributes:
+| Name | +Type | +Description | +
|---|---|---|
vector_field_name |
+
+ str
+ |
+
+
+
+ Name of the vector field in the index. + |
+
distance_threshold |
+
+ float
+ |
+
+
+
+ Maximum distance for results (default: 0.2). + |
+
num_results |
+
+ int
+ |
+
+
+
+ Maximum number of results to return. + |
+
dtype |
+
+ str
+ |
+
+
+
+ Data type of the vector (default: "float32"). + |
+
return_score |
+
+ bool
+ |
+
+
+
+ Whether to return vector distance scores. + |
+
dialect |
+
+ int
+ |
+
+
+
+ RediSearch query dialect version. + |
+
sort_by |
+
+ SortSpec
+ |
+
+
+
+ Field(s) to order results by. + |
+
in_order |
+
+ bool
+ |
+
+
+
+ Require query terms in same order as document. + |
+
normalize_vector_distance |
+
+ bool
+ |
+
+
+
+ Convert distance to 0-1 similarity score. + |
+
epsilon |
+
+ float | None
+ |
+
+
+
+ Range search approximation factor for HNSW/SVS-VAMANA. + |
+
to_query_kwargs
+
+
+¶Convert config to VectorRangeQuery kwargs.
+ + +Parameters:
+| Name | +Type | +Description | +Default | +
|---|---|---|---|
+ vector
+ |
+
+ list[float]
+ |
+
+
+
+ The query vector embedding. + |
+ + required + | +
+ filter_expression
+ |
+
+ Any | None
+ |
+
+
+
+ Optional filter expression to apply. + |
+
+ None
+ |
+
Returns:
+| Type | +Description | +
|---|---|
+ dict[str, Any]
+ |
+
+
+
+ Dictionary of kwargs suitable for VectorRangeQuery constructor. + |
+
src/adk_redis/tools/search/_config.py RedisRangeSearchTool
+
+
+¶RedisRangeSearchTool(*, index: SearchIndex | AsyncSearchIndex, vectorizer: BaseVectorizer, config: RedisRangeQueryConfig | None = None, return_fields: list[str] | None = None, filter_expression: Any | None = None, name: str = 'redis_range_search', description: str = 'Find all documents within a similarity threshold.')
+
+ Bases: VectorizedSearchTool
Vector range search tool using distance threshold.
+This tool finds all documents within a specified distance threshold +from the query vector. Unlike KNN search which returns a fixed number +of results, range search returns all documents that are "close enough" +based on the threshold.
+ + +from redisvl.index import SearchIndex
+from redisvl.utils.vectorize import HFTextVectorizer
+from adk_redis import (
+ RedisRangeSearchTool,
+ RedisRangeQueryConfig,
+)
+
+index = SearchIndex.from_yaml("schema.yaml")
+vectorizer = HFTextVectorizer(model="redis/langcache-embed-v2")
+
+# Using config object (recommended)
+config = RedisRangeQueryConfig(
+ distance_threshold=0.3, # Only return docs within 0.3 distance
+)
+tool = RedisRangeSearchTool(
+ index=index,
+ vectorizer=vectorizer,
+ config=config,
+ return_fields=["title", "content"],
+)
+
+agent = Agent(model="gemini-2.5-flash", tools=[tool])
+Initialize the range search tool.
+ + +Parameters:
+| Name | +Type | +Description | +Default | +
|---|---|---|---|
+ index
+ |
+
+ SearchIndex | AsyncSearchIndex
+ |
+
+
+
+ The RedisVL SearchIndex or AsyncSearchIndex to query. + |
+ + required + | +
+ vectorizer
+ |
+
+ BaseVectorizer
+ |
+
+
+
+ The vectorizer for embedding queries. + |
+ + required + | +
+ config
+ |
+
+ RedisRangeQueryConfig | None
+ |
+
+
+
+ Configuration for query parameters. If None, uses defaults. +See RedisRangeQueryConfig for available options including +distance_threshold, vector_field_name, and epsilon. + |
+
+ None
+ |
+
+ return_fields
+ |
+
+ list[str] | None
+ |
+
+
+
+ Optional list of fields to return in results. + |
+
+ None
+ |
+
+ filter_expression
+ |
+
+ Any | None
+ |
+
+
+
+ Optional filter expression to narrow results. + |
+
+ None
+ |
+
+ name
+ |
+
+ str
+ |
+
+
+
+ The name of the tool (exposed to LLM). + |
+
+ 'redis_range_search'
+ |
+
+ description
+ |
+
+ str
+ |
+
+
+
+ The description of the tool (exposed to LLM). + |
+
+ 'Find all documents within a similarity threshold.'
+ |
+
src/adk_redis/tools/search/range.py run_async
+
+
+
+ async
+
+
+¶Execute the vector-based search query.
+ + +Parameters:
+| Name | +Type | +Description | +Default | +
|---|---|---|---|
+ args
+ |
+
+ dict[str, Any]
+ |
+
+
+
+ Arguments from the LLM, must include 'query'. + |
+ + required + | +
+ tool_context
+ |
+
+ ToolContext
+ |
+
+
+
+ The tool execution context. + |
+ + required + | +
Returns:
+| Type | +Description | +
|---|---|
+ dict[str, Any]
+ |
+
+
+
+ A dictionary with status, count, and results. + |
+
src/adk_redis/tools/search/_base.py RedisSQLSearchTool
+
+
+¶RedisSQLSearchTool(*, index: SearchIndex | AsyncSearchIndex, sql_redis_options: dict[str, Any] | None = None, return_fields: list[str] | None = None, name: str = 'redis_sql_search', description: str = _DEFAULT_DESCRIPTION)
+
+ Bases: BaseRedisSearchTool
Search tool that lets the LLM issue SQL SELECT statements.
+Wraps redisvl.query.SQLQuery, which translates SQL into Redis
+FT.SEARCH / FT.AGGREGATE commands via the optional sql-redis
+extra. Use this when an agent benefits from expressing filters and
+projections directly in SQL rather than configuring query parameters
+field by field.
Requires the sql-redis optional dependency. Install with
+pip install 'adk-redis[sql]'.
Initialize the SQL search tool.
+ + +Parameters:
+| Name | +Type | +Description | +Default | +
|---|---|---|---|
+ index
+ |
+
+ SearchIndex | AsyncSearchIndex
+ |
+
+
+
+ The RedisVL SearchIndex or AsyncSearchIndex to query. + |
+ + required + | +
+ sql_redis_options
+ |
+
+ dict[str, Any] | None
+ |
+
+
+
+ Optional passthrough options forwarded to the
+sql-redis executor. For example, |
+
+ None
+ |
+
+ return_fields
+ |
+
+ list[str] | None
+ |
+
+
+
+ Ignored. SQL SELECT clauses already specify the +projection. Accepted for API symmetry with sibling tools. + |
+
+ None
+ |
+
+ name
+ |
+
+ str
+ |
+
+
+
+ The name of the tool (exposed to LLM). + |
+
+ 'redis_sql_search'
+ |
+
+ description
+ |
+
+ str
+ |
+
+
+
+ The description of the tool (exposed to LLM). + |
+
+ _DEFAULT_DESCRIPTION
+ |
+
src/adk_redis/tools/search/sql.py run_async
+
+
+
+ async
+
+
+¶Execute the SQL query.
+ + +Parameters:
+| Name | +Type | +Description | +Default | +
|---|---|---|---|
+ args
+ |
+
+ dict[str, Any]
+ |
+
+
+
+ Arguments from the LLM. Must include |
+ + required + | +
+ tool_context
+ |
+
+ ToolContext
+ |
+
+
+
+ The tool execution context. + |
+ + required + | +
Returns:
+| Type | +Description | +
|---|---|
+ dict[str, Any]
+ |
+
+
+
+ Dictionary with status, count, and results (or error). + |
+
src/adk_redis/tools/search/sql.py RedisTextQueryConfig
+
+
+¶
+ Bases: BaseModel
Configuration for Redis full-text search queries.
+This config groups all query-specific parameters for TextQuery, +using BM25 scoring for keyword-based search.
+ + +Attributes:
+| Name | +Type | +Description | +
|---|---|---|
text_field_name |
+
+ str
+ |
+
+
+
+ Name of the text field to search. + |
+
text_scorer |
+
+ str
+ |
+
+
+
+ Text scoring algorithm (default: "BM25STD"). + |
+
num_results |
+
+ int
+ |
+
+
+
+ Number of results to return (default: 10). + |
+
return_score |
+
+ bool
+ |
+
+
+
+ Whether to return the text score. + |
+
dialect |
+
+ int
+ |
+
+
+
+ RediSearch query dialect version. + |
+
sort_by |
+
+ SortSpec
+ |
+
+
+
+ Field(s) to order results by. + |
+
in_order |
+
+ bool
+ |
+
+
+
+ Require query terms in same order as document. + |
+
stopwords |
+
+ str | set[str] | None
+ |
+
+
+
+ Stopwords to remove from query (default: "english"). + |
+
to_query_kwargs
+
+
+¶to_query_kwargs(text: str, return_fields: list[str] | None = None, filter_expression: Any | None = None) -> dict[str, Any]
+Convert config to TextQuery kwargs.
+ + +Parameters:
+| Name | +Type | +Description | +Default | +
|---|---|---|---|
+ text
+ |
+
+ str
+ |
+
+
+
+ The query text for BM25 matching. + |
+ + required + | +
+ return_fields
+ |
+
+ list[str] | None
+ |
+
+
+
+ Optional list of fields to return. + |
+
+ None
+ |
+
+ filter_expression
+ |
+
+ Any | None
+ |
+
+
+
+ Optional filter expression to apply. + |
+
+ None
+ |
+
Returns:
+| Type | +Description | +
|---|---|
+ dict[str, Any]
+ |
+
+
+
+ Dictionary of kwargs suitable for TextQuery constructor. + |
+
src/adk_redis/tools/search/_config.py RedisTextSearchTool
+
+
+¶RedisTextSearchTool(*, index: SearchIndex | AsyncSearchIndex, config: RedisTextQueryConfig | None = None, return_fields: list[str] | None = None, filter_expression: Any | None = None, name: str = 'redis_text_search', description: str = 'Search for documents using keyword matching.')
+
+ Bases: BaseRedisSearchTool
Full-text search tool using BM25 scoring.
+This tool performs keyword-based full-text search using BM25 scoring. +Unlike vector search, it doesn't require embeddings - it matches +documents based on keyword relevance.
+ + +from redisvl.index import SearchIndex
+from adk_redis import (
+ RedisTextSearchTool,
+ RedisTextQueryConfig,
+)
+
+index = SearchIndex.from_yaml("schema.yaml")
+
+# Using config object (recommended)
+config = RedisTextQueryConfig(
+ text_field_name="content",
+ num_results=10,
+ text_scorer="BM25STD",
+)
+tool = RedisTextSearchTool(
+ index=index,
+ config=config,
+ return_fields=["title", "content"],
+)
+
+agent = Agent(model="gemini-2.5-flash", tools=[tool])
+Initialize the text search tool.
+ + +Parameters:
+| Name | +Type | +Description | +Default | +
|---|---|---|---|
+ index
+ |
+
+ SearchIndex | AsyncSearchIndex
+ |
+
+
+
+ The RedisVL SearchIndex or AsyncSearchIndex to query. + |
+ + required + | +
+ config
+ |
+
+ RedisTextQueryConfig | None
+ |
+
+
+
+ Configuration for text query parameters. If not provided, +defaults will be used. + |
+
+ None
+ |
+
+ return_fields
+ |
+
+ list[str] | None
+ |
+
+
+
+ Optional list of fields to return in results. + |
+
+ None
+ |
+
+ filter_expression
+ |
+
+ Any | None
+ |
+
+
+
+ Optional filter expression to narrow results. + |
+
+ None
+ |
+
+ name
+ |
+
+ str
+ |
+
+
+
+ The name of the tool (exposed to LLM). + |
+
+ 'redis_text_search'
+ |
+
+ description
+ |
+
+ str
+ |
+
+
+
+ The description of the tool (exposed to LLM). + |
+
+ 'Search for documents using keyword matching.'
+ |
+
src/adk_redis/tools/search/text.py run_async
+
+
+
+ async
+
+
+¶Execute the text search query.
+ + +Parameters:
+| Name | +Type | +Description | +Default | +
|---|---|---|---|
+ args
+ |
+
+ dict[str, Any]
+ |
+
+
+
+ Arguments from the LLM, must include 'query'. + |
+ + required + | +
+ tool_context
+ |
+
+ ToolContext
+ |
+
+
+
+ The tool execution context. + |
+ + required + | +
Returns:
+| Type | +Description | +
|---|---|
+ dict[str, Any]
+ |
+
+
+
+ A dictionary with status, count, and results. + |
+
src/adk_redis/tools/search/text.py RedisVectorQueryConfig
+
+
+¶
+ Bases: BaseModel
Configuration for Redis vector similarity search queries.
+This config groups all query-specific parameters for VectorQuery, +separating them from tool-level concerns like index and vectorizer.
+ + +Attributes:
+| Name | +Type | +Description | +
|---|---|---|
vector_field_name |
+
+ str
+ |
+
+
+
+ Name of the vector field in the index. + |
+
num_results |
+
+ int
+ |
+
+
+
+ Number of results to return (default: 10). + |
+
dtype |
+
+ str
+ |
+
+
+
+ Data type of the vector (default: "float32"). + |
+
return_score |
+
+ bool
+ |
+
+
+
+ Whether to return vector distance scores. + |
+
dialect |
+
+ int
+ |
+
+
+
+ RediSearch query dialect version. + |
+
sort_by |
+
+ SortSpec
+ |
+
+
+
+ Field(s) to order results by. + |
+
in_order |
+
+ bool
+ |
+
+
+
+ Require query terms in same order as document. + |
+
normalize_vector_distance |
+
+ bool
+ |
+
+
+
+ Convert distance to 0-1 similarity score. + |
+
hybrid_policy |
+
+ str | None
+ |
+
+
+
+ Filter application policy - "BATCHES" or "ADHOC_BF". + |
+
batch_size |
+
+ int | None
+ |
+
+
+
+ Batch size when hybrid_policy is "BATCHES". + |
+
ef_runtime |
+
+ int | None
+ |
+
+
+
+ HNSW exploration factor at query time. + |
+
search_window_size |
+
+ int | None
+ |
+
+
+
+ SVS-VAMANA search window size. + |
+
use_search_history |
+
+ str | None
+ |
+
+
+
+ SVS-VAMANA history mode - "OFF", "ON", or "AUTO". + |
+
search_buffer_capacity |
+
+ int | None
+ |
+
+
+
+ SVS-VAMANA 2-level compression tuning. + |
+
to_query_kwargs
+
+
+¶Convert config to VectorQuery kwargs, excluding None version-dependent params.
+ + +Parameters:
+| Name | +Type | +Description | +Default | +
|---|---|---|---|
+ vector
+ |
+
+ list[float]
+ |
+
+
+
+ The query vector embedding. + |
+ + required + | +
+ filter_expression
+ |
+
+ Any | None
+ |
+
+
+
+ Optional filter expression to apply. + |
+
+ None
+ |
+
Returns:
+| Type | +Description | +
|---|---|
+ dict[str, Any]
+ |
+
+
+
+ Dictionary of kwargs suitable for VectorQuery constructor. + |
+
src/adk_redis/tools/search/_config.py RedisVectorSearchTool
+
+
+¶RedisVectorSearchTool(*, index: SearchIndex | AsyncSearchIndex, vectorizer: BaseVectorizer, config: RedisVectorQueryConfig | None = None, return_fields: list[str] | None = None, filter_expression: Any | None = None, name: str = 'redis_vector_search', description: str = 'Search for semantically similar documents using vector similarity with Redis.')
+
+ Bases: VectorizedSearchTool
Vector similarity search tool using RedisVL.
+This tool performs K-nearest neighbor (KNN) vector similarity search +over a Redis index. It embeds the query text using the provided +vectorizer and finds the most similar documents.
+ + +from redisvl.index import SearchIndex
+from redisvl.utils.vectorize import HFTextVectorizer
+from redisvl.query.filter import Tag
+from adk_redis import (
+ RedisVectorSearchTool,
+ RedisVectorQueryConfig,
+)
+
+index = SearchIndex.from_yaml("schema.yaml")
+vectorizer = HFTextVectorizer(model="redis/langcache-embed-v2")
+
+# Using config object (recommended)
+config = RedisVectorQueryConfig(
+ num_results=5,
+ ef_runtime=100, # Higher = better recall
+)
+tool = RedisVectorSearchTool(
+ index=index,
+ vectorizer=vectorizer,
+ config=config,
+ return_fields=["title", "content", "url"],
+ filter_expression=Tag("category") == "redis",
+)
+
+# Use with an agent
+agent = Agent(model="gemini-2.5-flash", tools=[tool])
+Initialize the vector search tool.
+ + +Parameters:
+| Name | +Type | +Description | +Default | +
|---|---|---|---|
+ index
+ |
+
+ SearchIndex | AsyncSearchIndex
+ |
+
+
+
+ The RedisVL SearchIndex to query. + |
+ + required + | +
+ vectorizer
+ |
+
+ BaseVectorizer
+ |
+
+
+
+ The vectorizer for embedding queries. + |
+ + required + | +
+ config
+ |
+
+ RedisVectorQueryConfig | None
+ |
+
+
+
+ Configuration for query parameters. If None, uses defaults. +See RedisVectorQueryConfig for available options including +num_results, vector_field_name, dtype, and version-dependent +parameters like ef_runtime and hybrid_policy. + |
+
+ None
+ |
+
+ return_fields
+ |
+
+ list[str] | None
+ |
+
+
+
+ Optional list of fields to return in results. + |
+
+ None
+ |
+
+ filter_expression
+ |
+
+ Any | None
+ |
+
+
+
+ Optional RedisVL FilterExpression to narrow results. + |
+
+ None
+ |
+
+ name
+ |
+
+ str
+ |
+
+
+
+ The name of the tool (exposed to LLM). + |
+
+ 'redis_vector_search'
+ |
+
+ description
+ |
+
+ str
+ |
+
+
+
+ The description of the tool (exposed to LLM). + |
+
+ 'Search for semantically similar documents using vector similarity with Redis.'
+ |
+
src/adk_redis/tools/search/vector.py run_async
+
+
+
+ async
+
+
+¶Execute the vector-based search query.
+ + +Parameters:
+| Name | +Type | +Description | +Default | +
|---|---|---|---|
+ args
+ |
+
+ dict[str, Any]
+ |
+
+
+
+ Arguments from the LLM, must include 'query'. + |
+ + required + | +
+ tool_context
+ |
+
+ ToolContext
+ |
+
+
+
+ The tool execution context. + |
+ + required + | +
Returns:
+| Type | +Description | +
|---|---|
+ dict[str, Any]
+ |
+
+
+
+ A dictionary with status, count, and results. + |
+
src/adk_redis/tools/search/_base.py VectorizedSearchTool
+
+
+¶VectorizedSearchTool(*, name: str, description: str, index: SearchIndex | AsyncSearchIndex, vectorizer: BaseVectorizer, return_fields: list[str] | None = None)
+
+ Bases: BaseRedisSearchTool
Base class for Redis search tools that require vector embeddings.
+This class extends BaseRedisSearchTool with: +- Required vectorizer for embedding queries +- Abstract _build_query method for subclasses to implement
+Use this as the base class for vector-based search tools like +VectorSearchTool, HybridSearchTool, and RangeSearchTool.
+ +Initialize the vectorized search tool.
+ + +Parameters:
+| Name | +Type | +Description | +Default | +
|---|---|---|---|
+ name
+ |
+
+ str
+ |
+
+
+
+ The name of the tool (exposed to LLM). + |
+ + required + | +
+ description
+ |
+
+ str
+ |
+
+
+
+ The description of the tool (exposed to LLM). + |
+ + required + | +
+ index
+ |
+
+ SearchIndex | AsyncSearchIndex
+ |
+
+
+
+ The RedisVL SearchIndex or AsyncSearchIndex to query. + |
+ + required + | +
+ vectorizer
+ |
+
+ BaseVectorizer
+ |
+
+
+
+ The vectorizer for embedding queries (required). + |
+ + required + | +
+ return_fields
+ |
+
+ list[str] | None
+ |
+
+
+
+ Optional list of fields to return in results. + |
+
+ None
+ |
+
src/adk_redis/tools/search/_base.py run_async
+
+
+
+ async
+
+
+¶Execute the vector-based search query.
+ + +Parameters:
+| Name | +Type | +Description | +Default | +
|---|---|---|---|
+ args
+ |
+
+ dict[str, Any]
+ |
+
+
+
+ Arguments from the LLM, must include 'query'. + |
+ + required + | +
+ tool_context
+ |
+
+ ToolContext
+ |
+
+
+
+ The tool execution context. + |
+ + required + | +
Returns:
+| Type | +Description | +
|---|---|
+ dict[str, Any]
+ |
+
+
+
+ A dictionary with status, count, and results. + |
+
src/adk_redis/tools/search/_base.py create_memory_mcp_toolset
+
+
+¶create_memory_mcp_toolset(server_url: str = 'http://localhost:8000', tool_filter: list[str] | None = None) -> 'McpToolset'
+Create an MCP toolset for Agent Memory Server.
+This function creates an McpToolset configured to connect to the +Agent Memory Server's SSE endpoint. The toolset provides access to +all memory operations via the Model Context Protocol.
+ + +Parameters:
+| Name | +Type | +Description | +Default | +
|---|---|---|---|
+ server_url
+ |
+
+ str
+ |
+
+
+
+ Base URL of the Agent Memory Server (without /sse suffix). +Default: "http://localhost:8000" + |
+
+ 'http://localhost:8000'
+ |
+
+ tool_filter
+ |
+
+ list[str] | None
+ |
+
+
+
+ Optional list of tool names to expose. If None, all +available tools are exposed. Available tools: +- search_long_term_memory +- get_long_term_memory +- create_long_term_memories +- edit_long_term_memory +- delete_long_term_memories +- memory_prompt +- set_working_memory + |
+
+ None
+ |
+
Returns:
+| Type | +Description | +
|---|---|
+ 'McpToolset'
+ |
+
+
+
+ McpToolset configured for Agent Memory Server. + |
+
Raises:
+| Type | +Description | +
|---|---|
+ ImportError
+ |
+
+
+
+ If google-adk is not installed with MCP support. + |
+
from google.adk import Agent
+from adk_redis.tools.mcp_memory import create_memory_mcp_toolset
+
+# All memory tools
+all_tools = create_memory_mcp_toolset(
+ server_url="http://localhost:8000",
+)
+
+# Only search and create tools
+limited_tools = create_memory_mcp_toolset(
+ server_url="http://localhost:8000",
+ tool_filter=["search_long_term_memory", "create_long_term_memories"],
+)
+
+agent = Agent(
+ model="gemini-2.0-flash",
+ name="memory_agent",
+ tools=[limited_tools],
+)
+src/adk_redis/tools/mcp_memory.py58 + 59 + 60 + 61 + 62 + 63 + 64 + 65 + 66 + 67 + 68 + 69 + 70 + 71 + 72 + 73 + 74 + 75 + 76 + 77 + 78 + 79 + 80 + 81 + 82 + 83 + 84 + 85 + 86 + 87 + 88 + 89 + 90 + 91 + 92 + 93 + 94 + 95 + 96 + 97 + 98 + 99 +100 +101 +102 +103 +104 +105 +106 +107 +108 +109 +110 +111 +112 +113 +114 +115 +116 +117 +118 +119 +120 +121 +122 +123 +124 +125 +126 +127 +128 | |
0&&i[i.length-1])&&(p[0]===6||p[0]===2)){r=0;continue}if(p[0]===3&&(!i||p[1]>i[0]&&p[1]=e.length&&(e=void 0),{value:e&&e[o++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function K(e,t){var r=typeof Symbol=="function"&&e[Symbol.iterator];if(!r)return e;var o=r.call(e),n,i=[],s;try{for(;(t===void 0||t-- >0)&&!(n=o.next()).done;)i.push(n.value)}catch(a){s={error:a}}finally{try{n&&!n.done&&(r=o.return)&&r.call(o)}finally{if(s)throw s.error}}return i}function B(e,t,r){if(r||arguments.length===2)for(var o=0,n=t.length,i;o