Microsoft 365 Agents SDK
The channel and hosting layer for custom engine agents: receives and sends messages
across Microsoft 365 Copilot, Teams, web, and 10+ third-party channels (Slack, Facebook
Messenger, Twilio, SMS, email) via Azure Bot Service, which translates channel traffic
into Activities. It is the successor to the Bot Framework SDK (BF SDK and Emulator are
archived; support ended 2025-12-31). AI-agnostic: host Microsoft Agent Framework, Semantic
Kernel, LangChain, OpenAI Agents, or Foundry agents inside it.
Docs: https://learn.microsoft.com/microsoft-365/agents-sdk/agents-sdk-overview
Status (mid-2026): GA — .NET v1.6.x (.NET 8+), JavaScript v1.6.x (Node 18+), Python v1.1.x.
Packages
| Language |
Packages |
| .NET |
Microsoft.Agents.Builder (AgentApplication, routing, middleware, turn context), Microsoft.Agents.Core (Activity models), Microsoft.Agents.Storage, Microsoft.Agents.Authentication, Microsoft.Agents.Connector, Microsoft.Agents.Storage.Transcript |
| JS/TS |
@microsoft/agents-hosting, @microsoft/agents-hosting-express, @microsoft/agents-activity |
| Python |
microsoft-agents-hosting-core, microsoft-agents-activity, microsoft-agents-hosting-aiohttp, microsoft-agents-authentication-msal, microsoft-agents-storage-blob / -cosmos, microsoft-agents-hosting-teams (imports from microsoft_agents) |
Core concepts
- Activity Protocol — the standard JSON message format shared across channels; typed
models live in
Microsoft.Agents.Core / @microsoft/agents-activity.
AgentApplication — your entry point. Pipeline: Channel → hosting layer (HTTP auth)
→ AgentApplication routing → your handlers, with turn state loaded before and saved after
each handler. Route ranking (RouteRank.Last) orders catch-alls.
CloudAdapter processes /api/messages; agents are stateless with pluggable storage
(memory, Blob, Cosmos).
- Tooling: Microsoft 365 Agents Toolkit (formerly Teams Toolkit — VS, VS Code, CLI)
for scaffolding/manifests/publishing, and the Microsoft 365 Agents Playground — a
local Teams-like sandbox needing no tenant, tunnel, or bot registration.
- Agent 365 SDK (
@microsoft/agents-a365-*) layers on enterprise observability
(OpenTelemetry), notifications, MCP tool-server management, and Entra-based agent identity.
Minimal agents
public class EchoAgent : AgentApplication
{
public EchoAgent(AgentApplicationOptions options) : base(options)
=> OnActivity(ActivityTypes.Message, OnMessageAsync, rank: RouteRank.Last);
private async Task OnMessageAsync(ITurnContext tc, ITurnState ts, CancellationToken ct)
=> await tc.SendActivityAsync($"You said: {tc.Activity.Text}", cancellationToken: ct);
}
import { AgentApplication, MemoryStorage, TurnContext, TurnState } from '@microsoft/agents-hosting'
import { startServer } from '@microsoft/agents-hosting-express'
const app = new AgentApplication<TurnState>({ storage: new MemoryStorage() })
app.onActivity('message', async (ctx: TurnContext) => ctx.sendActivity(`You said: ${ctx.activity.text}`))
startServer(app)
Hosting an AI engine inside
The SDK is plumbing; the intelligence is whatever you host. The documented pattern for
Agent Framework / Semantic Kernel: instantiate the engine agent once, then call it from the
message handler and relay the result as an activity.
Guide: https://learn.microsoft.com/microsoft-365/agents-sdk/using-semantic-kernel-agent-framework
Keep the layers separate: channel/UX concerns (activities, cards, auth) in the
AgentApplication handler; reasoning/tools in the engine (see skills/agent-framework).
Bot Framework migration
Coming from Bot Framework v4 (see /msagent-migrate):
- The Activity protocol carries over — message shapes and channel semantics are familiar.
ActivityHandler/adapter wiring becomes AgentApplication routing; middleware moves to
the new pipeline.
- Dialogs have no direct successor — replace waterfall dialogs with an LLM engine + tools,
or explicit state machines for strictly deterministic flows.
- Re-register the messaging endpoint against Azure Bot Service; update auth to the current
Microsoft.Agents.Authentication / MSAL configuration.
Practices
- Develop against the Agents Playground first; only stand up tunnels/bot registrations when
channel-specific behavior needs testing.
- Store per-conversation state via the SDK's storage abstractions, not process memory, so
scale-out works.
- One agent codebase, many channels: guard Teams-only affordances (cards, meetings) behind
channel checks — see
skills/teams-agents for the Teams-native layer.
- Publishing to M365 Copilot/Teams flows through app manifests and the Agents Toolkit —
see
/msagent-deploy.
1---2name: m365-agents-sdk3description: Build and host custom engine agents with the Microsoft 365 Agents SDK — AgentApplication, the Activity protocol, channel reach via Azure Bot Service, hosting Agent Framework or Semantic Kernel engines, and the Agents Toolkit/Playground workflow. Successor to the Bot Framework SDK.4---56# Microsoft 365 Agents SDK78The channel and hosting layer for **custom engine agents**: receives and sends messages9across Microsoft 365 Copilot, Teams, web, and 10+ third-party channels (Slack, Facebook10Messenger, Twilio, SMS, email) via **Azure Bot Service**, which translates channel traffic11into Activities. It is the **successor to the Bot Framework SDK** (BF SDK and Emulator are12archived; support ended 2025-12-31). AI-agnostic: host Microsoft Agent Framework, Semantic13Kernel, LangChain, OpenAI Agents, or Foundry agents inside it.14Docs: https://learn.microsoft.com/microsoft-365/agents-sdk/agents-sdk-overview1516**Status (mid-2026):** GA — .NET v1.6.x (.NET 8+), JavaScript v1.6.x (Node 18+), Python v1.1.x.1718## Packages1920| Language | Packages |21|---|---|22| .NET | **`Microsoft.Agents.Builder`** (AgentApplication, routing, middleware, turn context), `Microsoft.Agents.Core` (Activity models), `Microsoft.Agents.Storage`, `Microsoft.Agents.Authentication`, `Microsoft.Agents.Connector`, `Microsoft.Agents.Storage.Transcript` |23| JS/TS | **`@microsoft/agents-hosting`**, `@microsoft/agents-hosting-express`, `@microsoft/agents-activity` |24| Python | `microsoft-agents-hosting-core`, `microsoft-agents-activity`, `microsoft-agents-hosting-aiohttp`, `microsoft-agents-authentication-msal`, `microsoft-agents-storage-blob` / `-cosmos`, `microsoft-agents-hosting-teams` (imports from `microsoft_agents`) |2526## Core concepts2728- **Activity Protocol** — the standard JSON message format shared across channels; typed29 models live in `Microsoft.Agents.Core` / `@microsoft/agents-activity`.30- **`AgentApplication`** — your entry point. Pipeline: Channel → hosting layer (HTTP auth)31 → AgentApplication routing → your handlers, with turn state loaded before and saved after32 each handler. Route ranking (`RouteRank.Last`) orders catch-alls.33- **`CloudAdapter`** processes `/api/messages`; agents are stateless with pluggable storage34 (memory, Blob, Cosmos).35- **Tooling:** **Microsoft 365 Agents Toolkit** (formerly Teams Toolkit — VS, VS Code, CLI)36 for scaffolding/manifests/publishing, and the **Microsoft 365 Agents Playground** — a37 local Teams-like sandbox needing no tenant, tunnel, or bot registration.38- **Agent 365 SDK** (`@microsoft/agents-a365-*`) layers on enterprise observability39 (OpenTelemetry), notifications, MCP tool-server management, and Entra-based agent identity.4041## Minimal agents4243```csharp44public class EchoAgent : AgentApplication45{46 public EchoAgent(AgentApplicationOptions options) : base(options)47 => OnActivity(ActivityTypes.Message, OnMessageAsync, rank: RouteRank.Last);4849 private async Task OnMessageAsync(ITurnContext tc, ITurnState ts, CancellationToken ct)50 => await tc.SendActivityAsync($"You said: {tc.Activity.Text}", cancellationToken: ct);51}52```5354```typescript55import { AgentApplication, MemoryStorage, TurnContext, TurnState } from '@microsoft/agents-hosting'56import { startServer } from '@microsoft/agents-hosting-express'5758const app = new AgentApplication<TurnState>({ storage: new MemoryStorage() })59app.onActivity('message', async (ctx: TurnContext) => ctx.sendActivity(`You said: ${ctx.activity.text}`))60startServer(app)61```6263## Hosting an AI engine inside6465The SDK is plumbing; the intelligence is whatever you host. The documented pattern for66Agent Framework / Semantic Kernel: instantiate the engine agent once, then call it from the67message handler and relay the result as an activity.68Guide: https://learn.microsoft.com/microsoft-365/agents-sdk/using-semantic-kernel-agent-framework6970Keep the layers separate: channel/UX concerns (activities, cards, auth) in the71AgentApplication handler; reasoning/tools in the engine (see `skills/agent-framework`).7273## Bot Framework migration7475Coming from Bot Framework v4 (see `/msagent-migrate`):7677- The Activity protocol carries over — message shapes and channel semantics are familiar.78- `ActivityHandler`/adapter wiring becomes `AgentApplication` routing; middleware moves to79 the new pipeline.80- Dialogs have no direct successor — replace waterfall dialogs with an LLM engine + tools,81 or explicit state machines for strictly deterministic flows.82- Re-register the messaging endpoint against Azure Bot Service; update auth to the current83 `Microsoft.Agents.Authentication` / MSAL configuration.8485## Practices8687- Develop against the Agents Playground first; only stand up tunnels/bot registrations when88 channel-specific behavior needs testing.89- Store per-conversation state via the SDK's storage abstractions, not process memory, so90 scale-out works.91- One agent codebase, many channels: guard Teams-only affordances (cards, meetings) behind92 channel checks — see `skills/teams-agents` for the Teams-native layer.93- Publishing to M365 Copilot/Teams flows through app manifests and the Agents Toolkit —94 see `/msagent-deploy`.