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…
In this repositoryOne other file it gives its agents.
- .github/copilot-instructions.mdCopilot instructions
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
- Distinctive: line 43
Never specify versions directly in project files
- Distinctive: line 48
Every C# file must include this header at the top:
- Distinctive: line 60
Never: use the keyword "Kairo" in any code - this is legacy terminology that must be replaced
- Distinctive: line 75
Before committing changes, ensure:
- Very specific: line 77
All tests pass: dotnet test src/Microsoft.Agents.A365.Sdk.sln
- Very specific: line 78
If adding/renaming/removing projects, update src/Microsoft.Agents.A365.Sdk.sln
- Distinctive: line 215
All published NuGet packages follow the pattern:
- Very specific: line 237
Call ListToolServersAsync to query Tooling Gateway
≈ “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.
Files
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 -TestTesting
# 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.csprojPackage 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:
| Constant | Location |
ProdObservabilityScope | src/Observability/Runtime/Common/EnvironmentUtils.cs (accessed via GetObservabilityAuthenticationScope()) |
DefaultEndpointHost | src/Observability/Runtime/Tracing/Exporters/Agent365ExporterOptions.cs |
| Export URL path pattern | BuildEndpointPath() 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:
- The solution builds:
dotnet build src/Microsoft.Agents.A365.Sdk.sln - All tests pass:
dotnet test src/Microsoft.Agents.A365.Sdk.sln - 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
OperationResultandOperationError - 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
BuilderAPI
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:powerpointsub-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
IMcpToolServerConfigurationServicefor 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 disposeResult 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 locksrc/Directory.Packages.props- Single source of truth for all NuGet versionssrc/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
| Package | Version | Purpose |
Microsoft.Agents.Builder | 1.3.163-beta | Core Agents SDK |
Microsoft.Agents.AI | 1.0.0-preview.251016.1 | Agent Framework |
OpenTelemetry | 1.11.2 | Distributed tracing foundation |
Microsoft.SemanticKernel | 1.65.0 | Semantic Kernel orchestration |
Azure.AI.OpenAI | 2.3.0-beta.2 | Azure OpenAI SDK |
ModelContextProtocol.Core | 0.2.0-preview.3 | MCP client SDK |
Azure.AI.Agents.Persistent | 1.2.0-beta.4 | Azure AI Foundry |
Important Classes and Entry Points
Runtime (src/Runtime/Core/)
TenantContextHelper- Extract tenant/worker ID from HttpContextAgenticAuthorizationService- Authorization for agent operations
Observability (src/Observability/)
Builder(Runtime) - Fluent OpenTelemetry configuration APIInvokeAgentScope,InferenceScope,ExecuteToolScope- Tracing scopesBaggageBuilder- OpenTelemetry baggage context management
Notifications (src/Notification/)
AgentNotification- AgentExtension for routing notificationsAgentNotificationActivity- Activity wrapper for notification data
Tooling (src/Tooling/Core/)
IMcpToolServerConfigurationService- MCP server discovery interfaceMcpToolServerConfigurationService- ImplementationMCPServerConfig- Server configuration model
Environment Variables
| Variable | Purpose | Default |
EnableAgent365Exporter | Enable Agent365 telemetry exporter | false |
ASPNETCORE_ENVIRONMENT | Environment (Development, Production) | - |
SuppressInvokeAgentInput | Suppress input in invoke_agent spans | false |
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.RuntimeMicrosoft.Agents.A365.Observability.Extensions.SemanticKernelMicrosoft.Agents.A365.Tooling.Extensions.AzureAIFoundry
Data Flow Examples
Agent Invocation Tracing
- HTTP request enters via middleware
BaggageMiddlewaresets tenant/agent context in OpenTelemetry baggageInvokeAgentScopecreates root span for agent invocationInferenceScopecreates child span for LLM inferenceExecuteToolScopecreates child spans for tool executions- Span processors add tags and export to Agent365 Exporter or Console
MCP Tool Discovery
- Agent receives user message requiring tools
- Call
ListToolServersAsyncto query Tooling Gateway - For each server, call
GetMcpClientToolsAsyncto connect via MCP SDK - Register tools with orchestrator (Semantic Kernel / Agent Framework / Azure AI Foundry)
- Agent executes user request with discovered tools
Additional Resources
- Microsoft Agent 365 Developer Documentation
- Design Documentation - Detailed architecture and package-specific design docs
- Build Documentation - Comprehensive build system details
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.

