Skip to content

Commit bf72426

Browse files
google-genai-botcopybara-github
authored andcommitted
fix: runner was expecting Event object instead of Content object when using early exist feature
PiperOrigin-RevId: 788516645
1 parent 9c0721b commit bf72426

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

src/google/adk/runners.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -258,16 +258,17 @@ async def _exec_with_plugin(
258258
early_exit_result = await plugin_manager.run_before_run_callback(
259259
invocation_context=invocation_context
260260
)
261-
if isinstance(early_exit_result, Event):
261+
if isinstance(early_exit_result, types.Content):
262+
early_exit_event = Event(
263+
invocation_id=invocation_context.invocation_id,
264+
author='model',
265+
content=early_exit_result,
266+
)
262267
await self.session_service.append_event(
263268
session=session,
264-
event=Event(
265-
invocation_id=invocation_context.invocation_id,
266-
author='model',
267-
content=early_exit_result,
268-
),
269+
event=early_exit_event,
269270
)
270-
yield early_exit_result
271+
yield early_exit_event
271272
else:
272273
# Step 2: Otherwise continue with normal execution
273274
async for event in execute_fn(invocation_context):

0 commit comments

Comments
 (0)