{"record":{"id":"2a92591a87f61f6d","repo":"microsoft/autogen","slug":"the-group-chat-is-currently-running-it-must-be-st","errorCode":null,"errorMessage":"The group chat is currently running. It must be stopped before it can be reset.","messagePattern":"The group chat is currently running\\. It must be stopped before it can be reset\\.","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"python/packages/autogen-agentchat/src/autogen_agentchat/teams/_group_chat/_base_group_chat.py","lineNumber":624,"sourceCode":"                stream = team.run_stream(task=\"Count from 1 to 10, respond one at a time.\")\n                async for message in stream:\n                    print(message)\n\n                # Reset the team.\n                await team.reset()\n                stream = team.run_stream(task=\"Count from 1 to 10, respond one at a time.\")\n                async for message in stream:\n                    print(message)\n\n\n            asyncio.run(main())\n        \"\"\"\n\n        if not self._initialized:\n            await self._init(self._runtime)\n\n        if self._is_running:\n            raise RuntimeError(\"The group chat is currently running. It must be stopped before it can be reset.\")\n        self._is_running = True\n\n        if self._embedded_runtime:\n            # Start the runtime.\n            assert isinstance(self._runtime, SingleThreadedAgentRuntime)\n            self._runtime.start()\n\n        try:\n            # Send a reset messages to all participants.\n            for participant_topic_type in self._participant_topic_types:\n                await self._runtime.send_message(\n                    GroupChatReset(),\n                    recipient=AgentId(type=participant_topic_type, key=self._team_id),\n                )\n            # Send a reset message to the group chat manager.\n            await self._runtime.send_message(\n                GroupChatReset(),\n                recipient=AgentId(type=self._group_chat_manager_topic_type, key=self._team_id),","sourceCodeStart":606,"sourceCodeEnd":642,"githubUrl":"https://github.com/microsoft/autogen/blob/027ecf0a379bcc1d09956d46d12d44a3ad9cee14/python/packages/autogen-agentchat/src/autogen_agentchat/teams/_group_chat/_base_group_chat.py#L606-L642","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"# before\nstream = team.run_stream(task=\"hi\")\nasync for msg in stream: break\nawait team.reset_state()  # RuntimeError\n\n# after\nstream = team.run_stream(task=\"hi\")\nasync for msg in stream: break\nawait stream.aclose()\nawait team.reset_state()","handlingStrategy":"validation","validationCode":"async with team_lock:\n    # run to completion inside the same critical section\n    async for _ in team.run_stream(task=task):\n        pass\n    await team.reset_state()","typeGuard":null,"tryCatchPattern":"try:\n    await team.reset_state()\nexcept RuntimeError as e:\n    if \"must be stopped\" in str(e):\n        await stream.aclose()  # release the running flag, then retry\n        await team.reset_state()\n    else:\n        raise","preventionTips":["Only reset between runs, never during one.","Share a lock between run and reset paths.","Close abandoned run_stream generators promptly."],"tags":["python","autogen","lifecycle","reset","asyncio"],"backgroundTag":null,"analyzedSha":"027ecf0a379bcc1d09956d46d12d44a3ad9cee14","analyzedAt":"2026-08-15T03:38:00.719Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}