ADK Plugin: Memory
FloTorch ADK Memory services enable persistent memory capabilities for your agents, allowing them to store and retrieve information across sessions. The memory system integrates seamlessly with Google ADK’s agent framework and provides two distinct memory implementations to suit different use cases.
Available Memory Types:
- FlotorchMemoryService - Traditional keyword-based memory search and retrieval
- FlotorchADKVectorMemoryService - Semantic vector-based memory search for advanced retrieval
Important: Memory services require prior setup in the FloTorch Console. Memory capabilities are not built-in and must be explicitly configured.
Prerequisites
Section titled “Prerequisites”Before using FloTorch ADK Memory services, ensure you have completed the general prerequisites outlined in the ADK Plugin Overview, Including installation and environment configuration.
Quick Setup
Section titled “Quick Setup”Traditional Memory Service
Section titled “Traditional Memory Service”from flotorch.adk.memory import FlotorchMemoryService
# Initialize memory service (requires prior registration in FloTorch Console)memory_service = FlotorchMemoryService( name="your-memory-provider", api_key="your_api_key", base_url="https://gateway.flotorch.cloud")Vector Memory Service
Section titled “Vector Memory Service”from flotorch.adk.memory import FlotorchADKVectorMemoryService
# Initialize vector memory service (requires prior vector store configuration)vector_memory = FlotorchADKVectorMemoryService( api_key="your_api_key", base_url="https://gateway.flotorch.cloud", vectorstore_id="your_vectorstore_id")Configuration
Section titled “Configuration”FlotorchMemoryService Parameters
Section titled “FlotorchMemoryService Parameters”FlotorchMemoryService( name: str, # Memory provider name (from FloTorch Console) - required base_url: str = None, # FloTorch Gateway URL (defaults to environment variable) api_key: str = None, # API key for authentication (defaults to environment variable))Parameter Details:
name- The name of the memory provider configured in FloTorch Consolebase_url- FloTorch Gateway endpoint URLapi_key- Authentication key for accessing FloTorch Gateway
FlotorchADKVectorMemoryService Parameters
Section titled “FlotorchADKVectorMemoryService Parameters”FlotorchADKVectorMemoryService( api_key: str, # FloTorch API key - required base_url: str, # FloTorch Gateway URL - required vectorstore_id: str = None, # Vector store ID from FloTorch Console)Parameter Details:
api_key- Authentication key for accessing FloTorch Gatewaybase_url- FloTorch Gateway endpoint URLvectorstore_id- The identifier of the vector store configured in FloTorch Console
Features
Section titled “Features”Automatic Session Storage
Section titled “Automatic Session Storage”Memory services provide automatic conversation management:
- Content Extraction - Automatically extracts content from ADK sessions
- Role Mapping - Converts ADK roles to FloTorch-compatible formats
- Metadata Storage - Stores conversations with associated metadata
- Tool Call Handling - Manages tool calls and responses within memory
Role Mapping
Section titled “Role Mapping”Provides seamless role conversion between ADK and FloTorch formats:
model/assistant/agent/bot/ai→assistantuser/human/person→usersystem→systemtool→tool
Search Capabilities
Section titled “Search Capabilities”Traditional Memory Search:
- Keyword-Based Search - Performs traditional text-based searches
- User/App Filtering - Filters results by user ID and application name
- Metadata Filtering - Supports custom metadata filtering
- Date Range Queries - Allows filtering by time ranges
Vector Memory Search:
- Semantic Similarity - Performs vector-based semantic searches
- KNN Configuration - Adjustable k-nearest neighbors parameter
- Score Thresholds - Configurable similarity score thresholds
- Query Rewriting - Supports query reformulation for better results
Usage Example
Section titled “Usage Example”Basic Memory Setup
Section titled “Basic Memory Setup”from flotorch.adk.memory import FlotorchMemoryServicefrom google.adk import Runner
# Initialize memory servicememory_service = FlotorchMemoryService( name="your-memory-provider", api_key="your_api_key", base_url="https://gateway.flotorch.cloud")
# Use with Runnerrunner = Runner( agent=your_agent, memory_service=memory_service)Best Practices
Section titled “Best Practices”- Memory Provider Setup - Always configure memory providers in FloTorch Console before using them in code
- Memory Type Selection - Use traditional memory for keyword searches and vector memory for semantic retrieval
- Error Handling - Implement proper error handling for memory operations in production environments
Next Steps
Section titled “Next Steps”- Agent Configuration - Learn how to configure agents with memory capabilities
- Session Management - Implement session persistence alongside memory
- LLM Configuration - Configure language models for your memory-enabled agents