{"record":{"id":"7cb1677932e27d04","repo":"microsoft/semantic-kernel","slug":"no-response-from-directline-bot","errorCode":null,"errorMessage":"No response from DirectLine Bot.","messagePattern":"No response from DirectLine Bot\\.","errorType":"exception","errorClass":"AgentInvokeException","httpStatus":null,"severity":"error","filePath":"python/samples/demos/copilot_studio_agent/src/direct_line_agent.py","lineNumber":99,"sourceCode":"            raise AgentInvokeException(\"Exception occurred while fetching token.\") from ex\n\n    @trace_agent_get_response\n    @override\n    async def get_response(\n        self,\n        history: ChatHistory,\n        arguments: dict[str, Any] | None = None,\n        **kwargs: Any,\n    ) -> ChatMessageContent:\n        \"\"\"\n        Get a response from the DirectLine Bot.\n        \"\"\"\n        responses = []\n        async for response in self.invoke(history, arguments, **kwargs):\n            responses.append(response)\n\n        if not responses:\n            raise AgentInvokeException(\"No response from DirectLine Bot.\")\n\n        return responses[0]\n\n    @trace_agent_invocation\n    @override\n    async def invoke(\n        self,\n        history: ChatHistory,\n        arguments: dict[str, Any] | None = None,\n        **kwargs: Any,\n    ) -> AsyncIterable[ChatMessageContent]:\n        \"\"\"\n        Send the latest message from the chat history to the DirectLine Bot\n        and yield responses. This sends the payload after ensuring that:\n          1. The token is fetched.\n          2. A conversation is started.\n          3. The activity payload is posted.\n          4. Activities are polled until an event \"DynamicPlanFinished\" is received.","sourceCodeStart":81,"sourceCodeEnd":117,"githubUrl":"https://github.com/microsoft/semantic-kernel/blob/c028a0c7dc4f0814cdcbaba9d998f187a41197bf/python/samples/demos/copilot_studio_agent/src/direct_line_agent.py#L81-L117","documentation":"An AgentInvokeException raised in get_response() when invoke() yields zero response messages. The method collects all streamed responses; if none arrive it cannot return a ChatMessageContent and aborts. This typically means the bot produced no message activities meeting the filter criteria (non-user 'message'/'bot' role activities).","triggerScenarios":"self.invoke(history) completes its async iteration producing an empty list — the bot returned only non-message activities, only user-originated activities, or ended without any reply.","commonSituations":"The DirectLine bot didn't process the activity (conversation desync); the DynamicPlanFinished event fired but no assistant message preceded it; role filtering dropped all activities because 'from.role' was unexpected.","solutions":["Inspect the raw activities collected during invoke (enable debug logging) to see what roles/types arrived.","Verify the conversation is live and the posted activity was accepted (check the post-activity response).","Confirm the bot is configured to reply with message-type activities from a non-user role."],"exampleFix":"// before\nresponses = []\nasync for response in self.invoke(history, arguments, **kwargs):\n    responses.append(response)\nif not responses:\n    raise AgentInvokeException(\"No response from DirectLine Bot.\")\n\n// after  # log raw activities for diagnosis first\nresponses = []\nasync for response in self.invoke(history, arguments, **kwargs):\n    responses.append(response)\nif not responses:\n    logger.debug(\"Raw response_data was: %s\", last_response_data)\n    raise AgentInvokeException(\"No response from DirectLine Bot.\")","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try:\n    resp = await agent.get_response(history)\nexcept AgentInvokeException as e:\n    if \"No response\" in str(e):\n        logger.warning(\"Bot produced no message activities; check filters/role mapping.\")\n    raise","preventionTips":["Log all raw activities during invoke to confirm role/type filtering isn't dropping valid replies.","Verify the conversation is live before calling get_response."],"tags":["runtime","directline","copilot-studio","semantic-kernel"],"backgroundTag":null,"analyzedSha":"c028a0c7dc4f0814cdcbaba9d998f187a41197bf","analyzedAt":"2026-08-13T13:48:05.040Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}