{"record":{"id":"cad2fc47bd327bb0","repo":"microsoft/semantic-kernel","slug":"no-response-from-agent","errorCode":null,"errorMessage":"No response from agent.","messagePattern":"No response from agent\\.","errorType":"exception","errorClass":"AgentInvokeException","httpStatus":null,"severity":"error","filePath":"python/semantic_kernel/agents/chat_completion/chat_completion_agent.py","lineNumber":322,"sourceCode":"        assert thread.id is not None  # nosec\n\n        chat_history = ChatHistory()\n        async for message in thread.get_messages():\n            chat_history.add_message(message)\n\n        responses: list[ChatMessageContent] = []\n        async for response in self._inner_invoke(\n            thread,\n            chat_history,\n            None,\n            arguments,\n            kernel,\n            **kwargs,\n        ):\n            responses.append(response)\n\n        if not responses:\n            raise AgentInvokeException(\"No response from agent.\")\n\n        return AgentResponseItem(message=responses[-1], thread=thread)\n\n    @trace_agent_invocation\n    @override\n    async def invoke(\n        self,\n        messages: str | ChatMessageContent | list[str | ChatMessageContent] | None = None,\n        *,\n        thread: AgentThread | None = None,\n        on_intermediate_message: Callable[[ChatMessageContent], Awaitable[None]] | None = None,\n        arguments: KernelArguments | None = None,\n        kernel: \"Kernel | None\" = None,\n        **kwargs: Any,\n    ) -> AsyncIterable[AgentResponseItem[ChatMessageContent]]:\n        \"\"\"Invoke the chat history handler.\n\n        Args:","sourceCodeStart":304,"sourceCodeEnd":340,"githubUrl":"https://github.com/microsoft/semantic-kernel/blob/c028a0c7dc4f0814cdcbaba9d998f187a41197bf/python/semantic_kernel/agents/chat_completion/chat_completion_agent.py#L304-L340","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Check the prompt/history is non-empty and contains a user message before calling get_response.","Inspect function_choice_behavior: ensure it lets the model produce a final assistant response (e.g. Auto) rather than only RETURN_CONTROL.","Verify the chat completion service is configured and returning content (test the service directly).","Add logging around _inner_invoke to see what responses are produced; handle AgentInvokeException with a fallback message or retry."],"exampleFix":"// before\nresp = await agent.get_response('')  # empty prompt -> may raise\n// after\nresp = await agent.get_response('Summarize this: ...')\n// guard\ntry:\n    resp = await agent.get_response(prompt)\nexcept AgentInvokeException:\n    resp = None","handlingStrategy":"try-catch","validationCode":"if not (prompt and str(prompt).strip()):\n    raise ValueError('Prompt is empty; the agent may return no response')","typeGuard":null,"tryCatchPattern":"from semantic_kernel.exceptions.agent_exceptions import AgentInvokeException\ntry:\n    resp = await agent.get_response(prompt)\nexcept AgentInvokeException as e:\n    if 'No response' in str(e):\n        resp = None  # or retry with a clarified prompt\n    else: raise","preventionTips":["Ensure non-empty user prompt and history","Verify function_choice_behavior allows a final assistant message","Log _inner_invoke output to diagnose empty responses"],"tags":["chat-completion","invocation","empty-response","try-catch"],"backgroundTag":null,"analyzedSha":"c028a0c7dc4f0814cdcbaba9d998f187a41197bf","analyzedAt":"2026-08-13T13:48:05.040Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}