Copilot Agent response does not persist in the chat history

Vinod 0 Reputation points Microsoft Employee
2025-05-29T06:32:26.37+00:00

Developed an M365 agent using Microsoft M365 Agent Toolkit. Added an API as an action to the agent. Using this agent in the M365 Copilot. Agent is showing the answers returned by the api.

But there is an issue with the chat history of this agent. Chat history does not persist the response from the copilot. Though, questions asked by me and the adaptive cards part of the answer from copilot persist.

I have not deployed this agent at organization level. I am simply provisioning using the M365 agent toolkit in VS Code.

Microsoft Copilot | Other
{count} votes

1 answer

Sort by: Most helpful
  1. Ayush Giri 245 Reputation points Microsoft External Staff
    2025-05-30T05:22:27.06+00:00

    Hi Vinod,

    This behavior is typically due to the agent rendering responses dynamically in the frontend without using the Bot Framework’s sendActivity() method. Only messages sent using supported formats (e.g., plain text, adaptive cards) and through the correct SDK methods are persisted in the chat transcript. Solution

    Use context.sendActivity() to send all responses:

    await context.sendActivity({  

    type: 'message',  

    text: 'Your API response here',  

    attachments: [adaptiveCard] }); ```  

     

    Avoid frontend-only rendering: Ensure that all responses are sent through the Bot Framework, not just displayed in the UI. Verify SDK Initialization: Ensure the Teams SDK is properly initialized and the app is hosted in a Teams-compatible context. Check MCP Server/Client Setup: If using MCP, confirm that the server is configured to persist responses and update resource data accordingly.

    Supporting Documentation

    Microsoft Learn: Add your agent to Teams

    [11-8-2024] CZD Copilot and AI Standup – Highlights the need to upgrade support for conversation history  [DAS AI Ready - AI Padawan Series] Mastering DFM Copilot - Rodrigo's Version  – Emphasizes the importance of feedback and response tracking  Build your own copilot chat.docx– Discusses best practices for building persistent and interactive Copilot agents 


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.