Building and customizing solutions using Microsoft 365 Copilot APIs and tools
The behavior described matches several known differences and limitations when running custom agents inside Microsoft 365 Copilot and Microsoft Teams compared to a standalone web experience.
Key points and checks:
- Teams-specific session and state behavior
- Teams retains conversation state across sessions. This can cause agents to appear “stuck” or to reuse outdated context when users return later.
- For agents built with Copilot Studio and deployed to Teams, configure an inactivity-based reset:
- Create a topic with the The user is inactive for a while trigger.
- Set a timeout (for example, 15 minutes).
- Add Clear variable values nodes to clear session variables and conversation history.
- End the conversation and mark the session as resolved.
- After reset, send a short message explaining that the conversation was cleared and how to restart. This improves stability and predictability when users come back in Teams.
- Manual reset for “stuck” conversations
- Provide a self-service reset command such as
/debug clearstateand document it for users. - This command should:
- Clear conversation state.
- Remove cached connector information.
- Reauthenticate connectors.
- Load the latest version of the agent.
- This is particularly useful in Teams where users may keep the same chat open for long periods and encounter intermittent issues.
- Provide a self-service reset command such as
- Testing under real Teams conditions
- Because Teams preserves state and runs the agent in an embedded environment, test specifically in Teams rather than only in the web channel:
- Deploy using Show to only me.
- Test long-running scenarios (leave the chat for hours and return).
- Publish updates and confirm the agent switches to the new version in Teams.
- Validate Adaptive Card rendering on desktop and mobile.
- Test actions in varied conversational contexts.
- Use this checklist to harden the deployment: inactivity trigger configured, reset messaging in place,
/debug clearstatedocumented, version identifier in responses, Force newest version enabled where appropriate, and Greeting topic containing initialization logic.
- Because Teams preserves state and runs the agent in an embedded environment, test specifically in Teams rather than only in the web channel:
- Known limitations for custom engine agents in Microsoft 365 Copilot / Teams
If the MSB Research Agent is implemented as a custom engine agent (using Microsoft 365 Agents Toolkit or Agents SDK) and surfaced in Microsoft 365 Copilot/Teams, be aware of these limitations that can manifest as “inconsistent” behavior compared to web:
- Conversation context: custom engine agents cannot access Copilot conversation history that occurred before the user @mentions the agent. This can make the agent appear to “forget” context when invoked mid-thread.
- Chat messages: messages are immutable;
updateActivityis not supported. Any design that relies on editing or replacing messages will not work in Teams/Copilot; use follow-up messages instead. - Adaptive Cards: cards refreshed via
Action.Executedo not persist their updated content when the chat is reopened; the original card is shown. For stable behavior, send new messages instead of relying on card updates. - File attachments: users cannot upload files to the agent chat, and the agent cannot return files for download. If the web experience depends on file upload/download, this will not translate directly to Teams.
- Rich cards and some Adaptive Card elements (for example, certain card types, dynamic refresh, @mentions, typeahead, password control) are not supported and may fail silently or behave unexpectedly.
- Microsoft 365 app support: custom engine agents are not supported in Outlook, Word, Excel, PowerPoint, or Microsoft Edge; ensure users are accessing the agent from supported entry points (Microsoft 365 Copilot and Teams).
- Teams app packaging and diagnostics
- For issues where the agent fails to load or respond, use the Teams Developer tools:
- Open the Teams client, go to the conversation where the agent is used.
- Open Settings and more (…) → More tools → Developer tools.
- On the Network tab, filter by
invokeand inspect failing calls. - Check the
standardizedErrorobject (errorCode,errorSubCode,errorDescription) in the response to identify API or configuration issues (for example, 400/401/403/500 errors).
- If issues persist and cannot be resolved from the network trace and OpenAPI-based testing, contact Microsoft Teams product support with the captured error details.
- For issues where the agent fails to load or respond, use the Teams Developer tools:
- DOM and iframe considerations (if using embedded pages)
- When loading Dynamics 365 or other web pages inside Teams, pages that rely on
window.topto access DOM elements can fail inside Teams because they are hosted in an iframe. This can lead to errors like “Blocked a frame with origin from accessing a cross-origin frame” and cause pages or scripts not to load correctly. - Avoid using
window.topin custom JavaScript resources when targeting Teams; instead, design logic that does not depend on accessing the top-level window.
- When loading Dynamics 365 or other web pages inside Teams, pages that rely on
- Known platform incidents
- For some scenarios (for example, publishing Foundry-based agents to Teams), transient platform issues have been resolved by Microsoft via hotfixes. If the same configuration previously worked and suddenly started failing only in Teams, verify current service health and consider retesting after some time or opening a support ticket with detailed error codes.
Applying these checks and adjustments typically stabilizes agent behavior in Teams and aligns it with the web experience, within the limits of what Microsoft 365 Copilot and Teams currently support for custom agents.
References:
- Troubleshoot Microsoft Teams integration with customer engagement apps in Dynamics 365
- Deploy agents in Microsoft Teams
- Known issues
- Running In Teams (csharp)
- Custom engine agents for Microsoft 365 overview
- Troubleshoot your Microsoft Teams app
- Microsoft Foundry publish to Teams Bot service error - Microsoft Q&A