4646)
4747from ..types .content import ContentBlock , Messages
4848from ..types .event_loop import Metrics , Usage
49+ from ..types .multiagent import MultiAgentInput
4950from .base import MultiAgentBase , MultiAgentResult , NodeResult , Status
5051
5152logger = logging .getLogger (__name__ )
@@ -146,7 +147,7 @@ class SwarmState:
146147 """Current state of swarm execution."""
147148
148149 current_node : SwarmNode | None # The agent currently executing
149- task : str | list [ ContentBlock ] # The original task from the user that is being executed
150+ task : MultiAgentInput # The original task from the user that is being executed
150151 completion_status : Status = Status .PENDING # Current swarm execution status
151152 shared_context : SharedContext = field (default_factory = SharedContext ) # Context shared between agents
152153 node_history : list [SwarmNode ] = field (default_factory = list ) # Complete history of agents that have executed
@@ -278,7 +279,7 @@ def __init__(
278279 run_async (lambda : self .hooks .invoke_callbacks_async (MultiAgentInitializedEvent (self )))
279280
280281 def __call__ (
281- self , task : str | list [ ContentBlock ] , invocation_state : dict [str , Any ] | None = None , ** kwargs : Any
282+ self , task : MultiAgentInput , invocation_state : dict [str , Any ] | None = None , ** kwargs : Any
282283 ) -> SwarmResult :
283284 """Invoke the swarm synchronously.
284285
@@ -293,7 +294,7 @@ def __call__(
293294 return run_async (lambda : self .invoke_async (task , invocation_state ))
294295
295296 async def invoke_async (
296- self , task : str | list [ ContentBlock ] , invocation_state : dict [str , Any ] | None = None , ** kwargs : Any
297+ self , task : MultiAgentInput , invocation_state : dict [str , Any ] | None = None , ** kwargs : Any
297298 ) -> SwarmResult :
298299 """Invoke the swarm asynchronously.
299300
@@ -317,7 +318,7 @@ async def invoke_async(
317318 return cast (SwarmResult , final_event ["result" ])
318319
319320 async def stream_async (
320- self , task : str | list [ ContentBlock ] , invocation_state : dict [str , Any ] | None = None , ** kwargs : Any
321+ self , task : MultiAgentInput , invocation_state : dict [str , Any ] | None = None , ** kwargs : Any
321322 ) -> AsyncIterator [dict [str , Any ]]:
322323 """Stream events during swarm execution.
323324
@@ -756,7 +757,7 @@ async def _execute_swarm(self, invocation_state: dict[str, Any]) -> AsyncIterato
756757 )
757758
758759 async def _execute_node (
759- self , node : SwarmNode , task : str | list [ ContentBlock ] , invocation_state : dict [str , Any ]
760+ self , node : SwarmNode , task : MultiAgentInput , invocation_state : dict [str , Any ]
760761 ) -> AsyncIterator [Any ]:
761762 """Execute swarm node and yield TypedEvent objects."""
762763 start_time = time .time ()
0 commit comments