tl  tr
  Home | Tutorials | Articles | Videos | Products | Tools | Search
Interviews | Open Source | Tag Cloud | Follow Us | Bookmark | Contact   
 Agentic AI > ADK Agent Testing > Multi-Turn Stateful Dialog Testing for ADK Agents

Multi-Turn Stateful Dialog Testing for ADK Agents

Author: Venkata Sudhakar

ShopMax India customers often have multi-step conversations: they first ask about an order, then request a cancellation, then ask for a refund status. Each turn must preserve relevant context from earlier turns so the agent does not ask the customer to repeat information they already provided. Multi-turn stateful dialog testing verifies that the agent carries state correctly across the full conversation and produces the right response at each step.

The test defines a conversation script as a list of (user_input, expected_keywords) pairs and runs through them in sequence, feeding each response back as context for the next turn. After each turn, the test asserts that the expected keywords are present in the response and that the conversation state contains the correct accumulated context such as the resolved order ID or customer city.

The example below simulates a 4-turn ShopMax India support conversation and asserts that the agent correctly references order ORD-7821 in all follow-up turns after the customer mentions it in turn 1.


It gives the following output,

Turn 1 | Q: Track order ORD-7821 from Mumbai
         | A: Order ORD-7821 from Mumbai is shipped. Arrives b
Turn 2 | Q: Please cancel that order
         | A: Order ORD-7821 cancellation request submitted.
Turn 3 | Q: When will I get my refund?
         | A: Refund for ORD-7821 will be processed in 5-7 days
Turn 4 | Q: What is the current status?
         | A: Cancellation of ORD-7821 is confirmed. Refund pen
. (1 passed in 0.01s)

In production, replace the keyword-routing mock with a real ADK InMemoryRunner and pass the session state across turns using the ADK session API. Assert state after each turn rather than only at the end to catch the exact turn where context is lost. Add negative tests that verify the agent does not carry over context from a previous customer session into a new one.


 
  


  
bl  br