Skip to content

Commit 63353b2

Browse files
google-genai-botcopybara-github
authored andcommitted
feat: Refactor gepa sample code and clean-up user demo colab
PiperOrigin-RevId: 828293079
1 parent 4284c61 commit 63353b2

File tree

6 files changed

+2526
-783
lines changed

6 files changed

+2526
-783
lines changed

contributing/samples/gepa/adk_agent.py

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,10 @@
3131
from google.adk.agents import loop_agent
3232
from google.adk.events import event as event_lib
3333
from google.adk.models import google_llm
34+
from google.adk.planners import built_in_planner
3435
from google.adk.tools import base_tool
3536
from google.genai import types
37+
from retry import api as retry
3638

3739

3840
class EnvResponse(Protocol):
@@ -134,6 +136,11 @@ def _adk_agent(
134136
model=model or 'gemini-2.5-flash',
135137
retry_options=_default_retry_options(),
136138
),
139+
planner=built_in_planner.BuiltInPlanner(
140+
thinking_config=types.ThinkingConfig(
141+
thinking_budget=-1, include_thoughts=False
142+
)
143+
),
137144
instruction=instruction,
138145
tools=tools,
139146
generate_content_config=types.GenerateContentConfig(
@@ -173,11 +180,17 @@ async def _run_async_impl(self, ctx: Any) -> Any:
173180
return
174181

175182
if last_event.content and last_event.content.parts:
176-
next_message = last_event.content.parts[-1].text
183+
next_message = '\n\n'.join([p.text for p in last_event.content.parts])
177184
else:
178185
logging.warn('Empty content with event=%s', last_event)
179186
next_message = ''
180-
env_response = self.env.step(types.Part(text=next_message))
187+
env_response = retry.retry_call(
188+
self.env.step,
189+
fargs=(types.Part(text=next_message),),
190+
tries=3,
191+
delay=2,
192+
backoff=2,
193+
)
181194

182195
output_event = event_lib.Event(
183196
content=types.Content(

0 commit comments

Comments
 (0)