# Useful but Little-Known Features of ADK 2.0
๐ Ever had an AI agent fail mid-workflow because of a transient API hiccup, forcing you to manually re-run everything?
ADK 2.0 introduces RetryConfig, a framework-level automatic retry mechanism. Define your retry strategy declaratively โ no more manual try-catch blocks scattered throughout your agent code.
๐ Title: Automatic Retry (RetryConfig)
๐ URL:
๐งฉ Overview
RetryConfig lets the framework automatically manage retries when transient errors occur during agent or tool execution. By simply specifying max_attempts, you can automate recovery from network timeouts, API rate limits, and other temporary failures. This eliminates the need for developers to implement retry logic individually, dramatically improving agent robustness.
๐ How to use it
Just attach a RetryConfig to your agent โ automatic retries are immediately enabled.
```python
from adk import Agent, RetryConfig
agent = Agent(
name="api_caller",
model="gemini-2.0-flash",
instruction="Fetch data from the external API",
retry_config=RetryConfig(max_attempts=3),
)
```
When the framework detects an error, it automatically retries up to the specified number of attempts. No manual try-except blocks needed.
๐ Building it into production
ใปAlways configure RetryConfig for agents that call external APIs
ใปSet max_attempts appropriately based on target API rate limits and SLAs
ใปDesign with a clear distinction between transient and permanent errors
ใปMonitor retry counts and error details in logs to identify root causes
๐ก Use cases
๐ Automatic recovery from external API rate limits and timeouts
๐๏ธ Handling temporary database connection drops
โ๏ธ Building resilience against brief cloud service outages
๐ Improving stability at intermediate steps in multi-step workflows
โ ๏ธ Watch out
Broad `except Exception:` blocks will break the framework's retry mechanism by swallowing errors before the framework can handle them. Catching `BaseException` is even worse โ it traps `NodeInterruptedError`, which breaks Human-in-the-Loop (HITL) flows. Also, be careful not to waste retries on non-recoverable errors like authentication failures.
โจ With RetryConfig, you can free yourself from manual error handling and build robust agents that run reliably in production environments.
#
ADK# #
AIAgent#