microsoft/semantic-kernel · warning · AgentChatException

Chat is already complete

Error message

Chat is already complete

What it means

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.

Source

Thrown at python/semantic_kernel/agents/group_chat/agent_group_chat.py:145

        """
        if agent is not None:
            if is_joining:
                self.add_agent(agent)

            async for message in super().invoke_agent(agent):
                if message.role == AuthorRole.ASSISTANT:
                    task = self.termination_strategy.should_terminate(agent, self.history.messages)
                    self.is_complete = await task
                yield message

            return

        if not self.agents:
            raise AgentChatException("No agents are available")

        if self.is_complete:
            if not self.termination_strategy.automatic_reset:
                raise AgentChatException("Chat is already complete")

            self.is_complete = False

        for _ in range(self.termination_strategy.maximum_iterations):
            try:
                selected_agent = await self.selection_strategy.next(self.agents, self.history.messages)
            except Exception as ex:
                logger.error(f"Failed to select agent: {ex}")
                raise AgentChatException("Failed to select agent") from ex

            async for message in super().invoke_agent(selected_agent):
                if message.role == AuthorRole.ASSISTANT:
                    task = self.termination_strategy.should_terminate(selected_agent, self.history.messages)
                    self.is_complete = await task
                yield message

            if self.is_complete:
                break

View on GitHub (pinned to c028a0c7dc)

Solutions

  1. Call chat.is_complete = False (or chat.reset()) before re-invoking if you intentionally want to continue.
  2. Set automatic_reset=True on the termination strategy so the flag clears automatically on the next invoke.
  3. Pass a specific agent via chat.invoke(agent) for single-agent turns, which bypasses the completion check.
  4. Construct a fresh AgentGroupChat if the prior conversation is truly finished.

Example fix

# before
termination = DefaultTerminationStrategy(automatic_reset=False)
chat = AgentGroupChat(agents=[a1, a2], termination_strategy=termination)
async for msg in chat.invoke(): ...
async for msg in chat.invoke(): ...  # raises "already complete"

# after
termination = DefaultTerminationStrategy(automatic_reset=True)
chat = AgentGroupChat(agents=[a1, a2], termination_strategy=termination)
async for msg in chat.invoke(): ...
async for msg in chat.invoke(): ...  # auto-resets
Defensive patterns

Strategy: validation

Validate before calling

if chat.is_complete:
    chat.is_complete = False  # or chat.reset()
async for msg in chat.invoke():
    ...

Try / catch

from semantic_kernel.exceptions.agent_exceptions import AgentChatException

try:
    async for msg in chat.invoke():
        ...
except AgentChatException as exc:
    if "already complete" in str(exc):
        chat.is_complete = False
        async for msg in chat.invoke():
            ...
    raise

Prevention

When it happens

Trigger: 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).

Common situations: 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.

Related errors


AI-assisted analysis of microsoft/semantic-kernel@c028a0c7dc (2026-08-13). Data as JSON: /api/errors/7f4035efc447f61f. Report an issue: GitHub.