mirror of
https://github.com/microsoft/autogen.git
synced 2026-04-20 03:02:16 -04:00
Fix-swarm-handoff (#4198)
* fix select speaker for swarm * Fix max-turn = 1 for swarm
This commit is contained in:
@@ -791,3 +791,27 @@ async def test_swarm_handoff_using_tool_calls(monkeypatch: pytest.MonkeyPatch) -
|
||||
else:
|
||||
assert message == result.messages[index]
|
||||
index += 1
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_swarm_pause_and_resume() -> None:
|
||||
first_agent = _HandOffAgent("first_agent", description="first agent", next_agent="second_agent")
|
||||
second_agent = _HandOffAgent("second_agent", description="second agent", next_agent="third_agent")
|
||||
third_agent = _HandOffAgent("third_agent", description="third agent", next_agent="first_agent")
|
||||
|
||||
team = Swarm([second_agent, first_agent, third_agent], max_turns=1)
|
||||
result = await team.run(task="task")
|
||||
assert len(result.messages) == 2
|
||||
assert result.messages[0].content == "task"
|
||||
assert result.messages[1].content == "Transferred to third_agent."
|
||||
|
||||
# Resume with a new task.
|
||||
result = await team.run(task="new task")
|
||||
assert len(result.messages) == 2
|
||||
assert result.messages[0].content == "new task"
|
||||
assert result.messages[1].content == "Transferred to first_agent."
|
||||
|
||||
# Resume with the same task.
|
||||
result = await team.run()
|
||||
assert len(result.messages) == 1
|
||||
assert result.messages[0].content == "Transferred to second_agent."
|
||||
|
||||
Reference in New Issue
Block a user