Upgrade Agent Framework sample to Agent365 GA (1.0.0) with observability instrumentation#297
Open
sellakumaran wants to merge 1 commit intomainfrom
Open
Upgrade Agent Framework sample to Agent365 GA (1.0.0) with observability instrumentation#297sellakumaran wants to merge 1 commit intomainfrom
sellakumaran wants to merge 1 commit intomainfrom
Conversation
Contributor
sellakumaran
commented
May 1, 2026
- Upgraded Microsoft.Agents.A365.*, Microsoft.OpenTelemetry to GA 1.0.0 releases
- Added end-to-end tracing with InvokeAgentScope (per turn) and ExecuteToolScope (per tool call)
- Refactored DateTimeFunctionTool to instance class with DI for observability support
- Migrated from AgentThread to AgentSession for conversation state management
- Expanded appsettings.json with Agent365Observability config section; clarified Blueprint vs Agent Identity placeholders
…ity instrumentation - Upgraded Microsoft.Agents.A365.*, Microsoft.OpenTelemetry, Azure.AI.OpenAI, and related packages to GA 1.0.0 releases - Added end-to-end tracing with InvokeAgentScope (per turn) and ExecuteToolScope (per tool call) - Refactored DateTimeFunctionTool to instance class with DI for observability support - Migrated from AgentThread to AgentSession for conversation state management - Expanded appsettings.json with Agent365Observability config section; clarified Blueprint vs Agent Identity placeholders
Dependency ReviewThe following issues were found:
License Issuesdotnet/agent-framework/sample-agent/AgentFrameworkSampleAgent.csproj
OpenSSF Scorecard
Scanned Files
|
Contributor
There was a problem hiding this comment.
Pull request overview
Upgrades the .NET Agent Framework sample agent to Agent365 GA (1.0.0) packages and adds end-to-end observability/tracing around agent turns and tool invocations, while updating conversation state management to use AgentSession.
Changes:
- Upgrade A365 + OpenTelemetry-related NuGet dependencies to 1.0.0 GA (and related compatible versions).
- Add tracing scopes (
InvokeAgentScope,ExecuteToolScope) for per-turn and per-tool instrumentation. - Migrate conversation state from
AgentThreadtoAgentSessionand adjust tool registration/DI usage.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 9 comments.
Show a summary per file
| File | Description |
|---|---|
| dotnet/agent-framework/sample-agent/appsettings.json | Updates placeholders and adds Agent365 observability configuration settings. |
| dotnet/agent-framework/sample-agent/Tools/WeatherLookupTool.cs | Adds per-tool execution tracing and response recording for weather tools. |
| dotnet/agent-framework/sample-agent/Tools/DateTimeFunctionTool.cs | Refactors datetime tool to an instance class and adds tracing scope + response recording. |
| dotnet/agent-framework/sample-agent/Program.cs | Updates OpenTelemetry wiring to capture custom AgentMetrics activity source. |
| dotnet/agent-framework/sample-agent/AgentFrameworkSampleAgent.csproj | Updates package references to GA/stable versions (and related dependencies). |
| dotnet/agent-framework/sample-agent/Agent/MyAgent.cs | Adds per-turn tracing, migrates to AgentSession, and updates chat options/history wiring. |
Comments suppressed due to low confidence (1)
dotnet/agent-framework/sample-agent/Agent/MyAgent.cs:432
EnableSensitiveData = truewill cause user inputs/outputs and tool data to be recorded into telemetry. This is risky for production and can contradict the goal of avoiding PII leaks. Make this opt-in (config/env gated) and default it to disabled outside local development.
.AsBuilder()
.UseOpenTelemetry(sourceName: AgentMetrics.SourceName, (cfg) => cfg.EnableSensitiveData = true)
.Build();
Comment on lines
+44
to
+47
| var toolCallDetails = new ToolCallDetails( | ||
| toolName: nameof(GetCurrentWeatherForLocation), | ||
| arguments: $"{{\"location\":\"{location}\",\"state\":\"{state}\"}}", | ||
| toolCallId: Guid.NewGuid().ToString(), |
Comment on lines
+33
to
+35
| // Register custom activity source so spans from AgentMetrics are captured by the TracerProvider | ||
| builder.Services.AddOpenTelemetry() | ||
| .WithTracing(tracing => tracing.AddSource(AgentMetrics.SourceName)); |
Comment on lines
+284
to
+295
| var collectedOutput = new System.Text.StringBuilder(); | ||
| // Stream the response back to the user as we receive it from the agent. | ||
| await foreach (var response in _agent!.RunStreamingAsync(userText, thread, cancellationToken: cancellationToken)) | ||
| { | ||
| if (response.Role == ChatRole.Assistant && !string.IsNullOrEmpty(response.Text)) | ||
| { | ||
| turnContext?.StreamingResponse.QueueTextChunk(response.Text); | ||
| collectedOutput.Append(response.Text); | ||
| } | ||
| } | ||
| turnState.Conversation.SetValue("conversation.threadInfo", ProtocolJsonSerializer.ToJson(thread.Serialize())); | ||
| invokeScope.RecordOutputMessages(new[] { collectedOutput.ToString() }); | ||
| var serializedSession = await _agent!.SerializeSessionAsync(thread!); |
Comment on lines
+270
to
272
| // Read or Create the conversation session for this conversation. | ||
| AgentSession? thread = await GetConversationSessionAsync(_agent, turnState, cancellationToken); | ||
|
|
Comment on lines
+33
to
+39
| private AgentDetails BuildAgentDetails() => | ||
| new AgentDetails( | ||
| agentId: configuration["Agent365Observability:AgentId"] ?? "local-dev", | ||
| agentName: configuration["Agent365Observability:AgentName"] ?? "my-agent", | ||
| agentDescription: configuration["Agent365Observability:AgentDescription"] ?? "", | ||
| agentBlueprintId: configuration["Agent365Observability:AgentBlueprintId"] ?? "", | ||
| tenantId: configuration["Agent365Observability:TenantId"] ?? "local-dev"); |
| { | ||
| var toolCallDetails = new ToolCallDetails( | ||
| toolName: nameof(GetWeatherForecastForLocation), | ||
| arguments: $"{{\"location\":\"{location}\",\"state\":\"{state}\"}}", |
Comment on lines
+260
to
+262
| using var invokeScope = InvokeAgentScope.Start( | ||
| request: new Request(userText), | ||
| scopeDetails: new InvokeAgentScopeDetails(endpoint: new Uri("http://localhost:3978")), |
| }, | ||
| "OpenWeatherApiKey": "----" //https://openweathermap.org/price - You will need to create a free account to get an API key (its at the bottom of the page). | ||
| } | ||
| "OpenWeatherApiKey": "----", //https://openweathermap.org/price - You will need to create a free account to get an API key (its at the bottom of the page). |
| "OpenWeatherApiKey": "----" //https://openweathermap.org/price - You will need to create a free account to get an API key (its at the bottom of the page). | ||
| } | ||
| "OpenWeatherApiKey": "----", //https://openweathermap.org/price - You will need to create a free account to get an API key (its at the bottom of the page). | ||
| "EnableAgent365Exporter": true, |
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.