4545)
4646from ..types .content import ContentBlock , Messages
4747from ..types .event_loop import Metrics , Usage
48+ from ..types .multiagent import MultiAgentInput
4849from .base import MultiAgentBase , MultiAgentResult , NodeResult , Status
4950
5051logger = logging .getLogger (__name__ )
@@ -145,7 +146,7 @@ class SwarmState:
145146 """Current state of swarm execution."""
146147
147148 current_node : SwarmNode | None # The agent currently executing
148- task : str | list [ ContentBlock ] # The original task from the user that is being executed
149+ task : MultiAgentInput # The original task from the user that is being executed
149150 completion_status : Status = Status .PENDING # Current swarm execution status
150151 shared_context : SharedContext = field (default_factory = SharedContext ) # Context shared between agents
151152 node_history : list [SwarmNode ] = field (default_factory = list ) # Complete history of agents that have executed
@@ -277,7 +278,7 @@ def __init__(
277278 run_async (lambda : self .hooks .invoke_callbacks_async (MultiAgentInitializedEvent (self )))
278279
279280 def __call__ (
280- self , task : str | list [ ContentBlock ] , invocation_state : dict [str , Any ] | None = None , ** kwargs : Any
281+ self , task : MultiAgentInput , invocation_state : dict [str , Any ] | None = None , ** kwargs : Any
281282 ) -> SwarmResult :
282283 """Invoke the swarm synchronously.
283284
@@ -292,7 +293,7 @@ def __call__(
292293 return run_async (lambda : self .invoke_async (task , invocation_state ))
293294
294295 async def invoke_async (
295- self , task : str | list [ ContentBlock ] , invocation_state : dict [str , Any ] | None = None , ** kwargs : Any
296+ self , task : MultiAgentInput , invocation_state : dict [str , Any ] | None = None , ** kwargs : Any
296297 ) -> SwarmResult :
297298 """Invoke the swarm asynchronously.
298299
@@ -316,7 +317,7 @@ async def invoke_async(
316317 return cast (SwarmResult , final_event ["result" ])
317318
318319 async def stream_async (
319- self , task : str | list [ ContentBlock ] , invocation_state : dict [str , Any ] | None = None , ** kwargs : Any
320+ self , task : MultiAgentInput , invocation_state : dict [str , Any ] | None = None , ** kwargs : Any
320321 ) -> AsyncIterator [dict [str , Any ]]:
321322 """Stream events during swarm execution.
322323
@@ -741,7 +742,7 @@ async def _execute_swarm(self, invocation_state: dict[str, Any]) -> AsyncIterato
741742 )
742743
743744 async def _execute_node (
744- self , node : SwarmNode , task : str | list [ ContentBlock ] , invocation_state : dict [str , Any ]
745+ self , node : SwarmNode , task : MultiAgentInput , invocation_state : dict [str , Any ]
745746 ) -> AsyncIterator [Any ]:
746747 """Execute swarm node and yield TypedEvent objects."""
747748 start_time = time .time ()
0 commit comments