5555 new_task ,
5656)
5757
58+
5859class DummyAgentExecutor (AgentExecutor ):
5960 async def execute (self , context : RequestContext , event_queue : EventQueue ):
6061 task_updater = TaskUpdater (
@@ -78,6 +79,7 @@ async def _run(self):
7879 async def cancel (self , context : RequestContext , event_queue : EventQueue ):
7980 pass
8081
82+
8183# Helper to create a simple task for tests
8284def create_sample_task (
8385 task_id = 'task1' , status_state = TaskState .submitted , context_id = 'ctx1'
@@ -585,8 +587,10 @@ class HelloAgentExecutor(AgentExecutor):
585587 async def execute (self , context : RequestContext , event_queue : EventQueue ):
586588 task = context .current_task
587589 if not task :
588- assert context .message is not None , "A message is required to create a new task"
589- task = new_task (context .message ) # type: ignore
590+ assert context .message is not None , (
591+ 'A message is required to create a new task'
592+ )
593+ task = new_task (context .message ) # type: ignore
590594 await event_queue .enqueue_event (task )
591595 updater = TaskUpdater (event_queue , task .id , task .context_id )
592596
@@ -598,17 +602,18 @@ async def execute(self, context: RequestContext, event_queue: EventQueue):
598602 )
599603 except Exception as e :
600604 # Stop processing when the event loop is closed
601- logging .warning (" Error: %s" , e )
605+ logging .warning (' Error: %s' , e )
602606 return
603607 await updater .add_artifact (
604- [Part (root = TextPart (text = " Hello world!" ))],
608+ [Part (root = TextPart (text = ' Hello world!' ))],
605609 name = 'conversion_result' ,
606610 )
607611 await updater .complete ()
608612
609613 async def cancel (self , context : RequestContext , event_queue : EventQueue ):
610614 pass
611615
616+
612617@pytest .mark .asyncio
613618async def test_on_message_send_non_blocking ():
614619 task_store = InMemoryTaskStore ()
@@ -623,12 +628,11 @@ async def test_on_message_send_non_blocking():
623628 message = Message (
624629 role = Role .user ,
625630 message_id = 'msg_push' ,
626- parts = [Part (root = TextPart (text = f'Hi' ))]
631+ parts = [Part (root = TextPart (text = f'Hi' ))],
627632 ),
628633 configuration = MessageSendConfiguration (
629- blocking = False ,
630- accepted_output_modes = ['text/plain' ]
631- )
634+ blocking = False , accepted_output_modes = ['text/plain' ]
635+ ),
632636 )
633637
634638 result = await request_handler .on_message_send (
@@ -651,6 +655,7 @@ async def test_on_message_send_non_blocking():
651655 assert task is not None
652656 assert task .status .state == TaskState .completed
653657
658+
654659@pytest .mark .asyncio
655660async def test_on_message_send_interrupted_flow ():
656661 """Test on_message_send when flow is interrupted (e.g., auth_required)."""
0 commit comments