microsoft/semantic-kernel · error · RuntimeError

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

Error message

Agent "{self._agent.name}" did not return any response nor did not set a handoff agent name.

What it means

Raised as a RuntimeError in the handoff loop when the agent's invocation returned None (no response content) AND no handoff target was set (self._handoff_agent_name is falsy). The handoff orchestration expects an agent to either produce a response or delegate to another agent; doing neither is a dead end, so it fails.

Source

Thrown at python/semantic_kernel/agents/orchestration/handoffs.py:287

    async def _handle_request_message(self, message: HandoffRequestMessage, cts: MessageContext) -> None:
        """Handle a request message from an agent in the handoff group."""
        if message.agent_name != self._agent.name:
            return
        logger.debug(f"{self.id}: Received handoff request message.")

        response = await self._invoke_agent_with_potentially_no_response(kernel=self._kernel)

        while not self._task_completed:
            if self._handoff_agent_name:
                await self.publish_message(
                    HandoffRequestMessage(agent_name=self._handoff_agent_name),
                    TopicId(self._internal_topic_type, self.id.key),
                )
                self._handoff_agent_name = None
                break

            if response is None:
                raise RuntimeError(
                    f'Agent "{self._agent.name}" did not return any response nor did not set a handoff agent name.'
                )

            await self.publish_message(
                HandoffResponseMessage(body=response),
                TopicId(self._internal_topic_type, self.id.key),
                cancellation_token=cts.cancellation_token,
            )

            if self._human_response_function:
                human_response = await self._call_human_response_function()
                await self.publish_message(
                    HandoffResponseMessage(body=human_response),
                    TopicId(self._internal_topic_type, self.id.key),
                    cancellation_token=cts.cancellation_token,
                )
                response = await self._invoke_agent_with_potentially_no_response(
                    additional_messages=human_response,

View on GitHub (pinned to c028a0c7dc)

Solutions

  1. Inspect the agent in isolation: confirm it returns a ChatMessageContent or emits a handoff-selection function call.
  2. Ensure the handoff selection tool/plugin is registered so the agent can name the next agent.
  3. If a human_response_function is set, verify it returns a valid response.
  4. Make the agent's instructions explicitly require either an answer or a handoff decision.

Example fix

# Debug the agent standalone to confirm it produces output or a handoff call:
async for msg in agent.invoke(messages, thread=thread):
    print(msg)
# Fix instructions so the agent always answers or selects a handoff:
agent = ChatCompletionAgent(
    service=svc, name="triage",
    instructions="Either answer the user or call the handoff_to function with the next agent.",
)
Defensive patterns

Strategy: validation

Validate before calling

# Confirm the agent produces output or a handoff call before running the orchestration:
async def agent_produces(agent, messages, thread):
    found = False
    async for msg in agent.invoke(messages, thread=thread):
        found = True
    return found

Try / catch

try:
    result = await handoff_orchestration.invoke(messages, runtime=runtime)
except RuntimeError as ex:
    if "did not return any response" in str(ex):
        # inspect the agent directly; fix instructions/handoff tool
        ...

Prevention

When it happens

Trigger: _invoke_agent_with_potentially_no_response returns None, the loop continues, and because no HandoffRequestMessage was published (the agent did not select a handoff via a select-plugin response), the code reaches `if response is None: raise`. Happens when an agent silently returns nothing and does not choose a handoff.

Common situations: An agent whose tool/function returned terminate without producing output; an agent misconfigured so its completion yields an empty message; the handoff-selection plugin not wired correctly so the agent cannot name a successor; a human_response_function path that returned None; model returning empty content with no tool call.

Related errors


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