Agents-for-net
Copilot instructions181 starsChanged 58 days agoMITView on GitHub
This is the Microsoft 365 Agents SDK for .NET — a framework for building enterprise-grade conversational agents that work across M365, Teams, Copilot Studio, and other platforms. Current State: Generally Available (GA) Documentation: https://learn.microsoft.com/en-us/microsoft-365/agents-sdk/ The SDK is organized into layered libraries under src/libraries/. See docs/architecture.md for an architecture overview. See src/samples/EmptyAgent/Program.cs for the canonical minimal example. Microsoft.Agents.Extensions.MSTeams (src/libraries/Extensions/Microsoft.Agents.Extensions.MSTeams/) - Full Microsoft Teams extensibility: message extensions, task modules, meeting events, channel/team lifecycle, and file consent - Aligns its models and public…
In this repositoryOne other file it gives its agents.
- CLAUDE.mdCLAUDE.md
The file
We split this copilot-instructions.md into the rules it gives an agent
11 rules. About 0 are common, 5 are distinctive, and 6 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈5
Distinctive · estimate
This author's own choices. Worth a look.
6
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 89
Keep protocol-, channel-, and feature-specific implementation inside its AgentExtension project.
- Distinctive: line 90
Do not add AgentExtension-specific behavior to Agents SDK Core, Builder, or Hosting.
- Very specific: line 134
When adding or editing XML documentation comments, use fully qualified symbol names, including namespaces and containing types, in every …
- Distinctive: line 135
Verify that each referenced type or member still exists at that location and that member references use the current signature.
- Very specific: line 136
If a symbol cannot be referenced from the documenting project because of assembly or target-framework constraints, use fully qualified <c> …
- Very specific: line 140
Test projects are under src/tests/ and may target both .NET 8.0 and .NET Framework 4.8.
- Very specific: line 141
Test helpers in Microsoft.Agents.Builder.Testing.
- Distinctive: line 143
Do not use Task.Delay in tests as they cause flakiness.
- Very specific: line 173
Default agent port: http://localhost:3978
- Very specific: line 174
Use devtunnel for external client connections (Teams, Bot Service)
- Distinctive: line 175
Use Agents Playground for local testing without tunnels
≈ “Common” is an estimate: at least 1 in 5 of the 1,644 Copilot instructions files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Copilot Instructions for Agents-for-net
Project Overview
This is the Microsoft 365 Agents SDK for .NET — a framework for building enterprise-grade conversational agents that work across M365, Teams, Copilot Studio, and other platforms.
Current State: Generally Available (GA)
Documentation: https://learn.microsoft.com/en-us/microsoft-365/agents-sdk/
Build and Test
# Build entire solution
dotnet build src/Microsoft.Agents.SDK.sln
# Build via top-level project (includes all libraries)
dotnet build AgentSdk.proj
# Restore dependencies
dotnet restore AgentSdk.proj
# Run all tests
dotnet test --no-build -c Debug ./src/
# Run tests for a single project
dotnet test src/tests/Microsoft.Agents.Core.Tests/
# Run a single test
dotnet test --filter "FullyQualifiedName~Namespace.ClassName.MethodName"
# Create NuGet packages
dotnet pack --no-build -c Debug src/Microsoft.Agents.SDK.slnArchitecture
The SDK is organized into layered libraries under src/libraries/. See docs/architecture.md for an architecture overview.
Agent Pattern
public class MyAgent : AgentApplication
{
public MyAgent(AgentApplicationOptions options) : base(options)
{
OnConversationUpdate(ConversationUpdateEvents.MembersAdded, WelcomeMessageAsync);
OnActivity(ActivityTypes.Message, OnMessageAsync, rank: RouteRank.Last);
}
}ASP.NET Core Startup
builder.AddAgent<MyAgent>();
builder.Services.AddSingleton<IStorage, MemoryStorage>();
builder.AddAgentAuthorization(ConfigureAuthentication);
app.MapAgentApplicationEndpoints(requireAuth: !app.Environment.IsDevelopment());See src/samples/EmptyAgent/Program.cs for the canonical minimal example.
Extensions
Microsoft.Agents.Extensions.MSTeams (src/libraries/Extensions/Microsoft.Agents.Extensions.MSTeams/)
- Full Microsoft Teams extensibility: message extensions, task modules, meeting events, channel/team lifecycle, and file consent
- Aligns its models and public feature surface with the Teams SDK. When the Teams SDK removes a feature, MSTeams removes the corresponding feature rather than maintaining a compatibility implementation. These removals are breaking changes for MSTeams users and may occur in minor or patch releases.
- Depends on teams.net's
Microsoft.Teams.AppsNuGet package for Teams schema, API clients, and feature types (e.g.Microsoft.Teams.Apps.Schema.TeamsChannelData,Microsoft.Teams.Apps.Clients.ApiClient,Microsoft.Teams.Apps.MessageExtensions.*); it reimplements only routing onAgentApplication - Agent 365 lifecycle events are not handled by the Agents SDK or the MSTeams extension. Use the A365 Agent Extension (
Microsoft.Agents.A365.Notifications) for these events. - Enable with
[TeamsExtension]attribute on apartial AgentApplicationsubclass — source generator creates aTeamsproperty of typeTeamsAgentExtension - Two routing styles: fluent builders (
Teams.MessageExtensions.OnQuery(...)) or declarative attributes ([TeamsQueryRoute("cmdId")]) - Feature areas exposed as properties on
TeamsAgentExtension(accessed via the generatedTeamsproperty):Teams.MessageExtensions— search queries, link unfurling, anonymous link unfurling, action commands, compose previews, card button clicks, settingsTeams.TaskModules— modal dialogs (fetch + submit), supports string or Regex key matchingTeams.Meetings— start/end, participants join/leaveTeams.Channels— created/deleted/renamed/restored/shared/unshared; member add/removeTeams.Teams— archived/unarchived/renamed/deleted/restoredTeams.FileConsent— file upload consent accept/decline
TeamsAgentExtensionalso provides Graph helpers:GetTeamsClient()(teams.netMicrosoft.Teams.Apps.Clients.ApiClient),GetGraphClient()(user token),GetAppGraphClient()/GetAppGraphClientForConnection()(app-only)- App-level Teams route extension methods on
AgentApplication(inTeamsAppExtensions):OnTeamsHandoff()(Copilot handoff),OnTeamsFeedbackLoop(),OnTeamsMessageReactionsAdded()/OnTeamsMessageReactionsRemoved(), plus genericOnTeamsActivity()/OnTeamsMessage()/OnTeamsConversationUpdate()/OnTeamsEvent() ITeamsTurnContext/TeamsTurnContext—SendTargetedActivityAsync()for sending to specific recipientsTeamsActivityExtensions— activity helpers:TeamsGetChannelId(),TeamsGetMeetingInfo(),TeamsGetTeamInfo(),TeamsEnableFeedbackLoop(), etc.- Route builders accept
autoSignInHandlersand route attributes acceptsignInHandlersparameter for per-route OAuth/SSO flows; Teams SSO and OBO via Azure Bot Token Service are supported - Feedback is the FeedbackLoop feature in
AgentApplication; useAgentApplication.OnFeedbackLoop()or[FeedbackLoopRoute]rather than treating it as an MSTeams-specific feature. - Adaptive Cards support is handled by AgentApplication.AdaptiveCards
AgentExtension boundaries
- Keep protocol-, channel-, and feature-specific implementation inside its AgentExtension project.
- Do not add AgentExtension-specific behavior to Agents SDK Core, Builder, or Hosting.
- Changes outside the extension project must provide a general-purpose extensibility capability.
- Pull requests making such changes must explain why the extension cannot use existing extensibility points and identify the related Core documentation updates.
Microsoft.Agents.Extensions.Teams (src/libraries/Extensions/Microsoft.Agents.Extensions.Teams/)
- This is the older Teams Extension and should not be used.
Microsoft.Agents.A365.Notifications
- Separate
AgentExtension(on the"agents"channel) for inbound Agent 365 notifications — not part of the MSTeams extension. Lives in the Agent365-dotnet repo. OnLifecycleNotification(lifecycleEvent, handler)— agentic-user governance lifecycle events (AgenticUserIdentityCreated/IdentityUpdated/ManagerUpdated/Enabled/Disabled/Deleted/Undeleted/WorkloadOnboardingUpdated).OnAgentNotification(subChannelId, handler)— email, Office (Word/PowerPoint/Excel = WPX) comment, and Federated Knowledge Service notifications.- Distinct from Agent 365 agentic authentication in this repo (
AgenticAuthorization,IAgenticTokenProvider,AgenticUserAuthorization, samplesAgenticAI/A365LoopTest). - https://github.com/microsoft/Agent365-dotnet/tree/main/src/Notification/Microsoft.Agents.A365.Notifications
// Minimal Teams agent setup
[TeamsExtension]
public partial class MyAgent(AgentApplicationOptions options) : AgentApplication(options)
{
[TeamsQueryRoute("searchCmd")]
public Task<Microsoft.Teams.Apps.MessageExtensions.MessageExtensionResponse> OnSearchAsync(
ITurnContext ctx, ITurnState state,
Microsoft.Teams.Apps.MessageExtensions.MessageExtensionQuery query, CancellationToken ct)
=> Task.FromResult(new Microsoft.Teams.Apps.MessageExtensions.MessageExtensionResponse { ComposeExtension = BuildResults(query) });
}Key Conventions
Build System
- Central Package Management via
Directory.Packages.props— all package versions are declared there. - Core libraries multi-target
net8.0andnetstandard2.0(set insrc/Build.Common.core.props). - TreatWarningsAsErrors is enabled globally (
src/Build.Shared.props). - Package versioning uses Nerdbank.GitVersioning (
src/libraries/version.json). Release branches follow the patternrel/v{version}. - .NET SDK version pinned in
global.json(8.0.x withrollForward: latestMajor).
Serialization
- Uses
System.Text.Jsonexclusively (not Newtonsoft). The central serializer isProtocolJsonSerializerinMicrosoft.Agents.Core.Serialization. - Custom converters live in
Core/Microsoft.Agents.Core/Serialization/Converters/.
Nullability
- Libraries use
<Nullable>annotations</Nullable>(annotations only, warnings not enforced).
XML Documentation
- When adding or editing XML documentation comments, use fully qualified symbol names, including namespaces and containing types, in every
<see cref="...">and<seealso cref="...">reference. - Verify that each referenced type or member still exists at that location and that member references use the current signature.
- If a symbol cannot be referenced from the documenting project because of assembly or target-framework constraints, use fully qualified
<c>text instead of an unresolvedcref.
Testing
- xUnit (v2.9.3 and v3.0.1), Moq for mocking.
- Test projects are under
src/tests/and may target both .NET 8.0 and .NET Framework 4.8. - Test helpers in
Microsoft.Agents.Builder.Testing. - Telemetry tests use
[Collection("TelemetryTests")]to disable parallel execution (avoidsActivitySourcelistener conflicts). - Do not use Task.Delay in tests as they cause flakiness. Use syncronization primitives or test-specific hooks instead.
Authentication
- MSAL-based auth (
Authentication.Msal) supports ClientSecret, Federated Credentials, and Managed Identity. - ASP.NET Core authentication schemes are application-defined; the hosting package only integrates their registration and enforcement.
- Local dev port:
http://localhost:3978.
Terminology
- Agent-to-Agent refers to SDK agents communicating via the Activity Protocol — not the A2A open spec (
github.com/a2aproject/A2A). DeliveryModes.Streamis an SSE transport mechanism, unrelated to A2A.
Configuration
Authentication (appsettings.json)
- See Configure authentication in a .NET agent
- ClientSecret/Certificate: Works with dev tunnels for local debugging.
- Federated Credentials/Managed Identity: Requires deployment to App Service or container (cannot use dev tunnel).
Samples
Samples are in src/samples/. Each has its own README with setup instructions.
Key Samples:
EmptyAgent: Basic agent template — good starting pointCopilotStudioClient: Client examples for Copilot Studio integrationSemanticKernel/WeatherAgent: Shows Semantic Kernel integrationTelemetryAgent: OpenTelemetry instrumentation example
Local Development
- Default agent port:
http://localhost:3978 - Use
devtunnelfor external client connections (Teams, Bot Service) - Use Agents Playground for local testing without tunnels
Package Publishing
- Public packages: nuget.org (prefix:
Microsoft.Agents.*) - Nightly builds: nuget.org with
-betasuffix (updated overnight PT)
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

