Skip to content

ADK Plugin: Memory

The ADK Memory services provide ADK-compatible memory implementations that integrate with FloTorch’s memory infrastructure.

Exports:

  • FlotorchMemoryService – Traditional memory search using FloTorch Memory
  • FlotorchADKVectorMemoryService – Vector-based memory search using FloTorch VectorStore

from flotorch.adk.memory import FlotorchMemoryService, FlotorchADKVectorMemoryService
API_KEY = "<your_api_key>"
BASE_URL = "https://gateway.flotorch.cloud"
PROVIDER = "<flotorch_memory_provider>"
VECTORSTORE_ID = "<your_vectorstore_id>"

FlotorchMemoryService(
name: str,
base_url: str | None = None,
api_key: str | None = None,
)

Uses FloTorch Memory for traditional memory operations.

async def add_session_to_memory(self, session: Session) -> None

Adds an ADK session to FloTorch memory with automatic role mapping and content extraction.

search_memory(…) -> SearchMemoryResponse

Section titled “search_memory(…) -> SearchMemoryResponse”
async def search_memory(
self,
*,
app_name: str,
user_id: str,
query: str
) -> SearchMemoryResponse

Searches memory using FloTorch Memory with user/app filtering.


Constructor:

FlotorchADKVectorMemoryService(
api_key: str,
base_url: str,
vectorstore_id: str | None = None,
)

Uses FloTorch VectorStore for semantic memory search.

search_memory(…) -> SearchMemoryResponse

Section titled “search_memory(…) -> SearchMemoryResponse”
async def search_memory(
self,
query: str,
knn: int | None = None,
**kwargs
) -> SearchMemoryResponse

Performs vector-based semantic search with optional KNN parameter.


Automatically maps ADK roles to FloTorch expected roles:

  • model/assistant/agent/bot/aiassistant
  • user/human/personuser
  • systemsystem
  • tooltool

Robustly extracts text content from ADK Content and Part objects.

  • Graceful fallbacks on content extraction failures
  • Empty responses on search errors instead of exceptions

from google.adk.runner import Runner
# Traditional memory
memory_service = FlotorchMemoryService(
name="mem0",
base_url=BASE_URL,
api_key=API_KEY
)
# Vector memory
vector_memory = FlotorchADKVectorMemoryService(
api_key=API_KEY,
base_url=BASE_URL,
vectorstore_id=VECTORSTORE_ID
)
# Use with Runner
runner = Runner(
agent=agent,
memory_service=memory_service # or vector_memory
)

  • Memory services are designed to work seamlessly with ADK’s Runner
  • Vector memory requires a configured vector store in FloTorch
  • Both services handle ADK session and event objects automatically