{"library":"microsoft-agents-copilotstudio-client","title":"Microsoft Agents Copilot Studio Client","description":"The Microsoft Agents Copilot Studio Client library is a Python SDK for building and hosting custom agent extensions within Microsoft Copilot Studio. It provides an asynchronous framework to define agent behavior, handle incoming messages, manage conversation state, and integrate with the Copilot Studio platform. The library is actively developed, with frequent pre-1.0 releases, indicating an evolving API surface.","language":"python","status":"active","last_verified":"Sun May 17","install":{"commands":["pip install microsoft-agents-copilotstudio-client uvicorn"],"cli":null},"imports":["from microsoft.copilotstudio.agents import Agent","from microsoft.copilotstudio.agents.extension import AgentExtension","from microsoft.copilotstudio.agents.models import AgentActivity","from microsoft.copilotstudio.agents.models import UserMessage","from microsoft.copilotstudio.agents.turn_context import TurnContext"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"import os\nfrom microsoft.copilotstudio.agents import Agent\nfrom microsoft.copilotstudio.agents.extension import AgentExtension\nfrom microsoft.copilotstudio.agents.models import AgentActivity, UserMessage\nfrom microsoft.copilotstudio.agents.turn_context import TurnContext\n\n# Define your agent\nagent = Agent()\n\n# Define an initial message handler\n@agent.on_message(\"initial_message\")\nasync def initial_message_handler(turn_context: TurnContext):\n    user_message = turn_context.activity.value\n    if user_message and isinstance(user_message, UserMessage):\n        print(f\"Received initial message: {user_message.text}\")\n        await turn_context.send_activity(\n            AgentActivity(value=\"Hello! I'm your Copilot Studio Agent.\")\n        )\n    else:\n        print(\"Received activity is not a UserMessage for initial_message.\")\n\n# Define a follow-up message handler\n@agent.on_message(\"follow_up_message\")\nasync def follow_up_message_handler(turn_context: TurnContext):\n    user_message = turn_context.activity.value\n    if user_message and isinstance(user_message, UserMessage):\n        print(f\"Received follow-up message: {user_message.text}\")\n        await turn_context.send_activity(\n            AgentActivity(value=f\"You said: '{user_message.text}'. How can I help further?\")\n        )\n    else:\n        print(\"Received activity is not a UserMessage for follow_up_message.\")\n\n# Create the AgentExtension application\n# APP_ID and APP_PASSWORD are required for Copilot Studio to authenticate and connect.\n# For local testing, you might leave them empty, but they are critical for deployment.\napp = AgentExtension(agent, app_id=os.environ.get(\"COPILOT_STUDIO_APP_ID\", \"\"),\n                     app_password=os.environ.get(\"COPILOT_STUDIO_APP_PASSWORD\", \"\"))\n\n# To run this agent locally:\n# 1. Save this code as `app.py`.\n# 2. Ensure `uvicorn` is installed (`pip install uvicorn`).\n# 3. From your terminal, execute: `uvicorn app:app --host 0.0.0.0 --port 3978`\n# This will start a web server for your agent, accessible at http://localhost:3978","lang":"python","description":"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.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":{"tag":null,"tag_description":null,"last_tested":"2026-05-17","installed_version":"0.4.0","pypi_latest":"0.9.1","is_stale":true,"summary":{"python_range":"3.10–3.9","success_rate":100,"avg_install_s":5,"avg_import_s":null,"wheel_type":"wheel"},"results":[{"runtime":"python:3.10-alpine","python_version":"3.10","os_libc":"alpine (musl)","variant":"microsoft-agents-copilotstudio-client","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"broken","install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":"43.7M"},{"runtime":"python:3.10-slim","python_version":"3.10","os_libc":"slim (glibc)","variant":"microsoft-agents-copilotstudio-client","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"broken","install_time_s":5.7,"import_time_s":null,"mem_mb":null,"disk_size":"43M"},{"runtime":"python:3.11-alpine","python_version":"3.11","os_libc":"alpine (musl)","variant":"microsoft-agents-copilotstudio-client","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"broken","install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":"47.8M"},{"runtime":"python:3.11-slim","python_version":"3.11","os_libc":"slim (glibc)","variant":"microsoft-agents-copilotstudio-client","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"broken","install_time_s":5,"import_time_s":null,"mem_mb":null,"disk_size":"47M"},{"runtime":"python:3.12-alpine","python_version":"3.12","os_libc":"alpine (musl)","variant":"microsoft-agents-copilotstudio-client","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"broken","install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":"39.1M"},{"runtime":"python:3.12-slim","python_version":"3.12","os_libc":"slim (glibc)","variant":"microsoft-agents-copilotstudio-client","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"broken","install_time_s":4.2,"import_time_s":null,"mem_mb":null,"disk_size":"39M"},{"runtime":"python:3.13-alpine","python_version":"3.13","os_libc":"alpine (musl)","variant":"microsoft-agents-copilotstudio-client","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"broken","install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":"38.9M"},{"runtime":"python:3.13-slim","python_version":"3.13","os_libc":"slim (glibc)","variant":"microsoft-agents-copilotstudio-client","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"broken","install_time_s":4.3,"import_time_s":null,"mem_mb":null,"disk_size":"38M"},{"runtime":"python:3.9-alpine","python_version":"3.9","os_libc":"alpine (musl)","variant":"microsoft-agents-copilotstudio-client","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"broken","install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":"37.3M"},{"runtime":"python:3.9-slim","python_version":"3.9","os_libc":"slim (glibc)","variant":"microsoft-agents-copilotstudio-client","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"broken","install_time_s":5.9,"import_time_s":null,"mem_mb":null,"disk_size":"37M"}]}}