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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions samples/python/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,34 @@
|Copilot Studio Client|Console app to consume a Copilot Studio Agent|[copilotstudio-client](copilotstudio-client/README.md)|
|Cards Agent|Agent that uses rich cards to enhance conversation design |[cards](cards/README.md)|
|Copilot Studio Skill|Call the echo bot from a Copilot Studio skill |[copilotstudio-skill](copilotstudio-skill/README.md)|

## 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
8 changes: 4 additions & 4 deletions samples/python/auto-signin/src/agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from os import environ, path
from dotenv import load_dotenv

from microsoft.agents.hosting.core import (
from microsoft_agents.hosting.core import (
Authorization,
TurnContext,
MessageFactory,
Expand All @@ -15,9 +15,9 @@
TurnState,
MemoryStorage,
)
from microsoft.agents.activity import activity, load_configuration_from_env, ActivityTypes, Activity
from microsoft.agents.hosting.aiohttp import CloudAdapter
from microsoft.agents.authentication.msal import MsalConnectionManager
from microsoft_agents.activity import load_configuration_from_env, ActivityTypes
from microsoft_agents.hosting.aiohttp import CloudAdapter
from microsoft_agents.authentication.msal import MsalConnectionManager

from .github_api_client import get_current_profile, get_pull_requests
from .user_graph_client import get_user_info
Expand Down
2 changes: 1 addition & 1 deletion samples/python/auto-signin/src/cards.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from microsoft.agents.hosting.core import CardFactory
from microsoft_agents.hosting.core import CardFactory

def create_profile_card(profile):
return CardFactory.adaptive_card(
Expand Down
2 changes: 1 addition & 1 deletion samples/python/auto-signin/src/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# enable logging for Microsoft Agents library
# for more information, see README.md for Quickstart Agent
import logging
ms_agents_logger = logging.getLogger("microsoft.agents")
ms_agents_logger = logging.getLogger("microsoft_agents")
ms_agents_logger.addHandler(logging.StreamHandler())
ms_agents_logger.setLevel(logging.INFO)

Expand Down
4 changes: 2 additions & 2 deletions samples/python/auto-signin/src/start_server.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from os import environ
from microsoft.agents.hosting.core import AgentApplication, AgentAuthConfiguration
from microsoft.agents.hosting.aiohttp import (
from microsoft_agents.hosting.core import AgentApplication, AgentAuthConfiguration
from microsoft_agents.hosting.aiohttp import (
start_agent_process,
jwt_authorization_middleware,
CloudAdapter,
Expand Down
8 changes: 4 additions & 4 deletions samples/python/azureai-streaming/src/agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,17 @@
from dotenv import load_dotenv
from openai import AsyncAzureOpenAI

from microsoft.agents.hosting.aiohttp import CloudAdapter
from microsoft.agents.authentication.msal import MsalConnectionManager
from microsoft_agents.hosting.aiohttp import CloudAdapter
from microsoft_agents.authentication.msal import MsalConnectionManager

from microsoft.agents.hosting.core import (
from microsoft_agents.hosting.core import (
Authorization,
AgentApplication,
TurnState,
TurnContext,
MemoryStorage,
)
from microsoft.agents.activity import (
from microsoft_agents.activity import (
load_configuration_from_env,
Activity,
ActivityTypes,
Expand Down
2 changes: 1 addition & 1 deletion samples/python/azureai-streaming/src/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# enable logging for Microsoft Agents library
# for more information, see README.md for Quickstart Agent
import logging
ms_agents_logger = logging.getLogger("microsoft.agents")
ms_agents_logger = logging.getLogger("microsoft_agents")
ms_agents_logger.addHandler(logging.StreamHandler())
ms_agents_logger.setLevel(logging.INFO)

Expand Down
4 changes: 2 additions & 2 deletions samples/python/azureai-streaming/src/start_server.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from os import environ
from microsoft.agents.hosting.core import AgentApplication, AgentAuthConfiguration
from microsoft.agents.hosting.aiohttp import (
from microsoft_agents.hosting.core import AgentApplication, AgentAuthConfiguration
from microsoft_agents.hosting.aiohttp import (
start_agent_process,
jwt_authorization_middleware,
CloudAdapter,
Expand Down
8 changes: 4 additions & 4 deletions samples/python/cards/src/agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from os import environ
from dotenv import load_dotenv

from microsoft.agents.hosting.core import (
from microsoft_agents.hosting.core import (
Authorization,
TurnContext,
MemoryStorage,
Expand All @@ -14,9 +14,9 @@
MemoryStorage,
MessageFactory,
)
from microsoft.agents.activity import load_configuration_from_env
from microsoft.agents.hosting.aiohttp import CloudAdapter
from microsoft.agents.authentication.msal import MsalConnectionManager
from microsoft_agents.activity import load_configuration_from_env
from microsoft_agents.hosting.aiohttp import CloudAdapter
from microsoft_agents.authentication.msal import MsalConnectionManager

from .card_messages import CardMessages

Expand Down
6 changes: 3 additions & 3 deletions samples/python/cards/src/card_messages.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from microsoft.agents.activity import ActionTypes, Activity, ActivityTypes, Attachment
from microsoft.agents.hosting.core import CardFactory, TurnContext
from microsoft_agents.activity import ActionTypes, Activity, ActivityTypes, Attachment
from microsoft_agents.hosting.core import CardFactory, TurnContext

from microsoft.agents.activity import (
from microsoft_agents.activity import (
HeroCard,
AnimationCard,
AudioCard,
Expand Down
2 changes: 1 addition & 1 deletion samples/python/cards/src/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# enable logging for Microsoft Agents library
# for more information, see README.md for Quickstart Agent
import logging
ms_agents_logger = logging.getLogger("microsoft.agents")
ms_agents_logger = logging.getLogger("microsoft_agents")
ms_agents_logger.addHandler(logging.StreamHandler())
ms_agents_logger.setLevel(logging.INFO)

Expand Down
4 changes: 2 additions & 2 deletions samples/python/cards/src/start_server.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from os import environ
from microsoft.agents.hosting.core import AgentApplication, AgentAuthConfiguration
from microsoft.agents.hosting.aiohttp import (
from microsoft_agents.hosting.core import AgentApplication, AgentAuthConfiguration
from microsoft_agents.hosting.aiohttp import (
start_agent_process,
jwt_authorization_middleware,
CloudAdapter,
Expand Down
6 changes: 3 additions & 3 deletions samples/python/copilotstudio-client/src/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# enable logging for Microsoft Agents library
# for more information, see README.md for Quickstart Agent
import logging
ms_agents_logger = logging.getLogger("microsoft.agents")
ms_agents_logger = logging.getLogger("microsoft_agents")
ms_agents_logger.addHandler(logging.StreamHandler())
ms_agents_logger.setLevel(logging.INFO)

Expand All @@ -17,8 +17,8 @@

from msal import PublicClientApplication

from microsoft.agents.activity import ActivityTypes, load_configuration_from_env
from microsoft.agents.copilotstudio.client import (
from microsoft_agents.activity import ActivityTypes, load_configuration_from_env
from microsoft_agents.copilotstudio.client import (
ConnectionSettings,
CopilotClient,
)
Expand Down
8 changes: 4 additions & 4 deletions samples/python/copilotstudio-skill/src/agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@
from os import environ

from dotenv import load_dotenv
from microsoft.agents.hosting.core import (
from microsoft_agents.hosting.core import (
Authorization,
AgentApplication,
TurnState,
TurnContext,
MemoryStorage,
)
from microsoft.agents.activity import load_configuration_from_env
from microsoft.agents.hosting.aiohttp import CloudAdapter
from microsoft.agents.authentication.msal import MsalConnectionManager
from microsoft_agents.activity import load_configuration_from_env
from microsoft_agents.hosting.aiohttp import CloudAdapter
from microsoft_agents.authentication.msal import MsalConnectionManager

load_dotenv()
agents_sdk_config = load_configuration_from_env(environ)
Expand Down
6 changes: 3 additions & 3 deletions samples/python/copilotstudio-skill/src/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@
# enable logging for Microsoft Agents library
# for more information, see README.md for Quickstart Agent
import logging
ms_agents_logger = logging.getLogger("microsoft.agents")
ms_agents_logger = logging.getLogger("microsoft_agents")
ms_agents_logger.addHandler(logging.StreamHandler())
ms_agents_logger.setLevel(logging.INFO)

from os import environ

from microsoft.agents.hosting.core import AgentApplication
from microsoft.agents.hosting.aiohttp import (
from microsoft_agents.hosting.core import AgentApplication
from microsoft_agents.hosting.aiohttp import (
start_agent_process,
jwt_authorization_middleware,
CloudAdapter,
Expand Down
2 changes: 1 addition & 1 deletion samples/python/obo-authorization/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
This Agent has been created using [Microsoft 365 Agents SDK](https://github.com/microsoft/agents-for-net), it shows how to use authorization in your Agent using OAuth and OBO.

- The sample uses the Agent SDK User Authorization capabilities in [Azure Bot Service](https://docs.botframework.com), providing features to make it easier to develop an Agent that authorizes users with various identity providers such as Azure AD (Azure Active Directory), GitHub, Uber, etc.
- This sample shows how to use an OBO Exchange to communicate with Microsoft Copilot Studio using the [CopilotClient class](https://learn.microsoft.com/python/api/microsoft-agents-copilotstudio-client/microsoft.agents.copilotstudio.client.copilotclient).
- This sample shows how to use an OBO Exchange to communicate with Microsoft Copilot Studio using the [CopilotClient class](https://learn.microsoft.com/python/api/microsoft-agents-copilotstudio-client/microsoft_agents.copilotstudio.client.copilotclient).

## Prerequisites

Expand Down
10 changes: 5 additions & 5 deletions samples/python/obo-authorization/src/agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,18 @@
from os import environ
from dotenv import load_dotenv

from microsoft.agents.hosting.core import (
from microsoft_agents.hosting.core import (
Authorization,
TurnContext,
MemoryStorage,
AgentApplication,
TurnState,
MemoryStorage,
)
from microsoft.agents.activity import load_configuration_from_env, ActivityTypes
from microsoft.agents.hosting.aiohttp import CloudAdapter
from microsoft.agents.authentication.msal import MsalConnectionManager
from microsoft.agents.copilotstudio.client import ConnectionSettings, CopilotClient, PowerPlatformEnvironment, PowerPlatformCloud
from microsoft_agents.activity import load_configuration_from_env, ActivityTypes
from microsoft_agents.hosting.aiohttp import CloudAdapter
from microsoft_agents.authentication.msal import MsalConnectionManager
from microsoft_agents.copilotstudio.client import ConnectionSettings, CopilotClient, PowerPlatformEnvironment, PowerPlatformCloud

# Load configuration from environment
load_dotenv()
Expand Down
2 changes: 1 addition & 1 deletion samples/python/obo-authorization/src/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# enable logging for Microsoft Agents library
# for more information, see README.md for Quickstart Agent
import logging
ms_agents_logger = logging.getLogger("microsoft.agents")
ms_agents_logger = logging.getLogger("microsoft_agents")
ms_agents_logger.addHandler(logging.StreamHandler())
ms_agents_logger.setLevel(logging.INFO)

Expand Down
4 changes: 2 additions & 2 deletions samples/python/obo-authorization/src/start_server.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from os import environ
from microsoft.agents.hosting.core import AgentApplication, AgentAuthConfiguration
from microsoft.agents.hosting.aiohttp import (
from microsoft_agents.hosting.core import AgentApplication, AgentAuthConfiguration
from microsoft_agents.hosting.aiohttp import (
start_agent_process,
jwt_authorization_middleware,
CloudAdapter,
Expand Down
14 changes: 7 additions & 7 deletions samples/python/quickstart/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,15 +77,15 @@ import logging
logger = logging.getLogger(__name__)
```

By using `__name__`, the logger for the module will have namespaces corresponding to the file structure. So, `microsoft.agents.hosting.core.app.agent_application.py` will initialize a new logger with the namespace `microsoft.agents.hosting.core.app.agent_application`, and any configurations to parent namespaces such as `microsoft.agents.hosting` or `microsoft` will apply to that new logger. By default, logging level for the `microsoft.agents.*` namespaces is set to `WARNING`, so logs emitted with levels above and equal to that are logged. By default, this would be `WARNING`, `ERROR`, and `CRITICAL`. Thus, by default `DEBUG` and `INFO` logs are ignored.
By using `__name__`, the logger for the module will have namespaces corresponding to the file structure. So, `microsoft_agents.hosting.core.app.agent_application.py` will initialize a new logger with the namespace `microsoft_agents.hosting.core.app.agent_application`, and any configurations to parent namespaces such as `microsoft_agents.hosting` or `microsoft` will apply to that new logger. By default, logging level for the `microsoft_agents.*` namespaces is set to `WARNING`, so logs emitted with levels above and equal to that are logged. By default, this would be `WARNING`, `ERROR`, and `CRITICAL`. Thus, by default `DEBUG` and `INFO` logs are ignored.

### Configuration

In these samples, we configure the logging for the `microsoft.agents` namespace with:
In these samples, we configure the logging for the `microsoft_agents` namespace with:

```python
import logging
ms_agents_logger = logging.getLogger("microsoft.agents")
ms_agents_logger = logging.getLogger("microsoft_agents")
ms_agents_logger.addHandler(logging.StreamHandler())
ms_agents_logger.setLevel(logging.INFO)
```
Expand All @@ -103,7 +103,7 @@ Acquiring token using Confidential Client Application.
Meanwhile, here is an example that extends the configuration above to display logs in a more readable fashion by applying a formatter:
```python
import logging
ms_agents_logger = logging.getLogger("microsoft.agents")
ms_agents_logger = logging.getLogger("microsoft_agents")
console_handler = logging.StreamHandler()
console_handler.setFormatter(logging.Formatter("%(asctime)s - %(name)s - %(levelname)s - %(message)s (%(filename)s:%(lineno)d)"))
ms_agents_logger.addHandler(console_handler)
Expand All @@ -115,9 +115,9 @@ Running the Quickstart Agent with this configuration will print something like f
```bash
======== Running on http://localhost:3978 ========
(Press CTRL+C to quit)
2025-08-06 09:39:24,539 - microsoft.agents.authentication.msal.msal_auth - INFO - Acquiring token using Confidential Client Application. (msal_auth.py:55)
2025-08-06 09:39:24,658 - microsoft.agents.authentication.msal.msal_auth - INFO - Using cached client credentials for MSAL authentication. (msal_auth.py:117)
2025-08-06 09:39:24,824 - microsoft.agents.authentication.msal.msal_auth - INFO - Acquiring token using Confidential Client Application. (msal_auth.py:55)
2025-08-06 09:39:24,539 - microsoft_agents.authentication.msal.msal_auth - INFO - Acquiring token using Confidential Client Application. (msal_auth.py:55)
2025-08-06 09:39:24,658 - microsoft_agents.authentication.msal.msal_auth - INFO - Using cached client credentials for MSAL authentication. (msal_auth.py:117)
2025-08-06 09:39:24,824 - microsoft_agents.authentication.msal.msal_auth - INFO - Acquiring token using Confidential Client Application. (msal_auth.py:55)
...
```

Expand Down
8 changes: 4 additions & 4 deletions samples/python/quickstart/src/agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,16 @@
from dotenv import load_dotenv

from os import environ
from microsoft.agents.hosting.aiohttp import CloudAdapter
from microsoft.agents.hosting.core import (
from microsoft_agents.hosting.aiohttp import CloudAdapter
from microsoft_agents.hosting.core import (
Authorization,
AgentApplication,
TurnState,
TurnContext,
MemoryStorage,
)
from microsoft.agents.authentication.msal import MsalConnectionManager
from microsoft.agents.activity import load_configuration_from_env
from microsoft_agents.authentication.msal import MsalConnectionManager
from microsoft_agents.activity import load_configuration_from_env

load_dotenv() # robrandao: todo
agents_sdk_config = load_configuration_from_env(environ)
Expand Down
2 changes: 1 addition & 1 deletion samples/python/quickstart/src/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# enable logging for Microsoft Agents library
# for more information, see README.md for Quickstart Agent
import logging
ms_agents_logger = logging.getLogger("microsoft.agents")
ms_agents_logger = logging.getLogger("microsoft_agents")
ms_agents_logger.addHandler(logging.StreamHandler())
ms_agents_logger.setLevel(logging.INFO)

Expand Down
4 changes: 2 additions & 2 deletions samples/python/quickstart/src/start_server.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from os import environ
from microsoft.agents.hosting.core import AgentApplication, AgentAuthConfiguration
from microsoft.agents.hosting.aiohttp import (
from microsoft_agents.hosting.core import AgentApplication, AgentAuthConfiguration
from microsoft_agents.hosting.aiohttp import (
start_agent_process,
jwt_authorization_middleware,
CloudAdapter,
Expand Down
8 changes: 4 additions & 4 deletions samples/python/semantic-kernel-multiturn/src/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,18 @@
from semantic_kernel.connectors.ai.open_ai import AzureChatCompletion
from semantic_kernel.contents import ChatHistory

from microsoft.agents.hosting.core import (
from microsoft_agents.hosting.core import (
Authorization,
AgentApplication,
TurnState,
TurnContext,
MessageFactory,
MemoryStorage,
)
from microsoft.agents.hosting.aiohttp import CloudAdapter
from microsoft.agents.authentication.msal import MsalConnectionManager
from microsoft_agents.hosting.aiohttp import CloudAdapter
from microsoft_agents.authentication.msal import MsalConnectionManager

from microsoft.agents.activity import Attachment, load_configuration_from_env
from microsoft_agents.activity import Attachment, load_configuration_from_env

from .agent import WeatherForecastAgent

Expand Down
2 changes: 1 addition & 1 deletion samples/python/semantic-kernel-multiturn/src/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
# for more information, see README.md for Quickstart Agent
import logging

ms_agents_logger = logging.getLogger("microsoft.agents")
ms_agents_logger = logging.getLogger("microsoft_agents")
ms_agents_logger.addHandler(logging.StreamHandler())
ms_agents_logger.setLevel(logging.INFO)

Expand Down
Loading