Skip to content

Commit 1639298

Browse files
pwwpchecopybara-github
authored andcommitted
feat: Expose Gemini RetryOptions to client
google.genai SDK has introduced a new retry_options. This change exposes this configuration to ADK users Usage: ```python root_agent = Agent( model=Gemini( model='gemini-2.0-flash', retry_options=types.HttpRetryOptions( initial_delay=1, attempts=2 # ... Retry options from google.genai ), # ... ), ``` PiperOrigin-RevId: 786472564
1 parent 20537e8 commit 1639298

File tree

1 file changed

+22
-1
lines changed

1 file changed

+22
-1
lines changed

src/google/adk/models/google_llm.py

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import sys
2323
from typing import AsyncGenerator
2424
from typing import cast
25+
from typing import Optional
2526
from typing import TYPE_CHECKING
2627
from typing import Union
2728

@@ -57,6 +58,23 @@ class Gemini(BaseLlm):
5758

5859
model: str = 'gemini-1.5-flash'
5960

61+
retry_options: Optional[types.HttpRetryOptions] = None
62+
"""Allow Gemini to retry failed responses.
63+
64+
Sample:
65+
```python
66+
from google.genai import types
67+
68+
# ...
69+
70+
agent = Agent(
71+
model=Gemini(
72+
retry_options=types.HttpRetryOptions(initial_delay=1, attempts=2),
73+
)
74+
)
75+
```
76+
"""
77+
6078
@staticmethod
6179
@override
6280
def supported_models() -> list[str]:
@@ -191,7 +209,10 @@ def api_client(self) -> Client:
191209
The api client.
192210
"""
193211
return Client(
194-
http_options=types.HttpOptions(headers=self._tracking_headers)
212+
http_options=types.HttpOptions(
213+
headers=self._tracking_headers,
214+
retry_options=self.retry_options,
215+
)
195216
)
196217

197218
@cached_property

0 commit comments

Comments
 (0)