Add role to the event returned in agent callback sample

Events without a role are filtered out in the next turns.

PiperOrigin-RevId: 758393355
This commit is contained in:
Selcuk Gun 2025-05-13 15:11:31 -07:00 committed by Copybara-Service
parent f6bdd555fb
commit ff9de71869

View File

@ -92,7 +92,9 @@ def after_agent_cb1(callback_context):
def after_agent_cb2(callback_context): def after_agent_cb2(callback_context):
print('@after_agent_cb2') print('@after_agent_cb2')
return types.Content( # ModelContent (or Content with role set to 'model') must be returned.
# Otherwise, the event will be excluded from the context in the next turn.
return types.ModelContent(
parts=[ parts=[
types.Part( types.Part(
text='(stopped) after_agent_cb2', text='(stopped) after_agent_cb2',