Register and share your invite link to earn from video plays and referrals.

cv usk
@cv_usk
AI / Software Research Notes AI Agent, LLMOps, MLOps, Software Architecture ๆŠ•็จฟใฏๅ€‹ไบบใฎๆ„่ฆ‹ใงใ™ใ€‚
Joined May 2026
258 Following    228 Followers
# Practical and Useful Patterns with ADK ๐Ÿš€ Parallel tool execution, response size reduction, latency and token cost optimization โ€” maximize production throughput with ADK's Tool Performance guide. ๐Ÿ“Œ Title: Tool Performance โ€” Optimizing Tool Execution for Production ๐Ÿ”— URL: ๐Ÿงฉ Overview ADK provides multiple approaches for optimizing tool performance: parallel execution of read-only tools, response size reduction for token cost optimization, and latency reduction best practices. These optimizations are essential for achieving high throughput in production environments. ๐Ÿ›  Usage Examples of parallel execution and response optimization. First, define multiple read-only tools: `get_user_profile(user_id: str)`, `get_user_orders(user_id: str)`, and `get_user_preferences(user_id: str)` are side-effect-free functions that ADK can safely execute in parallel. Next, design a response-size-optimized tool like `search_products(query: str, limit: int = 5)` that returns only essential fields (`id`, `name`, `price`) while omitting image URLs, full descriptions, and metadata. Finally, create an `Agent` with `name="customer_service"` and `model="gemini-2.5-flash"`, passing all four functions in the `tools` list. ๐Ÿ— Practical Patterns **Parallel Execution Criteria**: Tools with no side effects and no mutual dependencies are safe for parallel execution. The LLM can invoke multiple tools simultaneously, and ADK executes them in parallel. Data retrieval tools (GET-equivalent) are great candidates. For parallel-friendly design, define independent tools like `get_weather(city: str)`, `get_news(topic: str)`, and `get_stock_price(symbol: str)`. Each is a read-only function returning a simple dict with its respective data (weather conditions, news articles, stock prices). When the LLM invokes all three simultaneously, ADK automatically runs them in parallel. **Response Size Optimization**: Tool return values consume LLM context window tokens. Removing unnecessary fields, summarizing data, and implementing pagination can dramatically reduce token costs. **Latency Optimization Checklist**: 1. Cache cacheable results 2. Set timeouts on external API calls 3. Avoid returning unnecessarily large data 4. Split into multiple small tools to encourage parallel execution ๐Ÿ’ก Use Cases ๐Ÿ“Š Parallel fetching from multiple data sources for dashboards ๐Ÿ” Field filtering in search results for token savings โšก Parallel API calls across microservices ๐Ÿ’ฐ Token cost optimization in high-volume request environments โš ๏ธ Caveats - Parallel execution of tools with side effects (writes, deletes) can cause race conditions. Sequential execution is recommended for write operations. - Over-reducing responses may leave the LLM without sufficient information, degrading answer quality. Ensure essential information is always included. - Timeouts that are too short may interrupt legitimate responses. Set appropriate timeout values. โœจ Small optimizations compound into significant performance differences in production. Start by reviewing your response sizes! #ADK# #AIAgent#
Show more