agentleFS
MicrosoftKnown publishermicrosoft/Agent365-dotnet/.github/copilot-instructions.md

Agent365-dotnet

Copilot instructions29 starsChanged 10 months agoMITView on GitHub

The Microsoft Agent 365 SDK (C#/.NET) extends the Microsoft 365 Agents SDK with enterprise capabilities across four modules: Observability, Notifications, Runtime, and Tooling. Packages publish to NuGet under the Microsoft.Agents.A365.* prefix. All commands run from the repository root unless noted. Requires the .NET 8.0.100 SDK (pinned in src/global.json). CI (.github/workflows/ci.yml) builds and tests in Release with --no-restore/--no-build, then packs. Some Observability/Tooling tests read AZURE_OPENAI_ENDPOINT, AZURE_OPENAI_API_KEY, and AZURE_OPENAI_DEPLOYMENT from the environment. Pre-commit hooks (.pre-commit-config.yaml, install with pip install pre-commit && pre-commit…

  • Reads credentials
  • Installs packages
  • In this repositoryOne other file it gives its agents.

The file

Show its rules and text

We split this copilot-instructions.md into the rules it gives an agent

18 rules. About 0 are common, 11 are distinctive, and 7 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈11

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 7

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    All commands run from the repository root unless noted.

    line 7
  2. Very specific:

    Central package management: ALL NuGet versions live in src/Directory.Packages.props.

    line 49
  3. Very specific:

    Before committing changes, ensure that the solution src/Microsoft.Agents.A365.Sdk.sln builds: dotnet build src/Microsoft.Agents.A365.Sdk.sln

    line 62
  4. Very specific:

    Before committing changes, ensure that all tests pass: dotnet test src/Microsoft.Agents.A365.Sdk.sln

    line 63
  5. Very specific:

    When adding a new project, renaming a project, or removing a project (.csproj file), ensure that the solution file …

    line 64
  6. Distinctive:

    Ensure that each file added or modified has the correct copyright header:

    line 65
  7. Distinctive:

    Action: If "Kairo" is found in any code file:

    line 75
  8. Distinctive:

    Check if it's a legacy reference that needs to be updated

    line 78
  9. Distinctive:

    Description: Ensure all C# files have proper Microsoft copyright headers

    line 82
  10. Very specific:

    Action: If a .cs file is missing a copyright header:

    line 83
  11. Distinctive:

    Add the Microsoft copyright header at the top of the file

    line 84
  12. Distinctive:

    Search for case-insensitive matches of "Kairo"

    line 98
  13. Distinctive:

    Verify the first non-empty lines of C# files

    line 109
  14. Distinctive:

    If missing, prepend the copyright header

    line 110
  15. Distinctive:

    Ensure there's a blank line after the header before other content

    line 111
  16. Distinctive:

    Do not add headers to:

    line 112
  17. Distinctive:

    When Copilot detects violations:

    line 170
  18. Very specific:

    Test files in Tests/, test/, or files ending with .Tests.cs, .Test.cs may have relaxed header requirements (but headers are still …

    line 175

≈ “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.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
copilot-instructions.md

GitHub Copilot Instructions for Agent365-dotnet

The Microsoft Agent 365 SDK (C#/.NET) extends the Microsoft 365 Agents SDK with enterprise capabilities across four modules: Observability, Notifications, Runtime, and Tooling. Packages publish to NuGet under the Microsoft.Agents.A365.* prefix.

Build, Test, and Lint

All commands run from the repository root unless noted. Requires the .NET 8.0.100 SDK (pinned in src/global.json).

# Build / test the whole solution
dotnet build src/Microsoft.Agents.A365.Sdk.sln
dotnet test  src/Microsoft.Agents.A365.Sdk.sln

# Build script (traversal build via src/dirs.proj) — preferred for full runs
./build/build.ps1                                   # Release build
./build/build.ps1 -Clean -Restore -Test             # clean rebuild + tests
./build/build.ps1 -Pack                              # produce NuGet packages

# Run all tests in ONE project
dotnet test src/Tests/Microsoft.Agents.A365.Runtime.Tests/Microsoft.Agents.A365.Runtime.Tests.csproj

# Run a SINGLE test or test class (xUnit primary; some MSTest)
dotnet test src/Microsoft.Agents.A365.Sdk.sln --filter "FullyQualifiedName~TenantContextHelperTests"
dotnet test src/Microsoft.Agents.A365.Sdk.sln --filter "Name=Extract_Returns_TenantId"

# Format check (enforced as a pre-commit hook)
dotnet format src/Microsoft.Agents.A365.Sdk.sln --verify-no-changes

CI (.github/workflows/ci.yml) builds and tests in Release with --no-restore/--no-build, then packs. Some Observability/Tooling tests read AZURE_OPENAI_ENDPOINT, AZURE_OPENAI_API_KEY, and AZURE_OPENAI_DEPLOYMENT from the environment.

Pre-commit hooks (.pre-commit-config.yaml, install with pip install pre-commit && pre-commit install) run gitleaks (secret scanning), whitespace/EOL fixers, and dotnet format.

Architecture

The SDK follows a consistent Core + Extensions pattern. Each module has a Core/Runtime package with base functionality and per-framework extension packages (SemanticKernel, AgentFramework, AzureAIFoundry, OpenAI). Source lives under src/<Module>/:

  • Runtime (src/Runtime/) — multi-tenant context extraction (TenantContextHelper pulls tenant/worker IDs from HttpContext claims/headers/items) and the result pattern (OperationResult / OperationError).
  • Observability (src/Observability/) — OpenTelemetry distributed tracing. Configured via a fluent Builder API; tracing uses disposable scope classes (InvokeAgentScope, InferenceScope, ExecuteToolScope) that auto-end spans on dispose. BaggageMiddleware seeds tenant/agent context into OTel baggage. A custom Agent365Exporter (gated by the EnableAgent365Exporter env var) exports spans.
  • Notifications (src/Notification/) — event routing for M365 (Teams, email, Office) via AgentNotification; sub-channels like agents:email, agents:word, agents:excel, agents:powerpoint.
  • Tooling (src/Tooling/) — Model Context Protocol (MCP) server discovery and tool registration via IMcpToolServerConfigurationService, with framework-specific registration extensions.

Build is a traversal build: src/dirs.proj (Microsoft.Build.Traversal) references each module's dirs.proj. Projects are auto-discovered, but the solution file is still maintained manually (see rules below). Versioning is automatic via Nerdbank.GitVersioning (nbgv) from git history — never hardcode versions.

Detailed design docs: docs/design.md; build internals: build/BUILD.md.

Key Conventions

  • Central package management: ALL NuGet versions live in src/Directory.Packages.props. Add a version there, then reference the package without a Version attribute in the .csproj. Never put versions in project files.
  • Common build props (src/Directory.Build.props): TreatWarningsAsErrors=true, Nullable=enable, and GenerateDocumentationFile=true are global. Warnings — including invalid XML-doc crefs (CS1574) — fail the build. Write valid XML doc comments.
  • Target frameworks: most packages target net8.0; some Runtime/Hosting packages target netstandard2.0 (no implicit usings; LangVersion 8.0). Guard framework-specific code accordingly.
  • Observability export config — coordinated change required: these three must stay in sync. If you change ONE, verify the other two:
    ConstantLocation
    ProdObservabilityScope (via GetObservabilityAuthenticationScope())src/Observability/Runtime/Common/EnvironmentUtils.cs
    DefaultEndpointHostsrc/Observability/Runtime/Tracing/Exporters/Agent365ExporterOptions.cs
    Export URL path (BuildEndpointPath())src/Observability/Runtime/Tracing/Exporters/Agent365ExporterCore.cs
    Snapshot tests in src/Tests/Microsoft.Agents.A365.Observability.Runtime.Tests/Tracing/Exporters/ExportConfigConsistencyTests.cs catch accidental drift but not intentional-but-incomplete updates — confirm values are correct for the target environment.
  • Tests mirror source under src/Tests/ (e.g. Microsoft.Agents.A365.Runtime.Tests). xUnit is primary (some MSTest), with Moq for mocking and FluentAssertions for assertions.

Coding agent rules

  • Before committing changes, ensure that the solution src/Microsoft.Agents.A365.Sdk.sln builds: dotnet build src/Microsoft.Agents.A365.Sdk.sln
  • Before committing changes, ensure that all tests pass: dotnet test src/Microsoft.Agents.A365.Sdk.sln
  • When adding a new project, renaming a project, or removing a project (.csproj file), ensure that the solution file src/Microsoft.Agents.A365.Sdk.sln is updated accordingly.
  • Ensure that each file added or modified has the correct copyright header:
    // Copyright (c) Microsoft Corporation.
    // Licensed under the MIT License.

Code Review Rules

Rule 1: Check for "Kairo" Keyword

  • Description: Scan code for any occurrence of the keyword "Kairo"
  • Action: If "Kairo" is found in any code file:
    • Flag it for review
    • Suggest removal or replacement with appropriate terminology
    • Check if it's a legacy reference that needs to be updated
  • Files to check: All .cs, .csx files in the repository

Rule 2: Verify Copyright Headers

  • Description: Ensure all C# files have proper Microsoft copyright headers
  • Action: If a .cs file is missing a copyright header:
    • Add the Microsoft copyright header at the top of the file
    • The header should be placed before any using statements or code
    • Maintain proper formatting and spacing

Required Copyright Header Format

// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

Implementation Guidelines

When Reviewing Code:

  1. Kairo Check:
    • Search for case-insensitive matches of "Kairo"
    • Review context to determine if it's:
      • A class name
      • A namespace
      • A variable name
      • A comment reference
      • A using statement
      • A string literal
    • Suggest appropriate alternatives based on the context
  2. Header Check:
    • Verify the first non-empty lines of C# files
    • If missing, prepend the copyright header
    • Ensure there's a blank line after the header before other content
    • Do not add headers to:
      • Auto-generated files (marked with <auto-generated> or // <auto-generated />)
      • Designer files (.Designer.cs)
      • Files with #pragma warning disable at the top for generated code

Example of Proper File Structure:

// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

using System;
using System.Collections.Generic;
using Microsoft.Extensions.Logging;

namespace MyNamespace
{
    /// <summary>
    /// Class documentation
    /// </summary>
    public class MyClass
    {
        // Rest of the code...
    }
}

Example with File-Scoped Namespace (C# 10+):

// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

using System;
using System.Threading.Tasks;

namespace MyNamespace;

/// <summary>
/// Class documentation
/// </summary>
public class MyClass
{
    // Rest of the code...
}

Example with Top-Level Statements (C# 9+):

// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

using System;

var builder = WebApplication.CreateBuilder(args);

// Rest of the code...

Auto-fix Behavior

When Copilot detects violations:

  • Kairo keyword: Suggest inline replacement or flag for manual review
  • Missing header: Automatically suggest adding the copyright header

Exclusions

  • Test files in Tests/, test/, or files ending with .Tests.cs, .Test.cs may have relaxed header requirements (but headers are still recommended)
  • Auto-generated files (.g.cs, .designer.cs, files with auto-generated markers)
  • Third-party code or vendored dependencies should not be modified
  • Project files (.csproj, .sln), configuration files (.json, .xml, .yaml, .md) do not require copyright headers
  • Build output directories (bin/, obj/)
  • AssemblyInfo.cs files that are auto-generated

Download now (ZIP)

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
What did you use it for? e.g. Reviewing pull requests in a Rails app

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.