Add Claude (Anthropic SDK) sample agent for .NET#285
Open
Yogeshp-MSFT wants to merge 2 commits intomicrosoft:mainfrom
Open
Add Claude (Anthropic SDK) sample agent for .NET#285Yogeshp-MSFT wants to merge 2 commits intomicrosoft:mainfrom
Yogeshp-MSFT wants to merge 2 commits intomicrosoft:mainfrom
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adds a new .NET sample agent under dotnet/claude/sample-agent demonstrating how to use Anthropic Claude (via Anthropic.SDK) as an IChatClient in the Agent 365 / Microsoft 365 Agents hosting and tooling patterns.
Changes:
- Introduces a new Claude-based sample agent project (hosting, auth, MCP tooling, sessions, streaming UX).
- Adds OpenTelemetry setup plus custom agent metrics helpers/wrappers.
- Adds sample configuration, MCP ToolingManifest, and Teams app package artifacts.
Agent 365 Sample Validation Report (high-level)
- Documentation: README and code walkthrough are present.
- Configuration:
appsettings.jsonandappsettings.Playground.jsonare present with placeholders (no obvious committed secrets). - Project structure:
.csproj, solution file, ToolingManifest, and Teams app package files are present. - Issues found (require changes): telemetry wrappers do not correctly await async operations / mark failures; custom metrics likely not exported due to meter registration; attachment handling currently risks leaking tokenized file URLs to the LLM provider.
Reviewed changes
Copilot reviewed 17 out of 19 changed files in this pull request and generated 8 comments.
Show a summary per file
| File | Description |
|---|---|
| dotnet/claude/sample-agent/Tools/DateTimeFunctionTool.cs | Adds a local function tool for date/time. |
| dotnet/claude/sample-agent/ToolingManifest.json | Declares MCP server configuration (Mail tools). |
| dotnet/claude/sample-agent/telemetry/AgentOTELExtensions.cs | Adds OpenTelemetry configuration for the sample host. |
| dotnet/claude/sample-agent/telemetry/AgentMetrics.cs | Adds ActivitySource/Meter helpers and wrapper methods. |
| dotnet/claude/sample-agent/telemetry/A365OtelWrapper.cs | Adds A365 baggage/token-cache integration wrapper. |
| dotnet/claude/sample-agent/README.md | Documents the sample and key behaviors. |
| dotnet/claude/sample-agent/Program.cs | Configures DI, Anthropic IChatClient, routing, and endpoints. |
| dotnet/claude/sample-agent/m365agents.yml | Adds Teams toolkit metadata file. |
| dotnet/claude/sample-agent/m365agents.playground.yml | Adds Teams toolkit metadata for playground env usage. |
| dotnet/claude/sample-agent/ClaudeSampleAgent.csproj | New web project with A365 + Anthropic dependencies. |
| dotnet/claude/sample-agent/AspNetExtensions.cs | Adds JWT bearer token validation utilities for the host. |
| dotnet/claude/sample-agent/appsettings.Playground.json | Adds playground config (token validation disabled, placeholders). |
| dotnet/claude/sample-agent/appsettings.json | Adds default config (A365 options, connections, Anthropic settings). |
| dotnet/claude/sample-agent/appPackage/outline.png | Teams app icon asset. |
| dotnet/claude/sample-agent/appPackage/manifest.json | Teams app manifest for the sample agent. |
| dotnet/claude/sample-agent/appPackage/color.png | Teams app icon asset. |
| dotnet/claude/sample-agent/Agent/MyAgent.cs | Implements message handling, sessions, MCP tool loading, streaming UX. |
| dotnet/claude/sample-agent/Agent-Code-Walkthrough.md | Provides a detailed walkthrough of the sample’s code. |
| dotnet/claude/ClaudeSampleAgent.sln | Adds a solution file for the new sample. |
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
d000d8b to
de27a27
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds a new .NET sample agent under
dotnet/claude/sample-agentthat uses Anthropic Claude as the LLM provider via the Anthropic.SDK NuGet package.What this does
Anthropic.SDK 5.10.0as anIChatClientdrop-in replacement for Azure OpenAI, working seamlessly withChatClientAgentand theMicrosoft.Extensions.AIecosystem.dotnet/agent-framework/sample-agent— identical MCP tooling, agentic auth, observability, and hosting patterns.Key files
AnthropicClientasIChatClientwith function invocation + OpenTelemetryAgent/MyAgent.cstelemetry/Package notes
Microsoft.Agents.AIis pinned to1.0.0-rc4— the last version compiled againstMicrosoft.Extensions.AI.Abstractions 10.3.0, which is binary-compatible withAnthropic.SDK 5.10.0. Newer versions (rc5+) target Abstractions 10.4.0+ and break at runtime due to removedHostedMcpServerTool.AuthorizationToken.