microsoft/autogen · error · RuntimeError
The group chat is currently running. It must be stopped befo
Error message
The group chat is currently running. It must be stopped before it can be reset.
What it means
reset_state() refuses to run while the team is mid-run: it initializes if needed, then checks _is_running and raises RuntimeError, because resetting participants during an active run would corrupt in-flight message routing and agent state.
Source
Thrown at python/packages/autogen-agentchat/src/autogen_agentchat/teams/_group_chat/_base_group_chat.py:624
stream = team.run_stream(task="Count from 1 to 10, respond one at a time.")
async for message in stream:
print(message)
# Reset the team.
await team.reset()
stream = team.run_stream(task="Count from 1 to 10, respond one at a time.")
async for message in stream:
print(message)
asyncio.run(main())
"""
if not self._initialized:
await self._init(self._runtime)
if self._is_running:
raise RuntimeError("The group chat is currently running. It must be stopped before it can be reset.")
self._is_running = True
if self._embedded_runtime:
# Start the runtime.
assert isinstance(self._runtime, SingleThreadedAgentRuntime)
self._runtime.start()
try:
# Send a reset messages to all participants.
for participant_topic_type in self._participant_topic_types:
await self._runtime.send_message(
GroupChatReset(),
recipient=AgentId(type=participant_topic_type, key=self._team_id),
)
# Send a reset message to the group chat manager.
await self._runtime.send_message(
GroupChatReset(),
recipient=AgentId(type=self._group_chat_manager_topic_type, key=self._team_id),View on GitHub (pinned to 027ecf0a37)
Solutions
- Finish or stop the current run first: consume run_stream to completion or await stream.aclose() / cancel the run task.
- Then call await team.reset_state().
- Guard resets with the same asyncio.Lock used to serialize runs.
Example fix
# before stream = team.run_stream(task="hi") async for msg in stream: break await team.reset_state() # RuntimeError # after stream = team.run_stream(task="hi") async for msg in stream: break await stream.aclose() await team.reset_state()
Defensive patterns
Strategy: validation
Validate before calling
async with team_lock:
# run to completion inside the same critical section
async for _ in team.run_stream(task=task):
pass
await team.reset_state() Try / catch
try:
await team.reset_state()
except RuntimeError as e:
if "must be stopped" in str(e):
await stream.aclose() # release the running flag, then retry
await team.reset_state()
else:
raise Prevention
- Only reset between runs, never during one.
- Share a lock between run and reset paths.
- Close abandoned run_stream generators promptly.
When it happens
Trigger: Calling await team.reset_state() (or the team.reset() alias) after starting run_stream but before the stream has fully completed — including when the consuming loop is merely paused between messages.
Common situations: Orchestrator code that starts a run in a background task and resets on a timer; calling reset after breaking out of an async for loop over run_stream without closing the generator.
Related errors
- The team is already running, it cannot run again until it is
- The team cannot be loaded while it is running.
- The group chat has not been initialized. It must be run befo
- The group chat has not been initialized. It must be run befo
- Connection is not open.
AI-assisted analysis of microsoft/autogen@027ecf0a37 (2026-08-15).
Data as JSON: /api/errors/2a92591a87f61f6d.
Report an issue: GitHub.