Skip to content

Commit 5b608ce

Browse files
committed
Add checking
1 parent 36dd459 commit 5b608ce

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

examples/google_adk/calendar_agent/adk_agent_executor.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,11 +216,29 @@ async def execute(
216216
event_queue: EventQueue,
217217
):
218218
# Run the agent until either complete or the task is suspended.
219+
assert context.task_id is not None, (
220+
'Task ID must be present for execution'
221+
)
222+
assert context.context_id is not None, (
223+
'Context ID must be present for execution'
224+
)
225+
219226
updater = TaskUpdater(event_queue, context.task_id, context.context_id)
220227
# Immediately notify that the task is submitted.
221228
if not context.current_task:
222229
updater.submit()
223230
updater.start_work()
231+
232+
if context.message is None:
233+
logger.warning('Execute called with no message in context')
234+
updater.update_status(
235+
TaskState.failed,
236+
message=new_agent_text_message(
237+
'No message provided to the agent.'
238+
),
239+
)
240+
return
241+
224242
await self._process_request(
225243
types.UserContent(
226244
parts=convert_a2a_parts_to_genai(context.message.parts),

0 commit comments

Comments
 (0)