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

ADK Tool Composition Patterns

Author: Venkata Sudhakar

Tool composition means building complex operations from simpler tool primitives. For ShopMax India, checking order fulfilment readiness requires stock verification, payment confirmation, and warehouse assignment - three separate tools that together answer one customer question. ADK agents orchestrate these automatically, but you can also create composed tools that bundle related operations.

The example shows two patterns: primitive tools that do one thing, and a composed tool that calls multiple primitives and aggregates their results. The agent can use either the primitives directly or the composed tool depending on what the query requires.


It gives the following output,

Q: Is order ORD-101 for SKU-001 ready to ship to Mumbai?
A: Order ORD-101 is ready for fulfilment. Stock confirmed (45 units at SKU-001),
payment of Rs 64,999 confirmed. Assigned to Pune Warehouse (45 km from Mumbai)
for dispatch.

Q: Is order ORD-102 for SKU-001 ready to ship to Bangalore?
A: Order ORD-102 is NOT ready. Stock is available (45 units), but payment status
is still pending at Rs 74,999. The order cannot be dispatched until payment is
confirmed.

Q: Just check stock for SKU-002
A: SKU-002 is currently out of stock at ShopMax India. No units are available
in any warehouse at this time.

For the first two queries the agent used the composed check_fulfilment_readiness tool, which ran all three primitives internally and returned a single aggregated result. For the third query, the agent correctly identified that only check_stock was needed and called just that primitive. This is the power of giving the agent both primitive and composed tools - it selects the right level of abstraction for each query.

For ShopMax India production, design your tool library in three layers: primitive tools (single data source, single operation), composed tools (multi-source, single domain), and orchestration tools (cross-domain workflows). Keep primitives thin and fast so they can be tested independently. Composed tools should include their own error handling so the agent receives a clean result even if one primitive fails - for example, returning warehouse as null rather than propagating an exception when warehouse assignment fails.


 
  


  
bl  br