tl  tr
  Home | Tutorials | Articles | Videos | Products | Tools | Search
Interviews | Open Source | Tag Cloud | Follow Us | Bookmark | Contact   
 Generative AI > Google Gemini API > ADK Dynamic Tool Selection

ADK Dynamic Tool Selection

Author: Venkata Sudhakar

Loading all tools into every agent session is wasteful and can confuse the model when the tool list is large. For ShopMax India, a customer agent needs pricing and stock tools, but a warehouse agent needs dispatch and logistics tools. Dynamic tool selection loads only the tools relevant to the current user role and query context, keeping the model focused and reducing token overhead.

The pattern below classifies the incoming query to determine intent, then builds an agent with only the tools appropriate for that intent. This replaces one large agent with many small focused agents selected at dispatch time.


It gives the following output,

[product_query] SKU-7821 is currently priced at Rs 64,999 with 88 units in
stock at the Pune warehouse.

[order_query] Order ORD-551 has been dispatched and is expected to arrive
within 2 days.

[warehouse_ops] There are currently 14 pending dispatches in the Pune warehouse
queue, with 3 marked as urgent priority.

Each query was routed to an agent with only the tools it needed - the product query agent had no access to return or dispatch tools, and the warehouse agent had no access to customer-facing order tools. This prevents the model from accidentally using the wrong tool, reduces input token count (fewer tool descriptions in the prompt), and makes each agent easier to test in isolation.

For ShopMax India production, replace the keyword classifier with a Gemini call that classifies intent from the query text - this handles ambiguous or complex queries more reliably than keyword matching. Cache the classification result in the session state so follow-up queries in the same conversation reuse the same tool set without re-classifying. Use Cloud Armor to enforce that warehouse_ops tool access is restricted to requests originating from internal ShopMax India IP ranges.


 
  


  
bl  br