.NET: Mark OpenTelemetryAgent autoWireChatClient ctor as [Experimental]

Annotate the new 3-arg OpenTelemetryAgent(AIAgent, string?, bool) constructor with [Experimental(DiagnosticIds.Experiments.AgentsAIExperiments)] (MAAI001) so callers must explicitly opt in to the auto-wire toggle. The original 2-arg constructor stays non-experimental and delegates with autoWireChatClient: true; the delegating call is locally suppressed so the existing source compatibility surface is preserved.
This commit is contained in:
Roger Barreto
2026-05-12 20:40:05 +01:00
Unverified
parent 9551f9ebd7
commit 3d4a8c4151
@@ -3,10 +3,12 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.Runtime.CompilerServices;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.Extensions.AI;
using Microsoft.Shared.DiagnosticIds;
namespace Microsoft.Agents.AI;
@@ -52,7 +54,9 @@ public sealed class OpenTelemetryAgent : DelegatingAIAgent, IDisposable
/// telemetry collection according to OpenTelemetry semantic conventions for AI systems.
/// </remarks>
public OpenTelemetryAgent(AIAgent innerAgent, string? sourceName = null)
#pragma warning disable MAAI001 // Delegating to the experimental autoWireChatClient overload with the default-on value preserves the original behavior.
: this(innerAgent, sourceName, autoWireChatClient: true)
#pragma warning restore MAAI001
{
}
@@ -73,6 +77,7 @@ public sealed class OpenTelemetryAgent : DelegatingAIAgent, IDisposable
/// The constructor automatically extracts provider metadata from the inner agent and configures
/// telemetry collection according to OpenTelemetry semantic conventions for AI systems.
/// </remarks>
[Experimental(DiagnosticIds.Experiments.AgentsAIExperiments)]
public OpenTelemetryAgent(AIAgent innerAgent, string? sourceName, bool autoWireChatClient) : base(innerAgent)
{
this._providerName = innerAgent.GetService<AIAgentMetadata>()?.ProviderName;