tl  tr
  Home | Tutorials | Articles | Videos | Products | Tools | Search
Interviews | Open Source | Tag Cloud | Follow Us | Bookmark | Contact   
 Agentic AI > ADK Agent Testing > Token Efficiency Testing for ADK Agents - Maximizing Quality Per Token

Token Efficiency Testing for ADK Agents - Maximizing Quality Per Token

Author: Venkata Sudhakar

ShopMax India often maintains two or more versions of the same agent prompt - a detailed version that retrieves more facts but costs more tokens, and a concise version that saves on API spend but may miss key details. Token efficiency testing measures the quality-to-token ratio so the team can pick the version that delivers the most value per rupee spent on the API.

Quality score is calculated as the fraction of expected keywords found in the response. Efficiency ratio divides quality score by total tokens used, scaled by 1000 for readability. By comparing efficiency ratios across prompt versions, teams can identify which version gives the best balance of accuracy and cost before deploying to production.

The example below compares two versions of the order tracking prompt and asserts that version A has a higher efficiency ratio and meets the minimum quality threshold.


It gives the following output,

version_a - quality: 1.0, tokens: 355, efficiency: 2.8169
version_b - quality: 0.0, tokens: 455, efficiency: 0.0
.. (2 passed in 0.01s)

In production, collect expected_keywords from a golden dataset reviewed by the product team. Automate the efficiency comparison as a pre-merge check so that prompt rewrites that degrade quality-per-token are caught before reaching customers in Chennai, Hyderabad, or Delhi. Track the ratio over time to detect prompt drift as the model updates.


 
  


  
bl  br