agentleFS
MicrosoftKnown publishermicrosoft/Agent365-dotnet/CLAUDE.md

Agent365-dotnet

CLAUDE.md29 starsChanged 10 months agoMITView on GitHub

Exceptions: - Auto-generated files (.g.cs, .designer.cs, files with <auto-generated> markers) - Files in bin/, obj/ directories - Third-party or vendored code The following three constants must stay in sync. If a PR changes any one of them, the reviewer (human or Copilot) must ask the author to confirm the other two are still correct: Snapshot tests in src/Tests/Microsoft.Agents.A365.Observability.Runtime.Tests/Tracing/Exporters/ExportConfigConsistencyTests.cs will fail if any value drifts, but the developer must also verify the values are correct for the target environment — the…

The file

We split this CLAUDE.md into the rules it gives an agent

8 rules. About 0 are common, 5 are distinctive, and 3 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.

  • 3

    Very specific

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

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Never specify versions directly in project files

    line 43
  2. Distinctive:

    Every C# file must include this header at the top:

    line 48
  3. Distinctive:

    Never: use the keyword "Kairo" in any code - this is legacy terminology that must be replaced

    line 60
  4. Distinctive:

    Before committing changes, ensure:

    line 75
  5. Very specific:

    All tests pass: dotnet test src/Microsoft.Agents.A365.Sdk.sln

    line 77
  6. Very specific:

    If adding/renaming/removing projects, update src/Microsoft.Agents.A365.Sdk.sln

    line 78
  7. Distinctive:

    All published NuGet packages follow the pattern:

    line 215
  8. Very specific:

    Call ListToolServersAsync to query Tooling Gateway

    line 237

≈ “Common” is an estimate: at least 1 in 5 of the 12,729 CLAUDE.md 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
CLAUDE.md

CLAUDE.md

This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.

Build Commands

Basic Build Operations

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

# Build using PowerShell script (recommended)
./build/build.ps1

# Full clean rebuild
./build/build.ps1 -Clean -Restore

# Build with tests
./build/build.ps1 -Test

# Build with NuGet packaging
./build/build.ps1 -Pack

# Debug build with tests
./build/build.ps1 -Configuration Debug -Test

Testing

# Run all tests
dotnet test src/Microsoft.Agents.A365.Sdk.sln

# Run tests using build script
./build/build.ps1 -Test

# Run tests for a specific project
dotnet test src/Tests/Runtime.Tests/Microsoft.Agents.A365.Runtime.Tests.csproj

Package Management

  • All package versions are centralized in src/Directory.Packages.props
  • To add a new package: add the version to Directory.Packages.props, then reference without version in the .csproj
  • Never specify versions directly in project files

Code Standards

Copyright Headers

Every C# file must include this header at the top:

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

Exceptions:

  • Auto-generated files (.g.cs, .designer.cs, files with <auto-generated> markers)
  • Files in bin/, obj/ directories
  • Third-party or vendored code

Legacy References

  • Never use the keyword "Kairo" in any code - this is legacy terminology that must be replaced

Observability Export Configuration — Coordinated Review Required

The following three constants must stay in sync. If a PR changes any one of them, the reviewer (human or Copilot) must ask the author to confirm the other two are still correct:

ConstantLocation
ProdObservabilityScopesrc/Observability/Runtime/Common/EnvironmentUtils.cs (accessed via GetObservabilityAuthenticationScope())
DefaultEndpointHostsrc/Observability/Runtime/Tracing/Exporters/Agent365ExporterOptions.cs
Export URL path patternBuildEndpointPath() in src/Observability/Runtime/Tracing/Exporters/Agent365ExporterCore.cs

Snapshot tests in src/Tests/Microsoft.Agents.A365.Observability.Runtime.Tests/Tracing/Exporters/ExportConfigConsistencyTests.cs will fail if any value drifts, but the developer must also verify the values are correct for the target environment — the tests only catch accidental drift, not intentional-but-incomplete updates.

Pre-Commit Requirements

Before committing changes, ensure:

  1. The solution builds: dotnet build src/Microsoft.Agents.A365.Sdk.sln
  2. All tests pass: dotnet test src/Microsoft.Agents.A365.Sdk.sln
  3. If adding/renaming/removing projects, update src/Microsoft.Agents.A365.Sdk.sln

Architecture Overview

Four Core Modules

This SDK extends the Microsoft 365 Agents SDK with four main areas:

1. Runtime (Microsoft.Agents.A365.Runtime)

  • Multi-tenant context extraction via TenantContextHelper (claims, headers, items)
  • Standardized result handling with OperationResult and OperationError
  • Authorization services for agentic operations

2. Observability (6 packages under Microsoft.Agents.A365.Observability.*)

  • OpenTelemetry-based distributed tracing with custom span processors
  • Scope classes: InvokeAgentScope, InferenceScope, ExecuteToolScope
  • Framework extensions for Agent Framework, Semantic Kernel, and OpenAI SDK
  • ETW (Event Tracing for Windows) support via Hosting package
  • Configuration via fluent Builder API

3. Notifications (Microsoft.Agents.A365.Notifications)

  • Event-driven notification handling for M365 (Teams, email, Office apps)
  • Support for agents:email, agents:word, agents:excel, agents:powerpoint sub-channels
  • Type-safe models: EmailReference, EmailResponse, WpxComment
  • Lifecycle notifications (user identity created, auto sign-in)

4. Tooling (4 packages under Microsoft.Agents.A365.Tooling.*)

  • Model Context Protocol (MCP) server discovery and integration
  • IMcpToolServerConfigurationService for server discovery and tool registration
  • Framework-specific registration for Semantic Kernel, Agent Framework, Azure AI Foundry
  • Bearer token and context header handling for tool server communication

Extension Pattern

The SDK uses a consistent Core + Extensions pattern:

  • Core packages provide base functionality
  • Extension packages integrate with specific frameworks (SemanticKernel, AgentFramework, AzureAIFoundry, OpenAI)
  • Example: Observability/Runtime (core) → Observability/Extensions/SemanticKernel (framework-specific)

Key Design Patterns

Builder Pattern: Fluent API for observability configuration

new Builder(services, configuration)
    .WithAgentFramework()
    .WithSemanticKernel()
    .Build();

Disposable Pattern: Automatic span lifecycle management

using var scope = InvokeAgentScope.Start(details, tenantDetails, request);
scope.RecordResponse(response);
// Span automatically ends on dispose

Result Pattern: Consistent success/failure handling

return OperationResult.Success;
return OperationResult.Failed(new OperationError("Message", HttpStatusCode.NotFound));

Project Organization

Target Frameworks

  • Most packages: net8.0
  • Runtime/Hosting packages: netstandard2.0 (broader compatibility)

Build System

  • SDK Version: .NET 8.0.100 (defined in src/global.json)
  • Build Traversal: Microsoft.Build.Traversal (v3.4.0) via src/dirs.proj
  • Automatic Discovery: Projects are auto-discovered via wildcards; no manual solution maintenance needed
  • Versioning: Nerdbank.GitVersioning (nbgv) - semantic versioning from git history

Configuration Files

  • src/global.json - .NET SDK version lock
  • src/Directory.Packages.props - Single source of truth for all NuGet versions
  • src/Directory.Build.props - Common build properties (warnings as errors, nullable enabled, XML docs)
  • src/dirs.proj - Build traversal root

Common Build Properties

  • Warnings treated as errors
  • Nullable reference types enabled
  • XML documentation generation enabled
  • Implicit usings enabled (net6.0+)
  • Source Link embedded for debugging

Key Dependencies

PackageVersionPurpose
Microsoft.Agents.Builder1.3.163-betaCore Agents SDK
Microsoft.Agents.AI1.0.0-preview.251016.1Agent Framework
OpenTelemetry1.11.2Distributed tracing foundation
Microsoft.SemanticKernel1.65.0Semantic Kernel orchestration
Azure.AI.OpenAI2.3.0-beta.2Azure OpenAI SDK
ModelContextProtocol.Core0.2.0-preview.3MCP client SDK
Azure.AI.Agents.Persistent1.2.0-beta.4Azure AI Foundry

Important Classes and Entry Points

Runtime (src/Runtime/Core/)

  • TenantContextHelper - Extract tenant/worker ID from HttpContext
  • AgenticAuthorizationService - Authorization for agent operations

Observability (src/Observability/)

  • Builder (Runtime) - Fluent OpenTelemetry configuration API
  • InvokeAgentScope, InferenceScope, ExecuteToolScope - Tracing scopes
  • BaggageBuilder - OpenTelemetry baggage context management

Notifications (src/Notification/)

  • AgentNotification - AgentExtension for routing notifications
  • AgentNotificationActivity - Activity wrapper for notification data

Tooling (src/Tooling/Core/)

  • IMcpToolServerConfigurationService - MCP server discovery interface
  • McpToolServerConfigurationService - Implementation
  • MCPServerConfig - Server configuration model

Environment Variables

VariablePurposeDefault
EnableAgent365ExporterEnable Agent365 telemetry exporterfalse
ASPNETCORE_ENVIRONMENTEnvironment (Development, Production)-
SuppressInvokeAgentInputSuppress input in invoke_agent spansfalse

Testing Structure

Tests mirror the source structure in src/Tests/:

  • Unit tests for each package (e.g., Microsoft.Agents.A365.Runtime.Tests)
  • Integration tests (e.g., Microsoft.Agents.A365.Observability.Runtime.IntegrationTests)
  • Framework-specific extension tests

Testing frameworks: xUnit (primary), MSTest, with Moq for mocking and FluentAssertions for assertions.

Package Naming Convention

All published NuGet packages follow the pattern:

Microsoft.Agents.A365.<Module>[.Extensions.<Framework>]

Examples:

  • Microsoft.Agents.A365.Runtime
  • Microsoft.Agents.A365.Observability.Extensions.SemanticKernel
  • Microsoft.Agents.A365.Tooling.Extensions.AzureAIFoundry

Data Flow Examples

Agent Invocation Tracing

  1. HTTP request enters via middleware
  2. BaggageMiddleware sets tenant/agent context in OpenTelemetry baggage
  3. InvokeAgentScope creates root span for agent invocation
  4. InferenceScope creates child span for LLM inference
  5. ExecuteToolScope creates child spans for tool executions
  6. Span processors add tags and export to Agent365 Exporter or Console

MCP Tool Discovery

  1. Agent receives user message requiring tools
  2. Call ListToolServersAsync to query Tooling Gateway
  3. For each server, call GetMcpClientToolsAsync to connect via MCP SDK
  4. Register tools with orchestrator (Semantic Kernel / Agent Framework / Azure AI Foundry)
  5. Agent executes user request with discovered tools

Additional Resources

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.