microsoft/semantic-kernel · error · AgentInvokeException

No response from DirectLine Bot.

Error message

No response from DirectLine Bot.

What it means

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).

Source

Thrown at python/samples/demos/copilot_studio_agent/src/direct_line_agent.py:99

            raise AgentInvokeException("Exception occurred while fetching token.") from ex

    @trace_agent_get_response
    @override
    async def get_response(
        self,
        history: ChatHistory,
        arguments: dict[str, Any] | None = None,
        **kwargs: Any,
    ) -> ChatMessageContent:
        """
        Get a response from the DirectLine Bot.
        """
        responses = []
        async for response in self.invoke(history, arguments, **kwargs):
            responses.append(response)

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

        return responses[0]

    @trace_agent_invocation
    @override
    async def invoke(
        self,
        history: ChatHistory,
        arguments: dict[str, Any] | None = None,
        **kwargs: Any,
    ) -> AsyncIterable[ChatMessageContent]:
        """
        Send the latest message from the chat history to the DirectLine Bot
        and yield responses. This sends the payload after ensuring that:
          1. The token is fetched.
          2. A conversation is started.
          3. The activity payload is posted.
          4. Activities are polled until an event "DynamicPlanFinished" is received.

View on GitHub (pinned to c028a0c7dc)

Solutions

  1. Inspect the raw activities collected during invoke (enable debug logging) to see what roles/types arrived.
  2. Verify the conversation is live and the posted activity was accepted (check the post-activity response).
  3. Confirm the bot is configured to reply with message-type activities from a non-user role.

Example fix

// before
responses = []
async for response in self.invoke(history, arguments, **kwargs):
    responses.append(response)
if not responses:
    raise AgentInvokeException("No response from DirectLine Bot.")

// after  # log raw activities for diagnosis first
responses = []
async for response in self.invoke(history, arguments, **kwargs):
    responses.append(response)
if not responses:
    logger.debug("Raw response_data was: %s", last_response_data)
    raise AgentInvokeException("No response from DirectLine Bot.")
Defensive patterns

Strategy: try-catch

Try / catch

try:
    resp = await agent.get_response(history)
except AgentInvokeException as e:
    if "No response" in str(e):
        logger.warning("Bot produced no message activities; check filters/role mapping.")
    raise

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


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