|
|
Testing ADK Agent Event Streaming and EventActions
Author: Venkata Sudhakar
ShopMax India's ADK agents emit events at each step of order processing: tool_called, tool_result, agent_response, and session_end. Testing event streaming ensures the agent emits the right events in the correct order, that EventActions such as escalate or end_session trigger correctly, and that event consumers like audit loggers and real-time dashboards receive every event without drops or duplicates.
ADK events are structured objects emitted by the agent runner during execution. In tests, collect all events from a run and assert on their types, order, and payloads. To test EventActions, verify that the action attached to an event causes the expected downstream behavior - such as setting a flag, escalating to a human agent, or closing the session. Use a list-based event collector as the test consumer.
The example below simulates an ADK event stream for a ShopMax India order query. Events include tool_called, tool_result, and agent_response. Tests verify event sequence, payload content, and that a escalate EventAction is emitted when the order cannot be resolved automatically.
It gives the following output,
... (3 passed in 0.01s)
In production, ShopMax India should publish ADK events to a Pub/Sub topic so that multiple downstream consumers - audit loggers, dashboards, and escalation workflows - can subscribe independently without coupling to the agent. Use event schema versioning so consumers can handle both old and new event formats gracefully during deployments. Test the full event fan-out in integration tests by asserting that each subscriber received the expected events after a single agent run.
|
|