|
|
Testing ADK Sequential Agent Pipelines with pytest
Author: Venkata Sudhakar
ShopMax India uses ADK sequential agents to process customer orders in stages: intent classification, inventory check, then confirmation dispatch. Testing sequential pipelines ensures each stage receives correct input from the prior stage and that the overall chain produces the expected final output. Without structured sequential tests, a broken handoff between stages can silently corrupt order state across thousands of transactions.
An ADK sequential agent runs sub-agents one after another, passing the session state forward. In tests, you assert on intermediate state after each step and on the final output after the full chain completes. Use dependency injection to substitute real LLM calls with deterministic mocks at each stage so tests run fast and reproduce reliably in CI.
The example below defines a three-stage sequential pipeline for ShopMax India: classify the customer query, look up inventory, then generate a confirmation. Each stage is mocked. The test asserts on the output of every stage and verifies the final response contains the expected order confirmation.
It gives the following output,
... (3 passed in 0.01s)
In production at ShopMax India, add timeout assertions between pipeline stages to catch slow LLM calls before they cascade into customer-facing delays. Log the intent classification result for every order so that misclassifications can be traced back to specific prompt versions. Run the full sequential pipeline test suite on every CI push and alert on any stage whose pass rate drops below 99 percent across the test dataset.
|
|