Your agent.py likely passes a model ID as a string when creating the root_agent:
root_agent = Agent(
# ...
model=os.getenv("MODEL"),
# ...
)When you pass a string, the Agent constructor creates a model instance with default settings.
Those defaults are not very resilient to transient errors such as HTTP 429 (rate limiting).
You can improve resilience by explicitly configuring retry behavior.
This requires two small changes.
from google.adk.models import Gemini
from google.genai.types import HttpRetryOptionsInstead of passing the model ID string, create a configured Gemini instance and pass it to Agent:
root_agent = Agent(
# ...
model=Gemini(
model=os.getenv("MODEL"),
retry_options=HttpRetryOptions(
initial_delay=2,
attempts=500,
max_delay=16,
jitter=2.0,
),
),
# ...
)The HttpRetryOptions values above are based on observed behavior under specific conditions and may not be optimal for your workload.
attemptsis set high to keep retrying rather than failing early.- Increasing delays did not significantly improve success rates in my case, but results may vary depending on service congestion level and dynamic quota value.
Adjust the parameters according to your experience.