agents-sdk-dotnet-activityhandler-migration

A migration guide for moving a Microsoft 365 bot from ActivityHandler or TeamsActivityHandler to AgentApplication in .NET. These are Microsoft bot programming patterns for receiving and routing messages.

In plain words
What is it for?
Use it for .NET projects using Microsoft.Agents packages whose bot class still inherits from ActivityHandler or TeamsActivityHandler.
Why use it?
It explains the code changes needed to replace the older compatibility layer with the newer routing pattern.

Skill for Claude CodeCodex

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add skills/microsoft/agents/agents-sdk-dotnet-activityhandler-migration
Any agent
npx skills add microsoft/Agents --skill agents-sdk-dotnet-activityhandler-migration
Clone the repo
git clone --depth 1 https://github.com/microsoft/Agents

Made for: Claude Code, Codex.

Per session 76 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 9,442 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00076 $0.09442
Opus 5 $0.00038 $0.04721
Sonnet 5 $0.00015 $0.01888
Haiku 4.5 $0.00008 $0.00944

Measured 2d ago against content hash db61a9a3eb35, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

agents-sdk-dotnet-activityhandler-migration scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 2d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

agent-plugins/agents-for-net/skills/agents-sdk-dotnet-activityhandler-migration/SKILL.md · 759 lines

How it starts

The opening of the file, as written. The whole thing — 759 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Agents SDK ActivityHandler → AgentApplication Migration (.NET)

Overview

Upgrades a bot from the ActivityHandler compat layer to the modern AgentApplication routing pattern. This is ONLY for DotNet projects that already use Microsoft.Agents.* packages. If the project is still using Microsoft.Bot.* packages the bf-to-agents-sdk-dotnet-migration skill should be used first.

Two entry points:

  • Standalone: The bot already uses Microsoft.Agents.* packages, namespaces, and appsettings — focus is on the bot class, Program.cs, and endpoint mapping.
  • Second step after bf-to-agents-sdk-dotnet-migration: Packages, namespaces, and appsettings were converted in that step — this skill handles the AgentApplication conversion.

What Does NOT Need to Change

Verify each of these is already correct — do not modify unless broken:

Item Expected State
Namespaces in bot class Already Microsoft.Agents.* — only remove compat namespaces
appsettings.json Already has Connections + TokenValidation sections
builder.Services.AddAgentAspNetAuthentication(...) Already present — keep
AspNetExtensions.cs (if present) Sample-provided auth helper — keep as-is
Custom DI in Program.cs Preserve dialogs, adapters, custom services — but remove ConversationState and UserState (see Step 2)

⚠️ If beta packages are required: Tell the user explicitly: "This migration uses pre-release (-beta) Agents SDK packages, which are nightly builds and not suitable for production. Upgrade to a stable release before deploying."


Handler Mapping: ActivityHandler → AgentApplication

ActivityHandler Override AgentApplication Registration
OnMessageActivityAsync(ITurnContext<IMessageActivity>, CT) OnActivity(ActivityTypes.Message, handler, rank: RouteRank.Last)
OnMembersAddedAsync(IList<ChannelAccount>, ITurnContext<IConversationUpdateActivity>, CT) OnConversationUpdate(ConversationUpdateEvents.MembersAdded, handler)
OnMembersRemovedAsync(...) OnConversationUpdate(ConversationUpdateEvents.MembersRemoved, handler)
OnMessageUpdateActivityAsync(...) OnActivity(ActivityTypes.MessageUpdate, handler)
OnMessageDeleteActivityAsync(...) OnActivity(ActivityTypes.MessageDelete, handler)
OnReactionsAddedAsync(IList<MessageReaction>, ...) OnMessageReactionsAdded(handler)
OnReactionsRemovedAsync(IList<MessageReaction>, ...) OnMessageReactionsRemoved(handler)
OnEventAsync(ITurnContext<IEventActivity>, CT) OnEvent(eventName, handler) or OnActivity(ActivityTypes.Event, handler)
OnInvokeActivityAsync(...) with adaptiveCard/action + verb switch AdaptiveCards.OnActionExecute(verb, handler) — one registration per verb (preferred)
OnInvokeActivityAsync(...) with application/search AdaptiveCards.OnSearch(dataset, handler) — one registration per choices.data.dataset value
OnInvokeActivityAsync(...) (other invoke types) OnActivity(ActivityTypes.Invoke, handler)
OnTurnAsync(...) override (cross-cutting) OnBeforeTurn(handler) / OnAfterTurn(handler)
OnInstallationUpdateActivityAsync(...) OnActivity(ActivityTypes.InstallationUpdate, handler)
OnEndOfConversationActivityAsync(...) OnActivity(ActivityTypes.EndOfConversation, handler)

Read the full file on GitHub · 759 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 2d ago First seen · 759 lines · 76 tokens per session scan A db61a9a3eb35

Subscribe to this mod's changes

agents-sdk-dotnet-activityhandler-migration is a skill published in the GitHub repository microsoft/Agents (1,050 stars, last pushed 5d ago), licensed MIT. It adds 76 tokens to every session and 9,442 once invoked, about $0.0004 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.

Related

Other skills, from other repositories

m365-agents-dotnet

Microsoft 365 Agents SDK for .NET. Build multichannel agents for Teams/M365/Copilot Studio with ASP.NET Core hosting, AgentApplication routing, and MSAL-based auth. Triggers: "Microsoft 365 Agents SDK", "Microsoft.Agents", "AddAgentApplicationOptions", "AgentApplication", "AddAgentAspNetAuthentication", "Copilot…

microsoft/skills · 89 tokens

azure-ai-agents-persistent-dotnet

Azure AI Agents Persistent SDK for .NET. Low-level SDK for creating and managing AI agents with threads, messages, runs, and tools. Use for agent CRUD, conversation threads, streaming responses, function calling, file search, and code interpreter. Triggers: "PersistentAgentsClient", "persistent agents", "agent…

microsoft/skills · 90 tokens

azure-ai-openai-dotnet

Azure OpenAI SDK for .NET. Client library for Azure OpenAI and OpenAI services. Use for chat completions, embeddings, image generation, audio transcription, and assistants. Triggers: "Azure OpenAI", "AzureOpenAIClient", "ChatClient", "chat completions .NET", "GPT-4", "embeddings", "DALL-E", "Whisper", "OpenAI .NET".

microsoft/skills · 92 tokens

azure-ai-projects-dotnet

Azure AI Projects SDK for .NET. High-level client for Azure AI Foundry projects including agents, connections, datasets, deployments, evaluations, and indexes. Use for AI Foundry project management, versioned agents, and orchestration. Triggers: "AI Projects", "AIProjectClient", "Foundry project", "versioned agents"…

microsoft/skills · 92 tokens

azure-eventgrid-dotnet

Azure Event Grid SDK for .NET. Client library for publishing and consuming events with Azure Event Grid. Use for event-driven architectures, pub/sub messaging, CloudEvents, and EventGridEvents. Triggers: "Event Grid", "EventGridPublisherClient", "CloudEvent", "EventGridEvent", "publish events .NET", "event-driven"…

microsoft/skills · 80 tokens

azure-mgmt-mongodbatlas-dotnet

Manage MongoDB Atlas Organizations as Azure ARM resources using Azure.ResourceManager.MongoDBAtlas SDK. Use when creating, updating, listing, or deleting MongoDB Atlas organizations through Azure Marketplace integration. This SDK manages the Azure-side organization resource, not Atlas clusters/databases directly.

microsoft/skills · 64 tokens