{"record":{"id":"7f4035efc447f61f","repo":"microsoft/semantic-kernel","slug":"chat-is-already-complete","errorCode":null,"errorMessage":"Chat is already complete","messagePattern":"Chat is already complete","errorType":"exception","errorClass":"AgentChatException","httpStatus":null,"severity":"warning","filePath":"python/semantic_kernel/agents/group_chat/agent_group_chat.py","lineNumber":145,"sourceCode":"        \"\"\"\n        if agent is not None:\n            if is_joining:\n                self.add_agent(agent)\n\n            async for message in super().invoke_agent(agent):\n                if message.role == AuthorRole.ASSISTANT:\n                    task = self.termination_strategy.should_terminate(agent, self.history.messages)\n                    self.is_complete = await task\n                yield message\n\n            return\n\n        if not self.agents:\n            raise AgentChatException(\"No agents are available\")\n\n        if self.is_complete:\n            if not self.termination_strategy.automatic_reset:\n                raise AgentChatException(\"Chat is already complete\")\n\n            self.is_complete = False\n\n        for _ in range(self.termination_strategy.maximum_iterations):\n            try:\n                selected_agent = await self.selection_strategy.next(self.agents, self.history.messages)\n            except Exception as ex:\n                logger.error(f\"Failed to select agent: {ex}\")\n                raise AgentChatException(\"Failed to select agent\") from ex\n\n            async for message in super().invoke_agent(selected_agent):\n                if message.role == AuthorRole.ASSISTANT:\n                    task = self.termination_strategy.should_terminate(selected_agent, self.history.messages)\n                    self.is_complete = await task\n                yield message\n\n            if self.is_complete:\n                break","sourceCodeStart":127,"sourceCodeEnd":163,"githubUrl":"https://github.com/microsoft/semantic-kernel/blob/c028a0c7dc4f0814cdcbaba9d998f187a41197bf/python/semantic_kernel/agents/group_chat/agent_group_chat.py#L127-L163","documentation":"Raised by AgentGroupChat.invoke() when self.is_complete is True and the termination_strategy.automatic_reset is False. The chat has already terminated (termination strategy returned True in a prior iteration), and without automatic reset the chat refuses to continue. It is an AgentChatException.","triggerScenarios":"Calling chat.invoke() (no agent arg) after the group chat already reached its termination condition in a previous invoke call, using a termination strategy where automatic_reset is False (the default for many strategies).","commonSituations":"Calling invoke() multiple times in a loop without resetting; using DefaultTerminationStrategy or a custom strategy with automatic_reset=False; not realizing the chat auto-completed after maximum_iterations or a keyword match.","solutions":["Call chat.is_complete = False (or chat.reset()) before re-invoking if you intentionally want to continue.","Set automatic_reset=True on the termination strategy so the flag clears automatically on the next invoke.","Pass a specific agent via chat.invoke(agent) for single-agent turns, which bypasses the completion check.","Construct a fresh AgentGroupChat if the prior conversation is truly finished."],"exampleFix":"# before\ntermination = DefaultTerminationStrategy(automatic_reset=False)\nchat = AgentGroupChat(agents=[a1, a2], termination_strategy=termination)\nasync for msg in chat.invoke(): ...\nasync for msg in chat.invoke(): ...  # raises \"already complete\"\n\n# after\ntermination = DefaultTerminationStrategy(automatic_reset=True)\nchat = AgentGroupChat(agents=[a1, a2], termination_strategy=termination)\nasync for msg in chat.invoke(): ...\nasync for msg in chat.invoke(): ...  # auto-resets","handlingStrategy":"validation","validationCode":"if chat.is_complete:\n    chat.is_complete = False  # or chat.reset()\nasync for msg in chat.invoke():\n    ...","typeGuard":null,"tryCatchPattern":"from semantic_kernel.exceptions.agent_exceptions import AgentChatException\n\ntry:\n    async for msg in chat.invoke():\n        ...\nexcept AgentChatException as exc:\n    if \"already complete\" in str(exc):\n        chat.is_complete = False\n        async for msg in chat.invoke():\n            ...\n    raise","preventionTips":["Set automatic_reset=True on the termination strategy for repeated sessions.","Check chat.is_complete before calling invoke and reset if needed.","Use chat.invoke(agent) for single-agent turns which bypass the completion check."],"tags":["lifecycle","group-chat","termination"],"backgroundTag":null,"analyzedSha":"c028a0c7dc4f0814cdcbaba9d998f187a41197bf","analyzedAt":"2026-08-13T13:48:05.040Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}