Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
85 changes: 77 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,83 @@
# Project
# Microsoft 365 Agents SDK - Python

> This repo has been populated by an initial template to help get you started. Please
> make sure to update the content to build a great experience for community-building.
![Build Status](https://github.com/microsoft/Agents-for-python/actions/workflows/python-package.yml/badge.svg)
![PyPI Downloads](https://img.shields.io/pypi/dm/microsoft-agents-activity)

As the maintainer of this project, please make a few updates:
The Microsoft 365 Agent SDK simplifies building full stack, multichannel, trusted agents for platforms including M365, Teams, Copilot Studio, and Webchat. We also offer integrations with 3rd parties such as Facebook Messenger, Slack, or Twilio. The SDK provides developers with the building blocks to create agents that handle user interactions, orchestrate requests, reason responses, and collaborate with other agents.

- Improving this README.MD file to provide a great experience
- Updating SUPPORT.MD with content about this project's support experience
- Understanding the security reporting process in SECURITY.MD
- Remove this section from the README
The M365 Agent SDK is a comprehensive framework for building enterprise-grade agents, enabling developers to integrate components from the Azure AI Foundry SDK, Semantic Kernel, as well as AI components from other vendors.

For more information please see the parent project information here [Microsoft 365 Agents SDK](https://aka.ms/agents)

## Getting Started

The best way to get started with these packages is to look at the samples available in [https://github.com/microsoft/Agents](https://github.com/microsoft/Agents)

## Important Notice - Import Changes

> **⚠️ Breaking Change**: Recent updates have changed the Python import structure from `microsoft.agents` to `microsoft_agents` (using underscores instead of dots). Please update your imports accordingly.

### Import Examples

```python
# Activity types and models
from microsoft_agents.activity import Activity

# Core hosting functionality
from microsoft_agents.hosting.core import TurnContext

# aiohttp hosting
from microsoft_agents.hosting.aiohttp import start_agent_process

# Teams-specific functionality (compatible only with activity handler)
from microsoft_agents.hosting.teams import TeamsActivityHandler

# Azure Blob storage
from microsoft_agents.storage.blob import BlobStorage

# CosmosDB storage
from microsoft_agents.storage.cosmos import CosmosDbStorage

# MSAL authentication
from microsoft_agents.authentication.msal import MsalAuth

# Copilot Studio client
from microsoft_agents.copilotstudio.client import CopilotClient
```

## Packages Overview

We offer the following PyPI packages to create conversational experiences based on Agents:

| Package Name | PyPI Version | Description | Replaces |
|--------------|-------------|-------------|----------|
| `microsoft-agents-activity` | [![PyPI](https://img.shields.io/pypi/v/microsoft-agents-activity)](https://pypi.org/project/microsoft-agents-activity/) | Types and validators implementing the Activity protocol spec. | `botframework-schema` |
| `microsoft-agents-hosting-core` | [![PyPI](https://img.shields.io/pypi/v/microsoft-agents-hosting-core)](https://pypi.org/project/microsoft-agents-hosting-core/) | Core library for Microsoft Agents hosting. | `botbuilder-core, botframework-connector` |
| `microsoft-agents-hosting-aiohttp` | [![PyPI](https://img.shields.io/pypi/v/microsoft-agents-hosting-aiohttp)](https://pypi.org/project/microsoft-agents-hosting-aiohttp/) | Configures aiohttp to run the Agent. | `botbuilder-integration-aiohttp` |
| `microsoft-agents-hosting-teams` | [![PyPI](https://img.shields.io/pypi/v/microsoft-agents-hosting-teams)](https://pypi.org/project/microsoft-agents-hosting-teams/) | Provides classes to host an Agent for Teams. | N/A |
| `microsoft-agents-storage-blob` | [![PyPI](https://img.shields.io/pypi/v/microsoft-agents-storage-blob)](https://pypi.org/project/microsoft-agents-storage-blob/) | Extension to use Azure Blob as storage. | `botbuilder-azure` |
| `microsoft-agents-storage-cosmos` | [![PyPI](https://img.shields.io/pypi/v/microsoft-agents-storage-cosmos)](https://pypi.org/project/microsoft-agents-storage-cosmos/) | Extension to use CosmosDB as storage. | `botbuilder-azure` |
| `microsoft-agents-authentication-msal` | [![PyPI](https://img.shields.io/pypi/v/microsoft-agents-authentication-msal)](https://pypi.org/project/microsoft-agents-authentication-msal/) | MSAL-based authentication for Microsoft Agents. | N/A |

Additionally we provide a Copilot Studio Client, to interact with Agents created in CopilotStudio:

| Package Name | PyPI Version | Description |
|--------------|-------------|-------------|
| `microsoft-agents-copilotstudio-client` | [![PyPI](https://img.shields.io/pypi/v/microsoft-agents-copilotstudio-client)](https://pypi.org/project/microsoft-agents-copilotstudio-client/) | Direct to Engine client to interact with Agents created in CopilotStudio |

### Environment requirements

The packages should target Python 3.9 or greater, and can be used with modern Python package managers like pip, poetry, or conda.

> Note: We recommend using Python 3.11 or later for optimal performance and compatibility with all features.

### Debugging

The packages include source code to allow debugging in your preferred Python IDE or debugger.

### Code Style

We are using `black` and `flake8` for code formatting and linting.

## Contributing

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class Activity(AgentsModel):
'endOfConversation', 'event', 'invoke', 'deleteUserData', 'messageUpdate',
'messageDelete', 'installationUpdate', 'messageReaction', 'suggestion',
'trace', 'handoff'
:type type: str or ~microsoft.agents.protocols.models.ActivityTypes
:type type: str or ~microsoft_agents.protocols.models.ActivityTypes
:param id: Contains an ID that uniquely identifies the activity on the channel.
:type id: str
:param timestamp: Contains the date and time that the message was sent, in UTC, expressed in ISO-8601 format.
Expand All @@ -43,23 +43,23 @@ class Activity(AgentsModel):
:param channel_id: Contains an ID that uniquely identifies the channel. Set by the channel.
:type channel_id: str
:param from_property: Identifies the sender of the message.
:type from_property: ~microsoft.agents.protocols.models.ChannelAccount
:type from_property: ~microsoft_agents.protocols.models.ChannelAccount
:param conversation: Identifies the conversation to which the activity belongs.
:type conversation: ~microsoft.agents.protocols.models.ConversationAccount
:type conversation: ~microsoft_agents.protocols.models.ConversationAccount
:param recipient: Identifies the recipient of the message.
:type recipient: ~microsoft.agents.protocols.models.ChannelAccount
:type recipient: ~microsoft_agents.protocols.models.ChannelAccount
:param text_format: Format of text fields Default:markdown. Possible values include: 'markdown', 'plain', 'xml'
:type text_format: str or ~microsoft.agents.protocols.models.TextFormatTypes
:type text_format: str or ~microsoft_agents.protocols.models.TextFormatTypes
:param attachment_layout: The layout hint for multiple attachments. Default: list. Possible values include: 'list', 'carousel'
:type attachment_layout: str or ~microsoft.agents.protocols.models.AttachmentLayoutTypes
:type attachment_layout: str or ~microsoft_agents.protocols.models.AttachmentLayoutTypes
:param members_added: The collection of members added to the conversation.
:type members_added: list[~microsoft.agents.protocols.models.ChannelAccount]
:type members_added: list[~microsoft_agents.protocols.models.ChannelAccount]
:param members_removed: The collection of members removed from the conversation.
:type members_removed: list[~microsoft.agents.protocols.models.ChannelAccount]
:type members_removed: list[~microsoft_agents.protocols.models.ChannelAccount]
:param reactions_added: The collection of reactions added to the conversation.
:type reactions_added: list[~microsoft.agents.protocols.models.MessageReaction]
:type reactions_added: list[~microsoft_agents.protocols.models.MessageReaction]
:param reactions_removed: The collection of reactions removed from the conversation.
:type reactions_removed: list[~microsoft.agents.protocols.models.MessageReaction]
:type reactions_removed: list[~microsoft_agents.protocols.models.MessageReaction]
:param topic_name: The updated topic name of the conversation.
:type topic_name: str
:param history_disclosed: Indicates whether the prior history of the channel is disclosed.
Expand All @@ -74,15 +74,15 @@ class Activity(AgentsModel):
:type speak: str
:param input_hint: Indicates whether your agent is accepting, expecting, or ignoring user input after the message is delivered to the client.
Possible values include: 'acceptingInput', 'ignoringInput', 'expectingInput'
:type input_hint: str or ~microsoft.agents.protocols.models.InputHints
:type input_hint: str or ~microsoft_agents.protocols.models.InputHints
:param summary: The text to display if the channel cannot render cards.
:type summary: str
:param suggested_actions: The suggested actions for the activity.
:type suggested_actions: ~microsoft.agents.protocols.models.SuggestedActions
:type suggested_actions: ~microsoft_agents.protocols.models.SuggestedActions
:param attachments: Attachments
:type attachments: list[~microsoft.agents.protocols.models.Attachment]
:type attachments: list[~microsoft_agents.protocols.models.Attachment]
:param entities: Represents the entities that were mentioned in the message.
:type entities: list[~microsoft.agents.protocols.models.Entity]
:type entities: list[~microsoft_agents.protocols.models.Entity]
:param channel_data: Contains channel-specific content.
:type channel_data: object
:param action: Indicates whether the recipient of a contactRelationUpdate was added or removed from the sender's contact list.
Expand All @@ -98,23 +98,23 @@ class Activity(AgentsModel):
:param name: The name of the operation associated with an invoke or event activity.
:type name: str
:param relates_to: A reference to another conversation or activity.
:type relates_to: ~microsoft.agents.protocols.models.ConversationReference
:type relates_to: ~microsoft_agents.protocols.models.ConversationReference
:param code: The a code for endOfConversation activities that indicates why the conversation ended. Possible values include: 'unknown',
'completedSuccessfully', 'userCancelled', 'botTimedOut', 'botIssuedInvalidMessage', 'channelFailed'
:type code: str or ~microsoft.agents.protocols.models.EndOfConversationCodes
:type code: str or ~microsoft_agents.protocols.models.EndOfConversationCodes
:param expiration: The time at which the activity should be considered to be "expired" and should not be presented to the recipient.
:type expiration: datetime
:param importance: The importance of the activity. Possible values include: 'low', 'normal', 'high'
:type importance: str or ~microsoft.agents.protocols.models.ActivityImportance
:type importance: str or ~microsoft_agents.protocols.models.ActivityImportance
:param delivery_mode: A delivery hint to signal to the recipient alternate delivery paths for the activity.
The default delivery mode is "default". Possible values include: 'normal', 'notification', 'expectReplies', 'ephemeral'
:type delivery_mode: str or ~microsoft.agents.protocols.models.DeliveryModes
:type delivery_mode: str or ~microsoft_agents.protocols.models.DeliveryModes
:param listen_for: List of phrases and references that speech and language priming systems should listen for
:type listen_for: list[str]
:param text_highlights: The collection of text fragments to highlight when the activity contains a ReplyToId value.
:type text_highlights: list[~microsoft.agents.protocols.models.TextHighlight]
:type text_highlights: list[~microsoft_agents.protocols.models.TextHighlight]
:param semantic_action: An optional programmatic action accompanying this request
:type semantic_action: ~microsoft.agents.protocols.models.SemanticAction
:type semantic_action: ~microsoft_agents.protocols.models.SemanticAction
:param caller_id: A string containing an IRI identifying the caller of an agent. This field is not intended to be transmitted over the wire,
but is instead populated by agents and clients based on cryptographically verifiable data that asserts the identity of the callers (e.g. tokens).
:type caller_id: str
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ class AdaptiveCardInvokeValue(AgentsModel):
Defines the structure that arrives in the Activity.Value for Invoke activity with Name of 'adaptiveCard/action'.

:param action: The action of this adaptive card invoke action value.
:type action: :class:`microsoft.agents.activity.models.AdaptiveCardInvokeAction`
:type action: :class:`microsoft_agents.activity.models.AdaptiveCardInvokeAction`
:param authentication: The TokenExchangeInvokeRequest for this adaptive card invoke action value.
:type authentication: :class:`microsoft.agents.activity.models.TokenExchangeInvokeRequest`
:type authentication: :class:`microsoft_agents.activity.models.TokenExchangeInvokeRequest`
:param state: The 'state' or magic code for an OAuth flow.
:type state: str
"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ class AnimationCard(AgentsModel):
:param text: Text of this card
:type text: str
:param image: Thumbnail placeholder
:type image: ~microsoft.agents.protocols.models.ThumbnailUrl
:type image: ~microsoft_agents.protocols.models.ThumbnailUrl
:param media: Media URLs for this card. When this field contains more than
one URL, each URL is an alternative format of the same content.
:type media: list[~microsoft.agents.protocols.models.MediaUrl]
:type media: list[~microsoft_agents.protocols.models.MediaUrl]
:param buttons: Actions on this card
:type buttons: list[~microsoft.agents.protocols.models.CardAction]
:type buttons: list[~microsoft_agents.protocols.models.CardAction]
:param shareable: This content may be shared with others (default:true)
:type shareable: bool
:param autoloop: Should the client loop playback at end of content
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class AttachmentInfo(AgentsModel):
:param type: ContentType of the attachment
:type type: str
:param views: attachment views
:type views: list[~microsoft.agents.protocols.models.AttachmentView]
:type views: list[~microsoft_agents.protocols.models.AttachmentView]
"""

name: NonEmptyString = None
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ class AudioCard(AgentsModel):
:param text: Text of this card
:type text: str
:param image: Thumbnail placeholder
:type image: ~microsoft.agents.protocols.models.ThumbnailUrl
:type image: ~microsoft_agents.protocols.models.ThumbnailUrl
:param media: Media URLs for this card. When this field contains more than
one URL, each URL is an alternative format of the same content.
:type media: list[~microsoft.agents.protocols.models.MediaUrl]
:type media: list[~microsoft_agents.protocols.models.MediaUrl]
:param buttons: Actions on this card
:type buttons: list[~microsoft.agents.protocols.models.CardAction]
:type buttons: list[~microsoft_agents.protocols.models.CardAction]
:param shareable: This content may be shared with others (default:true)
:type shareable: bool
:param autoloop: Should the client loop playback at end of content
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ class BasicCard(AgentsModel):
:param text: Text for the card
:type text: str
:param images: Array of images for the card
:type images: list[~microsoft.agents.protocols.models.CardImage]
:type images: list[~microsoft_agents.protocols.models.CardImage]
:param buttons: Set of actions applicable to the current card
:type buttons: list[~microsoft.agents.protocols.models.CardAction]
:type buttons: list[~microsoft_agents.protocols.models.CardAction]
:param tap: This action will be activated when user taps on the card
itself
:type tap: ~microsoft.agents.protocols.models.CardAction
:type tap: ~microsoft_agents.protocols.models.CardAction
"""

title: NonEmptyString = None
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class CardAction(AgentsModel):
:param type: The type of action implemented by this button. Possible
values include: 'openUrl', 'imBack', 'postBack', 'playAudio', 'playVideo',
'showImage', 'downloadFile', 'signin', 'call', 'messageBack'
:type type: str or ~microsoft.agents.protocols.models.ActionTypes
:type type: str or ~microsoft_agents.protocols.models.ActionTypes
:param title: Text description which appears on the button
:type title: str
:param image: Image URL which will appear on the button, next to text
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class CardImage(AgentsModel):
:param alt: Image description intended for screen readers
:type alt: str
:param tap: Action assigned to specific Attachment
:type tap: ~microsoft.agents.protocols.models.CardAction
:type tap: ~microsoft_agents.protocols.models.CardAction
"""

url: NonEmptyString = None
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class ChannelAccount(AgentsModel):
Directory (AAD)
:type aad_object_id: str
:param role: Role of the entity behind the account
:type role: str or ~microsoft.agents.protocols.models.RoleTypes
:type role: str or ~microsoft_agents.protocols.models.RoleTypes
"""

model_config = ConfigDict(extra="allow")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from typing import Protocol, List, Callable, Awaitable, Optional

from .turn_context_protocol import TurnContextProtocol
from microsoft.agents.activity import (
from microsoft_agents.activity import (
Activity,
ResourceResponse,
ConversationReference,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class ConversationAccount(AgentsModel):
Directory (AAD)
:type aad_object_id: str
:param role: Role of the entity behind the account
:type role: str or ~microsoft.agents.protocols.models.RoleTypes
:type role: str or ~microsoft_agents.protocols.models.RoleTypes
:param tenant_id: This conversation's tenant ID
:type tenant_id: str
:param properties: This conversation's properties
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class ConversationMembers(AgentsModel):
:param id: Conversation ID
:type id: str
:param members: List of members in this conversation
:type members: list[~microsoft.agents.protocols.models.ChannelAccount]
:type members: list[~microsoft_agents.protocols.models.ChannelAccount]
"""

id: NonEmptyString = None
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@ class ConversationParameters(AgentsModel):
:param is_group: IsGroup
:type is_group: bool
:param agent: The agent address for this conversation
:type agent: ~microsoft.agents.protocols.models.ChannelAccount
:type agent: ~microsoft_agents.protocols.models.ChannelAccount
:param members: Members to add to the conversation
:type members: list[~microsoft.agents.protocols.models.ChannelAccount]
:type members: list[~microsoft_agents.protocols.models.ChannelAccount]
:param topic_name: (Optional) Topic of the conversation (if supported by
the channel)
:type topic_name: str
:param activity: (Optional) When creating a new conversation, use this
activity as the initial message to the conversation
:type activity: ~microsoft.agents.protocols.models.Activity
:type activity: ~microsoft_agents.protocols.models.Activity
:param channel_data: Channel specific payload for creating the
conversation
:type channel_data: object
Expand Down
Loading