tl  tr
  Home | Tutorials | Articles | Videos | Products | Tools | Search
Interviews | Open Source | Tag Cloud | Follow Us | Bookmark | Contact   
 Agentic AI > ADK Agent Testing > Chaos Testing ADK Agents - Injecting Faults and Timeouts

Chaos Testing ADK Agents - Injecting Faults and Timeouts

Author: Venkata Sudhakar

ShopMax India's ADK agents depend on Gemini LLM calls, database tools, and external APIs. Any of these can fail in production - timeouts, connection errors, rate limit responses, and unexpected exceptions. Chaos testing deliberately injects these failure modes during tests to verify that the agent handles them gracefully: returning a sensible fallback response rather than crashing or leaking error details to customers.

Chaos testing uses pytest with AsyncMock side_effect to inject faults: asyncio.TimeoutError for slow LLM responses, custom exceptions for tool failures, and RuntimeError for unexpected crashes. The agent wrapper must catch each fault type and return an appropriate user-facing message. The test asserts both the fault tolerance (no crash) and the response quality (message is helpful, not a raw traceback). This is distinct from unit testing - chaos tests verify the failure handling code path, not the happy path.

The example shows ShopMax India testing three failure scenarios against their order tracking agent: LLM timeout, database tool failure, and an unexpected internal error. Each test verifies the agent returns a safe fallback response.


It gives the following output,

Timeout test: Request timed out. Please try again.
Tool failure test: A tool failed. Trying fallback.
Unexpected error test: Something went wrong. Our team has been notified.

Cover all failure modes your agent depends on: LLM timeout, LLM rate limit (429), database unreachable, third-party API 500, and malformed LLM response (JSON parse error). Add chaos tests to CI alongside integration tests - they run fast since faults are injected, not waited for. Never let raw exception messages reach the user response: assert that no test output contains the word traceback or exception. Review chaos test coverage quarterly as you add new tools and integrations.


 
  


  
bl  br