11import json
22import asyncio
3- from typing import Any , Dict , List
3+ from typing import Any , Dict , List , override
44from datetime import timedelta
55
66from agents import Runner
@@ -82,6 +82,7 @@ def __init__(self):
8282 )
8383
8484 @workflow .signal (name = SignalName .RECEIVE_EVENT )
85+ @override
8586 async def on_task_event_send (self , params : SendEventParams ) -> None :
8687
8788 if self ._state is None :
@@ -95,22 +96,30 @@ async def on_task_event_send(self, params: SendEventParams) -> None:
9596 self ._trace_id = params .task .id
9697 self ._parent_span_id = params .task .id
9798
99+ if params .event .content is None :
100+ workflow .logger .warning ("Received event with no content" )
101+ return
102+
98103 await adk .messages .create (task_id = params .task .id , content = params .event .content )
99104
100105 if self ._state .turn_number > 1 :
101- # put human message in human queue
102- await self .human_queue .put (params .event .content .content )
103- return await adk .messages .create (task_id = params .task .id , content = TextContent (
106+ # put human message in human queue
107+ # Extract text content from the event
108+ if hasattr (params .event .content , 'content' ):
109+ await self .human_queue .put (params .event .content .content )
110+
111+ await adk .messages .create (task_id = params .task .id , content = TextContent (
104112 author = "agent" ,
105113 content = "" ,
106114 ))
107115 else :
108- return await adk .messages .create (task_id = params .task .id , content = TextContent (
116+ await adk .messages .create (task_id = params .task .id , content = TextContent (
109117 author = "agent" ,
110118 content = "" ,
111119 ))
112120
113121 @workflow .run
122+ @override
114123 async def on_task_create (self , params : CreateTaskParams ) -> str :
115124 logger .info (f"Received task create params: { params } " )
116125
@@ -223,10 +232,10 @@ async def on_task_create(self, params: CreateTaskParams) -> str:
223232 hooks = TemporalStreamingHooks (task_id = params .task .id )
224233
225234 # Execute agent with graceful degradation pattern (from temporal-community demos)
226- result = await Runner .run (procurement_agent , self ._state .input_list , hooks = hooks )
235+ result = await Runner .run (procurement_agent , self ._state .input_list , hooks = hooks ) # type: ignore[arg-type]
227236
228237 # Update state with result
229- self ._state .input_list = result .to_input_list ()
238+ self ._state .input_list = result .to_input_list () # type: ignore[assignment]
230239 logger .info (f"Successfully processed event at turn { self ._state .turn_number } " )
231240
232241 # Extract learnings from NEW wait_for_human calls only (using going backwards approach)
@@ -242,7 +251,7 @@ async def on_task_create(self, params: CreateTaskParams) -> str:
242251
243252 # Create extraction agent and run with only the NEW context
244253 extract_agent = new_extract_learnings_agent ()
245- extraction_result = await Runner .run (extract_agent , new_context , hooks = hooks )
254+ extraction_result = await Runner .run (extract_agent , new_context , hooks = hooks ) # type: ignore[arg-type]
246255
247256 logger .info (f"About to extract learning: { extraction_result .final_output } " )
248257 # Append the learning and track the call_id
0 commit comments