Skip to content

Python: Enhance Copilot Studio Sample with AgentThread, Group Chat Support, and Rich Content #11461

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 22 commits into
base: main
Choose a base branch
from

Conversation

meghapatilcode
Copy link

Motivation and Context

This PR enhances the existing Copilot Studio sample by aligning it with recent Semantic Kernel architecture changes and extending its capabilities for broader usage scenarios. Specifically, it introduces three key improvements:

  • Agent Thread Implementation: Adds a CopilotAgentThread implementation to align with the introduction of agent threads in Semantic Kernel v1.26.0.

  • Channel Support for Group Chat: To enable Copilot Studio agents to participate in group conversations, this update includes a new CopilotStudioAgentChannel class. This allows channel-based invocation of agents.

  • Rich Content Handling: A new CopilotMessageContent class is introduced to handle the variety of content types returned by Copilot Studio agents. This includes not only plain text, but also adaptive cards and suggested actions, providing richer and more interactive responses in conversation flows.

Description

The following files were introduced or updated as part of this change to support Copilot Studio agent integration:

  • directline_client.py
    A new utility module that encapsulates all Direct Line API operations. It handles authentication, starts conversations, posts user activities, and retrieves bot responses using watermark-based polling. By extracting this logic from the agent, it provides clear separation between transport-level concerns and agent orchestration.

  • copilot_agent.py
    Defines the CopilotAgent, responsible for orchestrating interactions with a Copilot Studio bot via the Direct Line API. It serializes user messages, handles asynchronous polling for responses, and converts bot activities into structured message content.

  • copilot_agent_thread.py
    Implements the AgentThread interface for Copilot Studio conversations. It manages Direct Line-specific context such as conversation ID and watermark.

  • copilot_agent_channel.py
    Adds a CopilotStudioAgentChannel class, allowing Copilot Studio agents to participate in multi-agent group chats via the new channel-based invocation system.

  • copilot_message_content.py
    Introduces CopilotMessageContent, an extension of ChatMessageContent that can represent rich message types from Copilot Studio—including plain text, adaptive cards, and suggested actions.


Contribution Checklist

@markwallace-microsoft markwallace-microsoft added the python Pull requests for the Python Semantic Kernel label Apr 9, 2025
@meghapatilcode meghapatilcode marked this pull request as ready for review April 10, 2025 03:36
@meghapatilcode meghapatilcode requested a review from a team as a code owner April 10, 2025 03:36
@moonbox3
Copy link
Contributor

@meghapatilcode, sorry it's taken so long to get back on this: for agent orchestration, we're moving away from the pattern of using agent channels as part of group chat. Our new orchestration patterns leverage an InProcessRuntime, and any agent that inherits from our agent base class, is able to take part in the orchestration. Additionally, as the Copilot SDK/Agents SDK releases further updates related to using Copilot Agents through code via their clients, we're going to move that direction as it simplifies the interaction with the Copilot Studio Agent (there's no need to directly handle the DirectLineClient).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation python Pull requests for the Python Semantic Kernel
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants