|
|
ADK Batch Agent Processing
Author: Venkata Sudhakar
Many business workflows require processing hundreds or thousands of items through an AI agent - daily report generation, bulk product categorisation, nightly risk scoring, or end-of-day reconciliation. ADK agents can be run in batch mode using Python async concurrency, processing items in parallel while respecting API rate limits.
ShopMax India needs to process 500+ product listings each night - classifying items, generating SEO descriptions, and flagging policy violations. Running these sequentially would take hours. Batch agent processing completes the same work in minutes using concurrent Gemini calls with controlled throughput.
The below example shows a batch agent that processes a list of product listings concurrently with rate limiting and error tracking.
It gives the following output,
Batch complete: 3/3 succeeded, 0 failed
P001: Electronics|Televisions|false|Samsung 65-inch QLED 4K Smart TV HDR10+
P002: Electronics|Smartphones|false|Apple iPhone 15 Pro Titanium 48MP Camera
P003: Electronics|Laptops|false|Dell XPS 15 OLED i7 32GB 1TB SSD Laptop
The semaphore controls throughput so you stay within Gemini API rate limits. Scale max_concurrent based on your quota tier. For large batches (10,000+ items), chunk the list and process in waves, persisting results to a database between chunks. Add exponential backoff in the exception handler to retry transient quota errors automatically.
|
|