Skip to content

Commit 5d9ba84

Browse files
committed
update cli.py
1 parent 35310ac commit 5d9ba84

1 file changed

Lines changed: 4 additions & 9 deletions

File tree

samples/cli.py

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,20 +25,15 @@ async def _handle_stream(
2525

2626
if not current_task_id:
2727
if event.HasField('task'):
28-
# V2 handler emits Task(SUBMITTED) first per A2A spec §3.1.2.
28+
# V2 handler emits Task or Message first.
2929
current_task_id = event.task.id
3030
state_name = TaskState.Name(event.task.status.state)
3131
print(f'Task [state={state_name}]')
32+
# Legacy handler might not send a leading Task event.
3233
elif event.HasField('status_update'):
33-
# Legacy handler streams status updates directly without a
34-
# leading Task event; extract the task ID from the update.
3534
current_task_id = event.status_update.task_id
36-
else:
37-
warnings.warn(
38-
'Unexpected first streaming event type. '
39-
'Cannot determine task ID.',
40-
stacklevel=2,
41-
)
35+
elif event.HasField('artifact_update'):
36+
current_task_id = event.artifact_update.artifact.task_id
4237

4338
if event.HasField('status_update'):
4439
state_name = TaskState.Name(event.status_update.status.state)

0 commit comments

Comments
 (0)