Microsoft 365 Agents SDK

repository·main·Indexed 21 days ago

https://github.com/microsoft/agents

A framework for building and deploying AI agents across channels like Microsoft Teams and Microsoft 365 Copilot. It provides an agent container abstraction layer to manage state and communication while remaining agnostic to underlying AI models and technology stacks. The SDK includes support for TypeScript/JavaScript and .NET, along with AI coding assistant plugins for Claude Code and GitHub Copilot CLI.

Tokens
174.5K
Snippets
408
Records
681
Agent score
70%

What's inside Microsoft 365 Agents SDK

  1. Overview of the Agent Framework Weather Sample

    main

    This sample demonstrates a Microsoft 365 Agents SDK agent using the Microsoft Agent Framework (agent-framework-core) as its AI orchestrator. It features a cat-themed weather assistant capable of answering questions about current conditions and multi-day forecasts.

    Key Capabilities Demonstrated:

    • AI Orchestration: Uses Agent and OpenAIChatClient with Azure OpenAI.
    • Tool/Function Use: Uses @tool decorated functions (e.g., get_current_weather, get_weather_forecast, get_date) to interact with external data.
    • Streaming: Implements server-sent streaming via StreamingResponse.
    • Session Management: Manages per-conversation history using Agent Framework sessions.
    • Transport: Uses aiohttp with a /api/messages endpoint, making it compatible with Microsoft Agents Playground, M365 Teams, and Copilot.
  2. Overview of Microsoft 365 Agents SDK

    main

    The Microsoft 365 Agents SDK allows developers to create agents that can be deployed to various channels, including Microsoft 365 Copilot, Microsoft Teams, and custom Web apps. The SDK provides scaffolding to handle communication requirements and acts as an agent 'container' that manages state, storage, activities, and events.

    Key capabilities:

    • Channel Agnostic Deployment: Build an agent once and deploy it across multiple channels.
    • AI Agnostic: Implement agentic patterns using any AI service, model, or technology stack (e.g., OpenAI, Azure OpenAI, Hugging Face).
    • Customization: Align agent behaviors with specific client requirements, such as Microsoft Teams-specific interactions.
  3. Overview of Microsoft 365 Agents SDK Packages

    main

    The Microsoft 365 Agents SDK is used to build multichannel agents for Teams, Copilot Studio, and web chat. The core functionality is distributed across several packages:

    PackagePurpose
    @microsoft/agents-hostingCore: Provides AgentApplication, CloudAdapter, TurnContext, TurnState, and storage
    @microsoft/agents-hosting-expressProvides the startServer() convenience wrapper for Express
    @microsoft/agents-hosting-storage-blobAzure Blob Storage backend
    @microsoft/agents-hosting-storage-cosmosCosmosDB backend
    @microsoft/agents-hosting-dialogsDialog system

    Requirements: Node 18+. Use node --env-file .env (Node 20+) to load environment variables.

  4. Overview of the RetrievalAgent Sample

    main

    The RetrievalAgent is a sample implementation of a Retrieval Agent hosted on an ASP.NET Core web service. It demonstrates how to use the Microsoft 365 Agents SDK combined with Semantic Kernel to implement Copilot Retrieval API Grounding capabilities.

    Key features of this sample:

    • Uses Semantic Kernel for orchestration.
    • Responds to queries about specific data (e.g., Build sessions) using Adaptive Cards.
    • Requires a model capable of JSON output (e.g., gpt-4o-mini).
    • Demonstrates grounding via the Copilot Retrieval API using documents stored in SharePoint.
  5. Overview of Microsoft 365 Agents SDK for .NET

    main

    The Microsoft 365 Agents SDK is used to build multichannel agents for Teams, Copilot Studio, and web chat using C# / .NET.

    Core Packages:

    • Microsoft.Agents.Hosting.AspNetCore: Provides ASP.NET Core hosting, authentication, and endpoint mapping.
    • Microsoft.Agents.Authentication.Msal: Handles MSAL-based authentication (Client Credentials, OBO).
    • Microsoft.Agents.Builder: Contains core components like AgentApplication, ITurnContext, and ITurnState.
    • Microsoft.Agents.Core: Defines models, activity types, and channel accounts.
    • Microsoft.Agents.Storage: Provides storage abstractions like IStorage and MemoryStorage.
    • Microsoft.Agents.Extensions.Teams: Contains Teams-specific models and extensions.
    • Microsoft.Agents.Builder.Dialogs: Manages the dialog system (waterfall, prompts).
    • Microsoft.Agents.AI: Provides AI-specific features.

    Requirements:

    • .NET 8+
    • For a minimal project, you only need Microsoft.Agents.Hosting.AspNetCore and Microsoft.Agents.Authentication.Msal. Other dependencies are pulled in transitively.
  6. Explore Microsoft 365 Agents JavaScript SDK Samples

    main

    The microsoft/agents repository provides a variety of Node.js samples to demonstrate different capabilities of the Microsoft 365 Agents JavaScript SDK. You can use these samples to learn how to implement specific agent behaviors such as authentication, integration with external frameworks like LangChain, or consuming Copilot Studio agents.

    Key sample categories include:

    • Basic Agents: QuickStart/Empty Agent for the simplest implementation.
    • Authentication: AutoSignIn (OAuth with Graph) and OBOAuthorization (On-Behalf-Of flow for Copilot Studio).
    • Integrations: Integrate LangChain (WeatherAgent with LangChain) and Streaming Agent (OpenAI response streaming).
    • Copilot Studio Consumption: Copilot Studio Client (Console app), Copilot Studio Client - React Webchat (Webchat integration), and Copilot Studio Webclient.
    • Advanced Agent Behaviors: Cards Agent (rich cards), Multi-turn Prompt (state management and dialog flows), and OTel Agent (OpenTelemetry instrumentation).
    • Specialized Extensions: Named Pipe Agent (for DirectLine App Service extension) and Copilot SDK (Dungeon Scribe RPG agent).
  7. Explore Microsoft 365 .NET Agents SDK Samples

    main

    The microsoft/agents repository provides a variety of .NET samples to demonstrate different capabilities of the Microsoft 365 Agents SDK. Use these samples to understand specific implementation patterns such as OAuth authentication, multi-turn AI interactions, streaming, and integration with Copilot Studio.

    Sample Categories:

    • Core Agent Patterns:

      • QuickStart/Empty Agent: The simplest possible agent implementation.
      • MultiAgent: Demonstrates hosting multiple AgentApplication instances within a single host.
      • Proactive: Shows how to initiate proactive conversations using in-code and HTTP triggers.
    • AI & LLM Integration:

      • Semantic Kernel: A WeatherAgent demonstrating multi-turn AI interactions.
      • Streaming Agent: Demonstrates streaming OpenAI responses.
      • RetrievalAgent: A Retrieval Agent hosted on an ASP.NET Core web service using Semantic Kernel.
      • Copilot SDK: A 'Dungeon Scribe' RPG agent powered by the GitHub Copilot SDK.
    • Authentication & Security:

      • AutoSignIn: A simple OAuth agent utilizing Microsoft Graph.
      • OBOAuthorization: Demonstrates On-Behalf-Of (OBO) flow to a Copilot Studio Agent.
    • Copilot Studio & Ecosystem Integration:

      • Copilot Studio Client: A console application designed to consume a Copilot Studio Agent.
      • Copilot Studio Skill: Demonstrates calling an echo bot from a Copilot Studio skill.
      • GenesysHandoff: Shows how a Microsoft Copilot Studio Agent can hand off conversations to a live agent in Genesys Cloud.
    • Infrastructure & Extensions:

      • OpenTelemetry Agent: Configures OTel tracing, metrics, and logging with OTLP export.
      • Named Pipe Agent: A pipe-only echo agent for the DirectLine App Service extension (DirectLineFlex).
  8. Understand the experimental bicep-scripts directory structure

    main

    The experimental/bicep-scripts directory contains the following structure:

    • bicep/: Contains common Bicep scripts used by the provisioning scripts in the samples.
    • samples/: Contains provisioning scripts for specific samples:
      • quickstart/: For the Quickstart sample.
      • auto-signin/: For the Auto Sign-In sample.
      • obo-authorization/: For the OBO Authorization sample.
    • bot/: The destination directory where manifest.json is created by gen_teams_manifest.ps1. This directory contains the files used to deploy an Agent to Teams.
  9. Integrate Copilot Studio with React WebChat

    main
    This sample demonstrates how to connect Microsoft Copilot Studio to a custom React-based WebChat interface using the botframework-webchat component. It is a pure client-side React application built with TypeScript and bundled using esbuild. It uses the Power Platform API for secure communication and Microsoft Entra ID (Azure AD) for token acquisition.
  10. Dungeon Scribe Agent implementation details

    main

    The Dungeon Scribe sample demonstrates several key integration patterns:

    • Copilot SDK Integration: Wires a CopilotClient into the Microsoft Agents hosting loop.
    • Custom Tools: Uses @define_tool and Pydantic models to expose functions like roll_dice and manage_inventory to the Copilot model.
    • Session Management: Creates sessions keyed per user + conversation to maintain multi-turn context.
    • Streaming: Implements token-by-token response streaming using Copilot SDK event callbacks.
    • Persona Orchestration: Uses a system prompt to enforce a specific fantasy persona (Dungeon Chronicler).

    Project Structure:

    • src/agent.py: Core integration of M365 Agent + Copilot SDK.
    • src/main.py: Logging and server startup.
    • src/start_server.py: aiohttp hosting entry point.
    • src/tools/dice.py: Dice rolling tool implementation.
    • src/tools/inventory.py: In-memory inventory tool implementation.
  11. Provision Azure resources for Microsoft Agents SDK

    main

    The agents-sdk-provision skill automates the provisioning of Azure Bot resources for Microsoft Agents SDK applications. This includes creating Azure Bot Service resources, setting up Entra app registrations, configuring identity credentials, adding Teams channels, and running Bicep deployments for SSO. It is compatible with .NET, Node.js, and Python applications.

    This skill can be triggered by natural language requests such as:

    • "set up my bot on Azure"
    • "deploy my bot"
    • "configure Azure for my bot"
    • "get Teams SSO working"
  12. Overview of GenesysHandoff Integration Components

    main

    The GenesysHandoff integration consists of several key components working together to bridge Copilot Studio and Genesys Cloud:

    • Escalation Event Handler: Listens for the GenesysHandoff event emitted by the Copilot agent, which contains the conversation summary.
    • Genesys API Client: Interacts with Genesys Cloud APIs to initiate conversations and send messages on behalf of the user.
    • Webhook Endpoint: A listener that receives messages from Genesys agents and relays them back to the user.
    • Conversation Tracking: Manages the mapping between the bot's conversation state and the Genesys conversation state.

    Project Structure:

    • appsettings.json: Configuration for Azure Bot, Genesys APIs, and Copilot.
    • Program.cs: Entry point for startup and DI.
    • GenesysHandoffAgent.cs: Core agent logic and event handling.
    • Genesys/: Contains the API client and GenesysNotificationService.cs (a WebSocket client for detecting agent disconnects).