microsoft/semantic-kernel · error · RuntimeError

Agent "{self._agent.name}" did not return any response.

Error message

Agent "{self._agent.name}" did not return any response.

What it means

Raised as a RuntimeError in the streaming invoke path of AgentActorBase when the agent's invoke_stream async iterator yielded zero chunks (streaming_message_buffer is empty). It indicates the agent produced no streaming output at all, which is usually a symptom of an upstream error, an empty/filtered response, or a misconfigured streaming callback.

Source

Thrown at python/semantic_kernel/agents/orchestration/agent_actor_base.py:193

        async for response_item in self._agent.invoke_stream(
            messages,  # type: ignore[arg-type]
            thread=self._agent_thread,
            on_intermediate_message=self._handle_intermediate_message,
            **kwargs,
        ):
            # Buffer message chunks and stream them with correct is_final flag.
            streaming_message_buffer.append(response_item.message)
            if len(streaming_message_buffer) > 1:
                await self._call_streaming_agent_response_callback(streaming_message_buffer[-2], is_final=False)
            if self._agent_thread is None:
                self._agent_thread = response_item.thread

        if streaming_message_buffer:
            # Call the callback for the last message chunk with is_final=True.
            await self._call_streaming_agent_response_callback(streaming_message_buffer[-1], is_final=True)

        if not streaming_message_buffer:
            raise RuntimeError(f'Agent "{self._agent.name}" did not return any response.')

        # Build the full response from the streaming messages
        full_response = sum(streaming_message_buffer[1:], streaming_message_buffer[0])
        await self._call_agent_response_callback(full_response)

        return full_response

    def _create_messages(self, additional_messages: DefaultTypeAlias | None = None) -> list[ChatMessageContent]:
        """Create a list of messages to be sent to the agent along with a potential thread.

        Args:
            additional_messages (DefaultTypeAlias | None): Additional messages to be sent to the agent.

        Returns:
            list[ChatMessageContent]: A list of messages to be sent to the agent.
        """
        base_messages = self._message_cache.messages[:]

View on GitHub (pinned to c028a0c7dc)

Solutions

  1. Check the agent's logs / on_intermediate_message handler to see why no chunks were emitted.
  2. Verify the agent's instructions and inputs actually produce a response (test invoke directly outside the orchestration).
  3. Ensure the model/service is reachable and not returning empty due to content filtering or token limits.
  4. If using a custom agent, confirm invoke_stream yields at least one StreamingChatMessageContent.

Example fix

# Debug by invoking the agent directly to confirm it produces output:
async for chunk in agent.invoke_stream(messages, thread=thread):
    print(chunk)
# If empty, fix the agent config (model, instructions, tools) before running the orchestration.
Defensive patterns

Strategy: validation

Validate before calling

# Pre-check that the agent yields at least one chunk before running the orchestration:
async def agent_emits(agent, messages, thread):
    async for _ in agent.invoke_stream(messages, thread=thread):
        return True
    return False

Try / catch

try:
    result = await orchestration.invoke([...], runtime=runtime)
except RuntimeError as ex:
    if "did not return any response" in str(ex):
        # invoke the agent directly to diagnose
        ...

Prevention

When it happens

Trigger: self._agent.invoke_stream(...) completes its async iteration without yielding any response_item, so streaming_message_buffer stays empty. Happens when the agent returns an empty stream, when an exception inside the agent is swallowed, or when filtering drops everything.

Common situations: The underlying agent call failed silently or returned an empty completion; tool/function execution produced no text and the stream closed early; streaming callback misconfiguration; the model returned only reasoning with no output; bugs in a custom agent subclass that yields nothing.

Related errors


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