Registry /
azure / microsoft-agents-copilotstudio-client
Install & Compatibility
Where this runs
tested against v1.0.0 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
muslpy 3.10–3.920 runs
installs and imports cleanly · install 0.0s · import 0.000s · 43.7MB
glibcpy 3.10–3.920 runs
installs and imports cleanly · install 5.0s · import 0.000s · 43MB
41MB installed
● package 41MB
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
Agent
✓ from microsoft.copilotstudio.agents import Agent
AgentExtension
✓ from microsoft.copilotstudio.agents.extension import AgentExtension
AgentActivity
✓ from microsoft.copilotstudio.agents.models import AgentActivity
UserMessage
✓ from microsoft.copilotstudio.agents.models import UserMessage
TurnContext
✓ from microsoft.copilotstudio.agents.turn_context import TurnContext
This quickstart demonstrates how to define a basic agent with message handlers using the `Agent` decorator and how to host it locally using `AgentExtension` and `uvicorn`. The `APP_ID` and `APP_PASSWORD` are crucial for Copilot Studio to authenticate and connect to your deployed agent.
import os
from microsoft.copilotstudio.agents import Agent
from microsoft.copilotstudio.agents.extension import AgentExtension
from microsoft.copilotstudio.agents.models import AgentActivity, UserMessage
from microsoft.copilotstudio.agents.turn_context import TurnContext
# Define your agent
agent = Agent()
# Define an initial message handler
@agent.on_message("initial_message")
async def initial_message_handler(turn_context: TurnContext):
user_message = turn_context.activity.value
if user_message and isinstance(user_message, UserMessage):
print(f"Received initial message: {user_message.text}")
await turn_context.send_activity(
AgentActivity(value="Hello! I'm your Copilot Studio Agent.")
)
else:
print("Received activity is not a UserMessage for initial_message.")
# Define a follow-up message handler
@agent.on_message("follow_up_message")
async def follow_up_message_handler(turn_context: TurnContext):
user_message = turn_context.activity.value
if user_message and isinstance(user_message, UserMessage):
print(f"Received follow-up message: {user_message.text}")
await turn_context.send_activity(
AgentActivity(value=f"You said: '{user_message.text}'. How can I help further?")
)
else:
print("Received activity is not a UserMessage for follow_up_message.")
# Create the AgentExtension application
# APP_ID and APP_PASSWORD are required for Copilot Studio to authenticate and connect.
# For local testing, you might leave them empty, but they are critical for deployment.
app = AgentExtension(agent, app_id=os.environ.get("COPILOT_STUDIO_APP_ID", ""),
app_password=os.environ.get("COPILOT_STUDIO_APP_PASSWORD", ""))
# To run this agent locally:
# 1. Save this code as `app.py`.
# 2. Ensure `uvicorn` is installed (`pip install uvicorn`).
# 3. From your terminal, execute: `uvicorn app:app --host 0.0.0.0 --port 3978`
# This will start a web server for your agent, accessible at http://localhost:3978
Upgrade
Version history
1.0.0latest on PyPI · released May 22, 2026
Audit
Dependencies
No dependency data recorded yet.