tl  tr
  Home | Tutorials | Articles | Videos | Products | Tools | Search
Interviews | Open Source | Tag Cloud | Follow Us | Bookmark | Contact   
 Agentic AI > ADK Agent Testing > Fuzz Testing ADK Agent Inputs with Hypothesis

Fuzz Testing ADK Agent Inputs with Hypothesis

Author: Venkata Sudhakar

ShopMax India's ADK agents receive free-text input from customers across Mumbai, Bangalore, Delhi, Hyderabad, and Chennai - including typos, mixed Hindi-English, emojis, very long strings, and adversarial inputs. Fuzz testing bombards the agent's input validation and tool parsing functions with randomly generated and edge-case inputs to find crashes, uncaught exceptions, and silent data corruption before they reach production customers.

Fuzz testing for ADK agents uses the Hypothesis library to generate diverse inputs automatically. Hypothesis shrinks failing inputs to the minimal reproducing case, making bugs easy to diagnose. Define a strategy that generates strings with varying lengths, special characters, SQL-like patterns, and Unicode. Apply @given to any tool or parser function and assert safety invariants: the function never raises an unhandled exception and always returns a typed result.

The example below fuzz tests ShopMax India's order ID parser and query classifier using Hypothesis. The parser must never crash on any string input - it should return a valid result or a typed error dict. The classifier must always return one of the known intent labels.


It gives the following output,

.. (2 passed in 1.43s)

In production, ShopMax India should add fuzz tests for every new tool function and run them nightly with a higher max_examples count (1000+) to find rarer edge cases. Pay special attention to inputs containing SQL keywords, HTML tags, null bytes, and very long strings (10000+ characters) as these trigger bugs in parsers that only check the happy-path format. Store Hypothesis database artifacts in the repo so that discovered edge cases are replayed on every future CI run.


 
  


  
bl  br