|
|
Integration Testing ADK Multi-Agent Pipelines
Author: Venkata Sudhakar
ShopMax India's ADK support system uses a supervisor agent that delegates order queries to an order_agent and return requests to a returns_agent. Integration tests verify the full delegation chain - that the supervisor routes correctly, the right sub-agent handles the query, and the final reply reaches the customer with the expected content. These tests catch wiring errors that unit tests on individual agents cannot detect.
Integration tests for ADK multi-agent pipelines use InMemoryRunner with the supervisor as the root agent and all sub-agents registered. The LLM is mocked with side_effect to return a sequence of responses - first the supervisor routing decision, then the sub-agent reply. Assertions check both which agent authored the final response and what text it contains, validating the full delegation path in a single test.
The example below tests that ShopMax India's supervisor routes order queries to order_agent and return requests to returns_agent, verifying the end-to-end handoff chain with mocked LLM calls.
It gives the following output,
tests/test_pipeline.py::test_order_query_routed_to_order_agent PASSED
tests/test_pipeline.py::test_return_request_routed_to_returns_agent PASSED
2 passed in 0.44s
In production, add a third assertion that checks mock_llm.call_count equals 2 for each test - one call for the supervisor routing decision and one for the sub-agent reply. If call_count differs, the delegation chain has changed and you need to update either the mock side_effect sequence or the agent instructions. Run integration tests in a separate CI stage from unit tests since they are slower and test cross-agent behavior.
|
|