All skills
microsoft avatar

/m365-agents-py

@e19efc2
by microsoftmicrosoft/skills3.1k stars
351

Microsoft 365 Agents SDK for Python. Build multichannel agents for Teams/M365/Copilot Studio with aiohttp hosting, AgentApplication routing, streaming responses, and MSAL-based auth. Triggers: "Microsoft 365 Agents SDK", "microsoft_agents", "AgentApplication", "start_agent_process", "TurnContext", "Copilot Studio client", "CloudAdapter".

Use this Skill: https://skilld.dev/gh/microsoft/skills/m365-agents-py

This session only. Nothing lands on disk.

referencescapabilities.md

≈707 tokens on demand. Your agent reads this file only when SKILL.md points to it.

m365-agents-py capability coverage

SDK/package: microsoft-agents-hosting-core, microsoft-agents-hosting-aiohttp, microsoft-agents-activity, microsoft-agents-authentication-msal, microsoft-agents-copilotstudio-client

This reference mirrors the actual capability sections in SKILL.md and provides concrete non-hero examples for implementation guidance.

Hero scenarios covered in SKILL.md

  • Core Workflow: aiohttp-hosted AgentApplication
  • AgentApplication Routing
  • Streaming Responses with Azure OpenAI
  • OAuth / Auto Sign-In

Important non-hero scenarios with examples

Copilot Studio Client (Direct to Engine)

import asyncio
from os import environ
from msal import PublicClientApplication
from microsoft_agents.activity import ActivityTypes
from microsoft_agents.copilotstudio.client import (
    ConnectionSettings,
    CopilotClient,
)


def acquire_token(app_client_id: str, tenant_id: str) -> str:
    pca = PublicClientApplication(
        client_id=app_client_id,
        authority=f"https://login.microsoftonline.com/{tenant_id}",
    )

    scopes = ["https://api.powerplatform.com/.default"]
    accounts = pca.get_accounts()

    if accounts:
        response = pca.acquire_token_silent(scopes, account=accounts[0])
    else:
        response = pca.acquire_token_interactive(scopes=scopes)

    return response["access_token"]


async def main() -> None:
    settings = ConnectionSettings(
        environment_id=environ["COPILOTSTUDIOAGENT__ENVIRONMENTID"],
        agent_identifier=environ["COPILOTSTUDIOAGENT__SCHEMANAME"],
    )

    token = acquire_token(
        app_client_id=environ["COPILOTSTUDIOAGENT__AGENTAPPID"],
        tenant_id=environ["COPILOTSTUDIOAGENT__TENANTID"],
    )

    # CopilotClient does not implement the context manager protocol; close
    # any underlying resources explicitly when your application shuts down.
    copilot_client = CopilotClient(settings, token)

    # Start conversation and collect the opening activities
    opening_activities = copilot_client.start_conversation(True)
    async for activity in opening_activities:
        if activity.text:
            print(activity.text)

    # Send a message and iterate replies; CopilotClient retains the conversation ID
    replies = copilot_client.ask_question("Hello!")
    async for reply in replies:
        if reply.type == ActivityTypes.message:
            print(reply.text)


asyncio.run(main())

API breadth checklist

  • Verify client/auth mode for the environment before coding.
  • Confirm operation-group/method names against current Microsoft Learn API reference.
  • Include cleanup/delete paths for created resources in examples.
  • Prefer idempotent create/update operations where available.
  • Validate paging/LRO/error-handling patterns for production paths.

Source: SKILL.md on GitHub

1 warning15d4 checks · Risk SAFE
  • Gen Agent Trust Hub15d

    This skill provides a comprehensive implementation guide for the Microsoft 365 Agents SDK for Python. It follows security best practices by utilizing environment variables for secret management and leveraging official authentication libraries. No security issues were detected.

  • Socket15d

    No alerts

  • Snyk15d

    Risk: LOW · No issues

  • Runlayer7mo

    2/2 files flagged

Signed by skilld at e19efc2. This ties the file your Agent reads to that commit on GitHub. It does not review the instructions.

Last checked against GitHub yesterday.

Activeupdated 3 months ago
Other metadata
metadata
{
  "author": "Microsoft",
  "version": "1.0.0",
  "package": "microsoft-agents-hosting-core, microsoft-agents-hosting-aiohttp, microsoft-agents-activity, microsoft-agents-authentication-msal, microsoft-agents-copilotstudio-client"
}

README badge

README badge for microsoft/skills/m365-agents-py