You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
In a GraphFlow that includes a loop with exit and conditional branching, adding an edge to join into the terminal node causes a RuntimeError: No available speakers found.
To Reproduce
You can reproduce this with the following code. If you omit the linebuilder.add_edge(agent_c, agent_e), it works normally.
importasynciofromautogen_agentchat.agentsimportAssistantAgentfromautogen_agentchat.conditionsimportMaxMessageTerminationfromautogen_agentchat.teamsimportDiGraphBuilder, GraphFlowfromautogen_agentchat.uiimportConsolefromautogen_core.toolsimportFunctionToolfromautogen_ext.models.openaiimportOpenAIChatCompletionClientasyncdefmain():
# Initialize agents with OpenAI model clients.model_client=OpenAIChatCompletionClient(model="gpt-4.1-nano")
agent_a=AssistantAgent(
"A",
model_client=model_client,
system_message="Search the web.",
tools=[web_search_function_tool],
)
agent_b=AssistantAgent(
"B",
model_client=model_client,
system_message="Determine whether the previous agent obtained the optimal result for the user’s question. ""If the optimal result is found, respond with 'APPROVE'. ""If another search should be conducted, respond with 'SEARCH_AGAIN'. ""If multiple searches yield no relevant results, respond with 'NOT_FOUND'.",
)
agent_c=AssistantAgent(
"C",
model_client=model_client,
system_message="Use the search results to answer your question",
)
agent_d=AssistantAgent(
"D", model_client=model_client, system_message="You are a helpful assistant."
)
agent_e=AssistantAgent(
"E", model_client=model_client, system_message="Translate input to Japanese."
)
# Create a directed graph with conditional branching and loopbuilder=DiGraphBuilder()
builder.add_node(agent_a).add_node(agent_b).add_node(agent_c).add_node(
agent_d
).add_node(agent_e)
builder.add_edge(agent_a, agent_b)
builder.add_edge(agent_b, agent_a, condition="SEARCH_AGAIN")
builder.add_edge(agent_b, agent_c, condition="APPROVE")
builder.add_edge(agent_b, agent_d, condition="NOT_FOUND")
builder.add_edge(
agent_c, agent_e
) # if this line added, `RuntimeError: No available speakers found.` will be raised.builder.add_edge(agent_d, agent_e)
builder.set_entry_point(agent_a)
graph=builder.build()
# Create a GraphFlow team with the directed graph.team=GraphFlow(
participants=builder.get_participants(),
graph=graph,
termination_condition=MaxMessageTermination(10),
)
# Run the team and print the events.# await Console(team.run_stream(task="What is AutoGen?"))awaitConsole(team.run_stream(task="What is LangGraph?"))
asyncdefweb_search_func(query: str) ->str:
"""Find information on the web"""if"autogen"inquery.lower():
return (
"AutoGen is a programming framework for building multi-agent applications."
)
return"No results."web_search_function_tool=FunctionTool(
web_search_func, description="Find information on the web"
)
if__name__=="__main__":
asyncio.run(main())
Expected behavior
After starting at A → B, the flow should then either:
Loop B → A → B as long as the exit condition isn’t met,
Transition B → C → E, or
Transition B → D → E.
Screenshots
% rye run python main.py
---------- TextMessage (user) ----------
What is LangGraph?
---------- ToolCallRequestEvent (A) ----------
[FunctionCall(id='call_bUdgTvWyZ0eE0gCxp2J99ycJ', arguments='{"query":"What is LangGraph?"}', name='web_search_func')]
---------- ToolCallExecutionEvent (A) ----------
[FunctionExecutionResult(content='No results.', name='web_search_func', call_id='call_bUdgTvWyZ0eE0gCxp2J99ycJ', is_error=False)]
---------- ToolCallSummaryMessage (A) ----------
No results.
---------- TextMessage (B) ----------
SEARCH_AGAIN
---------- ToolCallRequestEvent (A) ----------
[FunctionCall(id='call_x5uTwkIbS7iL4Wckpb5S16vn', arguments='{"query": "What is LangGraph?"}', name='web_search_func')]
---------- ToolCallExecutionEvent (A) ----------
[FunctionExecutionResult(content='No results.', name='web_search_func', call_id='call_x5uTwkIbS7iL4Wckpb5S16vn', is_error=False)]
---------- ToolCallSummaryMessage (A) ----------
No results.
---------- TextMessage (B) ----------
NOT_FOUND
---------- TextMessage (D) ----------
It appears that there is no available information on "LangGraph" at this time. If you have more context or specific details about what LangGraph refers to, please share them, and I'll do my best to assist you further.
Error processing publish message for GraphManager_17f14989-847d-4561-994e-9c30d7068b5b/17f14989-847d-4561-994e-9c30d7068b5b
Traceback (most recent call last):
File "/Users/sogo/tmp/ag/.venv/lib/python3.12/site-packages/autogen_core/_single_threaded_agent_runtime.py", line 604, in _on_message
return await agent.on_message(
^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/sogo/tmp/ag/.venv/lib/python3.12/site-packages/autogen_core/_base_agent.py", line 119, in on_message
return await self.on_message_impl(message, ctx)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/sogo/tmp/ag/.venv/lib/python3.12/site-packages/autogen_agentchat/teams/_group_chat/_sequential_routed_agent.py", line 67, in on_message_impl
return await super().on_message_impl(message, ctx)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/sogo/tmp/ag/.venv/lib/python3.12/site-packages/autogen_core/_routed_agent.py", line 485, in on_message_impl
return await h(self, message, ctx)
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/sogo/tmp/ag/.venv/lib/python3.12/site-packages/autogen_core/_routed_agent.py", line 268, in wrapper
return_value = await func(self, message, ctx) # type: ignore
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/sogo/tmp/ag/.venv/lib/python3.12/site-packages/autogen_agentchat/teams/_group_chat/_base_group_chat_manager.py", line 165, in handle_agent_response
speaker_name = await speaker_name_future
^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/sogo/tmp/ag/.venv/lib/python3.12/site-packages/autogen_agentchat/teams/_group_chat/_graph/_digraph_group_chat.py", line 357, in select_speaker
raise RuntimeError("No available speakers found.")
RuntimeError: No available speakers found.
Traceback (most recent call last):
File "/Users/sogo/tmp/ag/main.py", line 81, in <module>
asyncio.run(main())
File "/Users/sogo/.rye/py/cpython@3.12.2/lib/python3.12/asyncio/runners.py", line 194, in run
return runner.run(main)
^^^^^^^^^^^^^^^^
File "/Users/sogo/.rye/py/cpython@3.12.2/lib/python3.12/asyncio/runners.py", line 118, in run
return self._loop.run_until_complete(task)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/sogo/.rye/py/cpython@3.12.2/lib/python3.12/asyncio/base_events.py", line 685, in run_until_complete
return future.result()
^^^^^^^^^^^^^^^
File "/Users/sogo/tmp/ag/main.py", line 63, in main
await Console(team.run_stream(task="What is LangGraph?"))
File "/Users/sogo/tmp/ag/.venv/lib/python3.12/site-packages/autogen_agentchat/ui/_console.py", line 117, in Console
async for message in stream:
File "/Users/sogo/tmp/ag/.venv/lib/python3.12/site-packages/autogen_agentchat/teams/_group_chat/_base_group_chat.py", line 518, in run_stream
raise RuntimeError(str(message.error))
RuntimeError: RuntimeError: No available speakers found.
Traceback:
Traceback (most recent call last):
File "/Users/sogo/tmp/ag/.venv/lib/python3.12/site-packages/autogen_agentchat/teams/_group_chat/_base_group_chat_manager.py", line 165, in handle_agent_response
speaker_name = await speaker_name_future
^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/sogo/tmp/ag/.venv/lib/python3.12/site-packages/autogen_agentchat/teams/_group_chat/_graph/_digraph_group_chat.py", line 357, in select_speaker
raise RuntimeError("No available speakers found.")
RuntimeError: No available speakers found.
Additional context
Add any other context about the problem here.
Which packages was the bug in?
Python AgentChat (autogen-agentchat>=0.4.0)
AutoGen library version.
Python 0.5.7
Other library version.
No response
Model used
gpt-4.1-nano
Model provider
OpenAI
Other model provider
No response
Python version
3.12
.NET version
None
Operating system
MacOS
The text was updated successfully, but these errors were encountered:
I have a similar problem,
i have the flow
A -> B -> C -> D
conditional:
D -> C "OR" D -> E
then
E -> C "OR" E -> F
this give me the same error at the step B -> C of the linear flow (it don't see the C speaker)
if I Remove the conditional part of the flow, then the error disappear
In the example above, agent D only has a single, unconditional edge to agent E, yet GraphFlow still fails to find that next node. This suggests that even non-conditional outgoing edges are ignored.
What happened?
Describe the bug
In a GraphFlow that includes a loop with exit and conditional branching, adding an edge to join into the terminal node causes a
RuntimeError: No available speakers found.
To Reproduce
You can reproduce this with the following code. If you omit the line
builder.add_edge(agent_c, agent_e)
, it works normally.Expected behavior
After starting at A → B, the flow should then either:
Screenshots
Additional context
Add any other context about the problem here.
Which packages was the bug in?
Python AgentChat (autogen-agentchat>=0.4.0)
AutoGen library version.
Python 0.5.7
Other library version.
No response
Model used
gpt-4.1-nano
Model provider
OpenAI
Other model provider
No response
Python version
3.12
.NET version
None
Operating system
MacOS
The text was updated successfully, but these errors were encountered: