# 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#