Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/google/adk/agents/llm_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -471,7 +471,7 @@ async def _run_async_impl(
events = ctx._get_events(current_invocation=True, current_branch=True)
if events and (
ctx.should_pause_invocation(events[-1])
or ctx.should_pause_invocation(events[-2])
or (len(events) >= 2 and ctx.should_pause_invocation(events[-2]))
):
Comment on lines 472 to 475
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

While the fix is correct, the logic to check the last two events can be simplified and made more robust using a slice and any(). This avoids manual length checks and is more idiomatic. Using [::-1] on the slice preserves the evaluation order of checking the last event first.

      if any(ctx.should_pause_invocation(event) for event in events[-2:][::-1]):

return
# Only yield an end state if the last event is no longer a long running
Expand Down