Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 0 additions & 16 deletions src/strands/multiagent/graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -461,22 +461,6 @@ def __init__(

run_async(lambda: self.hooks.invoke_callbacks_async(MultiAgentInitializedEvent(self)))

def __call__(
self, task: MultiAgentInput, invocation_state: dict[str, Any] | None = None, **kwargs: Any
) -> GraphResult:
"""Invoke the graph synchronously.

Args:
task: The task to execute
invocation_state: Additional state/context passed to underlying agents.
Defaults to None to avoid mutable default argument issues.
**kwargs: Keyword arguments allowing backward compatible future changes.
"""
if invocation_state is None:
invocation_state = {}

return run_async(lambda: self.invoke_async(task, invocation_state))

async def invoke_async(
self, task: MultiAgentInput, invocation_state: dict[str, Any] | None = None, **kwargs: Any
) -> GraphResult:
Expand Down
15 changes: 0 additions & 15 deletions src/strands/multiagent/swarm.py
Original file line number Diff line number Diff line change
Expand Up @@ -299,21 +299,6 @@ def __init__(
self._inject_swarm_tools()
run_async(lambda: self.hooks.invoke_callbacks_async(MultiAgentInitializedEvent(self)))

def __call__(
self, task: MultiAgentInput, invocation_state: dict[str, Any] | None = None, **kwargs: Any
) -> SwarmResult:
"""Invoke the swarm synchronously.

Args:
task: The task to execute
invocation_state: Additional state/context passed to underlying agents.
Defaults to None to avoid mutable default argument issues.
**kwargs: Keyword arguments allowing backward compatible future changes.
"""
if invocation_state is None:
invocation_state = {}
return run_async(lambda: self.invoke_async(task, invocation_state))

async def invoke_async(
self, task: MultiAgentInput, invocation_state: dict[str, Any] | None = None, **kwargs: Any
) -> SwarmResult:
Expand Down
12 changes: 12 additions & 0 deletions tests/strands/multiagent/test_graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -890,6 +890,18 @@ def test_graph_synchronous_execution(mock_strands_tracer, mock_use_span, mock_ag
mock_use_span.assert_called_once()


def test_graph_call_kwargs_deprecation_warning(mock_strands_tracer, mock_use_span, mock_agents):
"""Test that __call__ emits deprecation warning when kwargs are passed outside invocation_state."""
builder = GraphBuilder()
builder.add_node(mock_agents["start_agent"], "start_agent")
builder.set_entry_point("start_agent")

graph = builder.build()

with pytest.warns(UserWarning, match=r"\*\*kwargs.*parameter is deprecating"):
graph("Test task", custom_param="custom_value")


def test_graph_validate_unsupported_features():
"""Test Graph validation for session persistence and callbacks."""
# Test with normal agent (should work)
Expand Down
9 changes: 9 additions & 0 deletions tests/strands/multiagent/test_swarm.py
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,15 @@ def test_swarm_synchronous_execution(mock_strands_tracer, mock_use_span, mock_ag
mock_use_span.assert_called_once()


def test_swarm_call_kwargs_deprecation_warning(mock_strands_tracer, mock_use_span, mock_agents):
"""Test that __call__ emits deprecation warning when kwargs are passed outside invocation_state."""
agents = list(mock_agents.values())
swarm = Swarm(nodes=agents)

with pytest.warns(UserWarning, match=r"\*\*kwargs.*parameter is deprecating"):
swarm("Test task", custom_param="custom_value")


def test_swarm_builder_validation(mock_agents):
"""Test swarm builder validation and error handling."""
# Test agent name assignment
Expand Down
Loading