@@ -96,9 +96,15 @@ def list_registered_agents() -> list:
9696
9797
9898def _supports_async_start (agent : Any ) -> bool :
99- """Return True when agent exposes a real async astart method ."""
99+ """Return True if agent.astart is a coroutine function ."""
100100 astart = getattr (agent , "astart" , None )
101- return callable (astart ) and inspect .iscoroutinefunction (astart )
101+ return inspect .iscoroutinefunction (astart )
102+
103+
104+ def _supports_sync_start (agent : Any ) -> bool :
105+ """Return True when agent exposes a callable sync start method."""
106+ start = getattr (agent , "start" , None )
107+ return callable (start )
102108
103109
104110# FastAPI Router (if FastAPI is available)
@@ -161,11 +167,11 @@ async def invoke_agent(
161167 if _supports_async_start (agent ):
162168 # Async agent
163169 result = await agent .astart (request .message )
164- elif hasattr (agent , "start" ) and callable ( agent . start ):
170+ elif _supports_sync_start (agent ):
165171 # Sync agent (use start method)
166172 result = agent .start (request .message )
167173 else :
168- raise AttributeError ("Agent must provide start() or async astart()" )
174+ raise AttributeError (f "Agent { agent_id } must provide start() or async astart()" )
169175
170176 logger .info (f"Agent { agent_id } invoked successfully" )
171177
@@ -298,10 +304,10 @@ async def invoke_agent_standalone(
298304
299305 if _supports_async_start (agent ):
300306 result = await agent .astart (message )
301- elif hasattr (agent , "start" ) and callable ( agent . start ):
307+ elif _supports_sync_start (agent ):
302308 result = agent .start (message )
303309 else :
304- raise AttributeError ("Agent must provide start() or async astart()" )
310+ raise AttributeError (f "Agent { agent_id } must provide start() or async astart()" )
305311
306312 return {
307313 "result" : str (result ),
0 commit comments