tl  tr
  Home | Tutorials | Articles | Videos | Products | Tools | Search
Interviews | Open Source | Tag Cloud | Follow Us | Bookmark | Contact   
 Agentic AI > ADK Agent Testing > Testing ADK Agents with External Memory Stores

Testing ADK Agents with External Memory Stores

Author: Venkata Sudhakar

ShopMax India's ADK agents need to remember customer preferences, previous order history, and ongoing support tickets across sessions. In-memory state is lost when the agent restarts, so production agents use external memory stores like Firestore or Redis to persist data. Testing agents with external memory stores verifies that the agent correctly reads stored context at session start, updates it during the conversation, and does not mix up state between different customers.

The test uses a mock memory store that behaves like a key-value database with get and set operations. Before the agent runs, the test seeds the store with a previous session snapshot. After the agent runs, the test asserts that the store was read at the start, written with updated values at the end, and that no data from a different customer leaked into the session.

The example below tests a ShopMax India agent that reads customer preference data from a mock memory store at session start and writes the updated order context back at session end.


It gives the following output,

Response: Order ORD-9034 shipped to Hyderabad. Arrives by 27 Apr.
Get calls: ['profile:CUST-Hyderabad-5012']
Set calls: ['last_order:CUST-Hyderabad-5012']
.. (2 passed in 0.01s)

In production, replace MockMemoryStore with a real Firestore or Redis client wrapped in a thin adapter interface. Use the same interface for both the mock and the real client so tests stay fast while production uses persistent storage. Set TTLs on all stored keys to prevent stale customer context from persisting across multiple days, and add an integration test that writes to a real test-namespace collection to validate the Firestore schema before each release.


 
  


  
bl  br