microsoft/semantic-kernel · error · RuntimeError

No messages in the chat history.

Error message

No messages in the chat history.

What it means

Thrown by the group-chat manager's filter_results when it is asked to summarize the discussion but chat_history.messages is empty. The result-filter prompt needs prior messages to synthesize a result; with none present it cannot proceed. This indicates the manager's filter was invoked before any participant contributed.

Source

Thrown at python/samples/getting_started_with_agents/multi_agent_orchestration/step3b_group_chat_with_chat_completion_manager.py:277

        )
        print("*********************")

        if participant_name_with_reason.result in participant_descriptions:
            return participant_name_with_reason

        raise RuntimeError(f"Unknown participant selected: {response.content}.")

    @override
    async def filter_results(
        self,
        chat_history: ChatHistory,
    ) -> MessageResult:
        """Provide concrete implementation for filtering the results of the discussion.

        The manager will filter the results of the conversation after the conversation is terminated.
        """
        if not chat_history.messages:
            raise RuntimeError("No messages in the chat history.")

        chat_history.messages.insert(
            0,
            ChatMessageContent(
                role=AuthorRole.SYSTEM,
                content=await self._render_prompt(
                    self.result_filter_prompt,
                    KernelArguments(topic=self.topic),
                ),
            ),
        )
        chat_history.add_message(
            ChatMessageContent(role=AuthorRole.USER, content="Please summarize the discussion."),
        )

        response = await self.service.get_chat_message_content(
            chat_history,
            settings=PromptExecutionSettings(response_format=StringResult),

View on GitHub (pinned to c028a0c7dc)

Solutions

  1. Review the selection and termination strategies so at least one participant produces a message before results are filtered.
  2. Guard filter_results to return a default message when chat_history.messages is empty instead of raising, if an empty discussion is legitimate.
  3. Ensure participants don't error out before contributing (check upstream agent exceptions).
  4. Confirm the orchestration isn't terminated by an immediate Exit condition.

Example fix

# before
if not chat_history.messages:
    raise RuntimeError("No messages in the chat history.")
# after (graceful default)
if not chat_history.messages:
    return MessageResult(result="No discussion occurred.", reason="Empty history.")
Defensive patterns

Strategy: validation

Validate before calling

if not chat_history.messages:
    # return a safe default rather than calling filter_results
    return MessageResult(result='No discussion occurred.', reason='Empty history.')

Type guard

def has_messages(chat_history) -> bool:
    return bool(getattr(chat_history, 'messages', None))

Try / catch

try:
    result = await manager.filter_results(chat_history)
except RuntimeError as e:
    if 'No messages' in str(e):
        result = MessageResult(result='No discussion occurred.', reason='Empty history.')
    else:
        raise

Prevention

When it happens

Trigger: filter_results called on a chat history that never received messages — e.g. every participant declined/errored, the conversation terminated immediately, or the termination condition fired before any turn.

Common situations: Misconfigured termination/selection policies that end the chat on the first turn before any agent speaks; an early Exit event or exception swallowing all messages; calling the manager manually with a fresh ChatHistory.

Related errors


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