Skip to content

Commit 3bc90c5

Browse files
Jacksunweicopybara-github
authored andcommitted
fix: Rollback 2aab1cf temporally
Related to #423 #1670 PiperOrigin-RevId: 786955451
1 parent a858d79 commit 3bc90c5

File tree

4 files changed

+6
-23
lines changed

4 files changed

+6
-23
lines changed

src/google/adk/agents/loop_agent.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -53,15 +53,10 @@ async def _run_async_impl(
5353
times_looped = 0
5454
while not self.max_iterations or times_looped < self.max_iterations:
5555
for sub_agent in self.sub_agents:
56-
should_exit = False
5756
async for event in sub_agent.run_async(ctx):
5857
yield event
5958
if event.actions.escalate:
60-
should_exit = True
61-
62-
if should_exit:
63-
return
64-
59+
return
6560
times_looped += 1
6661
return
6762

src/google/adk/tools/exit_loop_tool.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,3 @@ def exit_loop(tool_context: ToolContext):
2121
Call this function only when you are instructed to do so.
2222
"""
2323
tool_context.actions.escalate = True
24-
tool_context.actions.skip_summarization = True

tests/unittests/agents/test_loop_agent.py

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -68,13 +68,6 @@ async def _run_async_impl(
6868
),
6969
actions=EventActions(escalate=True),
7070
)
71-
yield Event(
72-
author=self.name,
73-
invocation_id=ctx.invocation_id,
74-
content=types.Content(
75-
parts=[types.Part(text=f'I have done my job after escalation!!')]
76-
),
77-
)
7871

7972

8073
async def _create_parent_invocation_context(
@@ -122,20 +115,17 @@ async def test_run_async_with_escalate_action(request: pytest.FixtureRequest):
122115
escalating_agent = _TestingAgentWithEscalateAction(
123116
name=f'{request.function.__name__}_test_escalating_agent'
124117
)
125-
ignored_agent = _TestingAgent(
126-
name=f'{request.function.__name__}_test_ignored_agent'
127-
)
128118
loop_agent = LoopAgent(
129119
name=f'{request.function.__name__}_test_loop_agent',
130-
sub_agents=[non_escalating_agent, escalating_agent, ignored_agent],
120+
sub_agents=[non_escalating_agent, escalating_agent],
131121
)
132122
parent_ctx = await _create_parent_invocation_context(
133123
request.function.__name__, loop_agent
134124
)
135125
events = [e async for e in loop_agent.run_async(parent_ctx)]
136126

137127
# Only two events are generated because the sub escalating_agent escalates.
138-
assert len(events) == 3
128+
assert len(events) == 2
139129
assert events[0].author == non_escalating_agent.name
140130
assert events[1].author == escalating_agent.name
141131
assert events[0].content.parts[0].text == (
@@ -144,6 +134,3 @@ async def test_run_async_with_escalate_action(request: pytest.FixtureRequest):
144134
assert events[1].content.parts[0].text == (
145135
f'Hello, async {escalating_agent.name}!'
146136
)
147-
assert (
148-
events[2].content.parts[0].text == 'I have done my job after escalation!!'
149-
)

tests/unittests/flows/llm_flows/test_agent_transfer.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -303,9 +303,11 @@ def test_auto_to_loop():
303303
name='exit_loop', response={'result': None}
304304
),
305305
),
306+
# root_agent summarizes.
307+
('root_agent', 'response4'),
306308
]
307309

308310
# root_agent should still be the current agent because sub_agent_1 is loop.
309311
assert testing_utils.simplify_events(runner.run('test2')) == [
310-
('root_agent', 'response4'),
312+
('root_agent', 'response5'),
311313
]

0 commit comments

Comments
 (0)