microsoft/semantic-kernel · error · AgentInvokeException

No response from agent.

Error message

No response from agent.

What it means

Raised by ChatCompletionAgent.get_response (an AgentInvokeException) when the inner invocation produced no response messages. After streaming _inner_invoke and collecting responses, an empty list means the model/service returned nothing usable, so the agent cannot return an AgentResponseItem.

Source

Thrown at python/semantic_kernel/agents/chat_completion/chat_completion_agent.py:322

        assert thread.id is not None  # nosec

        chat_history = ChatHistory()
        async for message in thread.get_messages():
            chat_history.add_message(message)

        responses: list[ChatMessageContent] = []
        async for response in self._inner_invoke(
            thread,
            chat_history,
            None,
            arguments,
            kernel,
            **kwargs,
        ):
            responses.append(response)

        if not responses:
            raise AgentInvokeException("No response from agent.")

        return AgentResponseItem(message=responses[-1], thread=thread)

    @trace_agent_invocation
    @override
    async def invoke(
        self,
        messages: str | ChatMessageContent | list[str | ChatMessageContent] | None = None,
        *,
        thread: AgentThread | None = None,
        on_intermediate_message: Callable[[ChatMessageContent], Awaitable[None]] | None = None,
        arguments: KernelArguments | None = None,
        kernel: "Kernel | None" = None,
        **kwargs: Any,
    ) -> AsyncIterable[AgentResponseItem[ChatMessageContent]]:
        """Invoke the chat history handler.

        Args:

View on GitHub (pinned to c028a0c7dc)

Solutions

  1. Check the prompt/history is non-empty and contains a user message before calling get_response.
  2. Inspect function_choice_behavior: ensure it lets the model produce a final assistant response (e.g. Auto) rather than only RETURN_CONTROL.
  3. Verify the chat completion service is configured and returning content (test the service directly).
  4. Add logging around _inner_invoke to see what responses are produced; handle AgentInvokeException with a fallback message or retry.

Example fix

// before
resp = await agent.get_response('')  # empty prompt -> may raise
// after
resp = await agent.get_response('Summarize this: ...')
// guard
try:
    resp = await agent.get_response(prompt)
except AgentInvokeException:
    resp = None
Defensive patterns

Strategy: try-catch

Validate before calling

if not (prompt and str(prompt).strip()):
    raise ValueError('Prompt is empty; the agent may return no response')

Try / catch

from semantic_kernel.exceptions.agent_exceptions import AgentInvokeException
try:
    resp = await agent.get_response(prompt)
except AgentInvokeException as e:
    if 'No response' in str(e):
        resp = None  # or retry with a clarified prompt
    else: raise

Prevention

When it happens

Trigger: The chat completion service returns an empty completion (no choices/content); the service call is short-circuited by tool/filter behavior that yields no message; a misconfigured service returns a 200 with empty content; function-calling configuration suppresses the assistant message.

Common situations: Empty/blank prompts; overly aggressive content filters; a function_choice_behavior that returns control without a final assistant message; a custom service returning an empty list; misconfigured streaming that discards chunks.

Related errors


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