.NET: Add feature-usage bitmask - #7709
Conversation
There was a problem hiding this comment.
Pull request overview
Adds process-wide .NET feature-usage telemetry and emits its 128-bit mask through approved Foundry and Azure OpenAI User-Agent pipelines.
Changes:
- Adds feature registry indexes and activation markers across .NET capabilities.
- Adds origin-scoped User-Agent emission with opt-out support.
- Adds registry, activation, concurrency, and emission tests.
Reviewed changes
Copilot reviewed 143 out of 143 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
dotnet/src/Shared/FeatureUsage/UserAgentPolicyRegistration.cs |
Adds shared User-Agent policies and origin checks. |
dotnet/src/Microsoft.Agents.AI.Abstractions/FeatureUsage.cs |
Implements the process-wide feature mask. |
dotnet/src/Microsoft.Agents.AI.Abstractions/FeatureIndex.cs |
Registers the in-memory history bit. |
dotnet/src/Microsoft.Agents.AI.Abstractions/InMemoryChatHistoryProvider.cs |
Marks in-memory history usage. |
dotnet/src/Microsoft.Agents.AI/FeatureIndex.cs |
Registers core feature indexes. |
dotnet/src/Microsoft.Agents.AI/ChatClient/ChatClientAgent.cs |
Marks core agent execution. |
dotnet/src/Microsoft.Agents.AI/Compaction/CompactionProvider.cs |
Marks compaction usage. |
dotnet/src/Microsoft.Agents.AI/TextSearchProvider.cs |
Marks text-search usage. |
dotnet/src/Microsoft.Agents.AI/Memory/ChatHistoryMemoryProvider.cs |
Marks memory-provider usage. |
dotnet/src/Microsoft.Agents.AI/Skills/AgentSkillsProvider.cs |
Marks skills-provider participation. |
dotnet/src/Microsoft.Agents.AI/Skills/AgentInMemorySkillsSource.cs |
Marks in-memory skill loading. |
dotnet/src/Microsoft.Agents.AI/Skills/File/AgentFileSkillsSource.cs |
Marks file skill discovery. |
dotnet/src/Microsoft.Agents.AI/Skills/Programmatic/AgentInlineSkill.cs |
Marks inline skill access. |
dotnet/src/Microsoft.Agents.AI/Skills/Programmatic/AgentClassSkill.cs |
Marks class skill access. |
dotnet/src/Microsoft.Agents.AI/Harness/ToolApproval/ToolApprovalAgent.cs |
Marks tool-approval execution. |
dotnet/src/Microsoft.Agents.AI/Harness/Todo/TodoProvider.cs |
Marks todo-provider usage. |
dotnet/src/Microsoft.Agents.AI/Harness/FileMemory/FileMemoryProvider.cs |
Marks file-memory usage. |
dotnet/src/Microsoft.Agents.AI/Harness/FileAccess/FileAccessProvider.cs |
Marks file-access usage. |
dotnet/src/Microsoft.Agents.AI/Harness/BackgroundAgents/BackgroundAgentsProvider.cs |
Marks background-agent usage. |
dotnet/src/Microsoft.Agents.AI/Harness/AgentMode/AgentModeProvider.cs |
Marks agent-mode usage. |
dotnet/src/Microsoft.Agents.AI.Workflows/FeatureIndex.cs |
Registers workflow indexes. |
dotnet/src/Microsoft.Agents.AI.Workflows/WorkflowBuilder.cs |
Marks successful workflow builds. |
dotnet/src/Microsoft.Agents.AI.Workflows/SequentialWorkflowBuilder.cs |
Marks sequential workflows. |
dotnet/src/Microsoft.Agents.AI.Workflows/ConcurrentWorkflowBuilder.cs |
Marks concurrent workflows. |
dotnet/src/Microsoft.Agents.AI.Workflows/GroupChatWorkflowBuilder.cs |
Marks group-chat workflows. |
dotnet/src/Microsoft.Agents.AI.Workflows/MagenticWorkflowBuilder.cs |
Marks Magentic workflows. |
dotnet/src/Microsoft.Agents.AI.Workflows/HandoffWorkflowBuilder.cs |
Marks handoff workflows. |
dotnet/src/Microsoft.Agents.AI.Workflows.Declarative/FeatureIndex.cs |
Registers declarative workflow usage. |
dotnet/src/Microsoft.Agents.AI.Workflows.Declarative/DeclarativeWorkflowBuilder.cs |
Marks successful declarative builds. |
dotnet/src/Microsoft.Agents.AI.Foundry/FeatureIndex.cs |
Registers Foundry feature indexes. |
dotnet/src/Microsoft.Agents.AI.Foundry/FoundryFeatureUsage.cs |
Centralizes Foundry marking. |
dotnet/src/Microsoft.Agents.AI.Foundry/FoundryChatClient.cs |
Marks Foundry requests and toolbox use. |
dotnet/src/Microsoft.Agents.AI.Foundry/ClientHeadersAgent.cs |
Marks Foundry agent execution. |
dotnet/src/Microsoft.Agents.AI.Foundry/Memory/FoundryMemoryProvider.cs |
Marks Foundry memory operations. |
dotnet/src/Microsoft.Agents.AI.Foundry/Evaluation/FoundryEvals.cs |
Marks Foundry evaluations. |
dotnet/src/Microsoft.Agents.AI.Foundry/AgentFrameworkUserAgentPolicy.cs |
Configures approved Foundry origins. |
dotnet/src/Microsoft.Agents.AI.Foundry/Microsoft.Agents.AI.Foundry.csproj |
Injects shared User-Agent code. |
dotnet/src/Microsoft.Agents.AI.Foundry.Hosting/FeatureIndex.cs |
Registers Foundry hosting usage. |
dotnet/src/Microsoft.Agents.AI.Foundry.Hosting/ServiceCollectionExtensions.cs |
Marks Foundry hosting setup. |
dotnet/src/Microsoft.Agents.AI.OpenAI/FeatureIndex.cs |
Registers and wraps OpenAI usage. |
dotnet/src/Microsoft.Agents.AI.OpenAI/UserAgentPolicies.cs |
Configures Azure OpenAI origins. |
dotnet/src/Microsoft.Agents.AI.OpenAI/Microsoft.Agents.AI.OpenAI.csproj |
Injects shared User-Agent code. |
dotnet/src/Microsoft.Agents.AI.OpenAI/Extensions/OpenAIChatClientExtensions.cs |
Registers chat policies and markers. |
dotnet/src/Microsoft.Agents.AI.OpenAI/Extensions/OpenAIResponseClientExtensions.cs |
Registers Responses policies and markers. |
dotnet/src/Microsoft.Agents.AI.OpenAI/Extensions/AIAgentWithOpenAIExtensions.cs |
Marks OpenAI interoperability calls. |
dotnet/src/Microsoft.Agents.AI.OpenAI/ChatClient/AsyncStreamingResponseUpdateCollectionResult.cs |
Marks streamed Responses usage. |
dotnet/src/Microsoft.Agents.AI.OpenAI/ChatClient/AsyncStreamingChatCompletionUpdateCollectionResult.cs |
Marks streamed chat usage. |
dotnet/src/Microsoft.Agents.AI.Anthropic/FeatureIndex.cs |
Registers and wraps Anthropic usage. |
dotnet/src/Microsoft.Agents.AI.Anthropic/AnthropicClientExtensions.cs |
Applies Anthropic usage wrappers. |
dotnet/src/Microsoft.Agents.AI.Anthropic/AnthropicBetaServiceExtensions.cs |
Applies beta Anthropic wrappers. |
dotnet/src/Microsoft.Agents.AI.CopilotStudio/FeatureIndex.cs |
Registers Copilot Studio usage. |
dotnet/src/Microsoft.Agents.AI.CopilotStudio/CopilotStudioAgent.cs |
Marks execution and changes session API. |
dotnet/src/Microsoft.Agents.AI.GitHub.Copilot/FeatureIndex.cs |
Registers GitHub Copilot usage. |
dotnet/src/Microsoft.Agents.AI.GitHub.Copilot/GitHubCopilotAgent.cs |
Marks execution and simplifies properties. |
dotnet/src/Microsoft.Agents.AI.A2A/FeatureIndex.cs |
Registers A2A usage. |
dotnet/src/Microsoft.Agents.AI.A2A/A2AAgent.cs |
Marks execution and changes session APIs. |
dotnet/src/Microsoft.Agents.AI.CosmosNoSql/FeatureIndex.cs |
Registers Cosmos usage. |
dotnet/src/Microsoft.Agents.AI.CosmosNoSql/CosmosCheckpointStore.cs |
Marks checkpoint operations. |
dotnet/src/Microsoft.Agents.AI.CosmosNoSql/CosmosChatHistoryProvider.cs |
Marks Cosmos history operations. |
dotnet/src/Microsoft.Agents.AI.Valkey/FeatureIndex.cs |
Registers Valkey usage. |
dotnet/src/Microsoft.Agents.AI.Valkey/ValkeyChatHistoryProvider.cs |
Marks Valkey operations. |
dotnet/src/Microsoft.Agents.AI.Mem0/FeatureIndex.cs |
Registers Mem0 usage. |
dotnet/src/Microsoft.Agents.AI.Mem0/Mem0Client.cs |
Marks Mem0 HTTP operations. |
dotnet/src/Microsoft.Agents.AI.Purview/FeatureIndex.cs |
Registers Purview usage. |
dotnet/src/Microsoft.Agents.AI.Purview/PurviewWrapper.cs |
Marks Purview processing. |
dotnet/src/Microsoft.Agents.AI.Mcp/FeatureIndex.cs |
Registers MCP feature indexes. |
dotnet/src/Microsoft.Agents.AI.Mcp/McpClientTaskExtensions.cs |
Marks MCP tool listing. |
dotnet/src/Microsoft.Agents.AI.Mcp/Skills/AgentMcpSkillsSource.cs |
Marks MCP skill loading. |
dotnet/src/Microsoft.Agents.AI.Declarative/FeatureIndex.cs |
Registers declarative agent usage. |
dotnet/src/Microsoft.Agents.AI.Declarative/PromptAgentFactory.cs |
Marks successful agent creation. |
dotnet/src/Microsoft.Agents.AI.Declarative/AggregatorPromptAgentFactory.cs |
Marks aggregated factory creation. |
dotnet/src/Microsoft.Agents.AI.Declarative/ChatClient/ChatClientPromptAgentFactory.cs |
Marks chat-based declarative agents. |
dotnet/src/Microsoft.Agents.AI.DevUI/FeatureIndex.cs |
Registers DevUI usage. |
dotnet/src/Microsoft.Agents.AI.DevUI/DevUIExtensions.cs |
Marks DevUI endpoint mapping. |
dotnet/src/Microsoft.Agents.AI.Tools.Shell/FeatureIndex.cs |
Registers shell-tool usage. |
dotnet/src/Microsoft.Agents.AI.Tools.Shell/LocalShellExecutor.cs |
Marks local shell execution. |
dotnet/src/Microsoft.Agents.AI.Tools.Shell/DockerShellExecutor.cs |
Marks Docker shell execution. |
dotnet/src/Microsoft.Agents.AI.Hyperlight/FeatureIndex.cs |
Registers Hyperlight usage. |
dotnet/src/Microsoft.Agents.AI.Hyperlight/HyperlightCodeActProvider.cs |
Marks Hyperlight participation. |
dotnet/src/Microsoft.Agents.AI.LocalCodeAct/FeatureIndex.cs |
Registers local CodeAct usage. |
dotnet/src/Microsoft.Agents.AI.LocalCodeAct/LocalCodeActProvider.cs |
Marks local CodeAct participation. |
dotnet/src/Microsoft.Agents.AI.Harness/FeatureIndex.cs |
Registers harness-agent usage. |
dotnet/src/Microsoft.Agents.AI.Harness/HarnessAgent.cs |
Marks harness execution. |
dotnet/src/Microsoft.Agents.AI.Hosting/FeatureIndex.cs |
Registers hosting-agent usage. |
dotnet/src/Microsoft.Agents.AI.Hosting/AIHostAgent.cs |
Marks hosted-agent operations. |
dotnet/src/Microsoft.Agents.AI.Hosting.OpenAI/FeatureIndex.cs |
Registers OpenAI hosting usage. |
dotnet/src/Microsoft.Agents.AI.Hosting.OpenAI/EndpointRouteBuilderExtensions.Responses.cs |
Marks Responses endpoint mapping. |
dotnet/src/Microsoft.Agents.AI.Hosting.OpenAI/EndpointRouteBuilderExtensions.Conversations.cs |
Marks Conversations endpoint mapping. |
dotnet/src/Microsoft.Agents.AI.Hosting.OpenAI/EndpointRouteBuilderExtensions.ChatCompletions.cs |
Marks chat endpoint mapping. |
dotnet/src/Microsoft.Agents.AI.Hosting.AGUI.AspNetCore/FeatureIndex.cs |
Registers AG-UI hosting usage. |
dotnet/src/Microsoft.Agents.AI.Hosting.AGUI.AspNetCore/AGUIEndpointRouteBuilderExtensions.cs |
Marks AG-UI endpoint mapping. |
dotnet/src/Microsoft.Agents.AI.Hosting.A2A.AspNetCore/FeatureIndex.cs |
Registers A2A hosting usage. |
dotnet/src/Microsoft.Agents.AI.Hosting.A2A.AspNetCore/A2AEndpointRouteBuilderExtensions.cs |
Marks A2A endpoint mapping. |
dotnet/tests/FeatureUsageAssert.cs |
Adds shared mask assertions. |
dotnet/tests/Directory.Build.props |
Links shared assertions into tests. |
dotnet/tests/Microsoft.Agents.AI.Abstractions.UnitTests/FeatureUsageTests.cs |
Tests mask semantics and formatting. |
dotnet/tests/Microsoft.Agents.AI.UnitTests/FeatureUsageActivationTests.cs |
Tests core feature activation. |
dotnet/tests/Microsoft.Agents.AI.Workflows.UnitTests/WorkflowBuilderTests.cs |
Tests workflow activation. |
dotnet/tests/Microsoft.Agents.AI.Workflows.Declarative.UnitTests/DeclarativeWorkflowOptionsTest.cs |
Tests declarative workflow activation. |
dotnet/tests/Microsoft.Agents.AI.Foundry.UnitTests/PolicyPipelineInvestigationTests.cs |
Probes policy ordering and isolation. |
dotnet/tests/Microsoft.Agents.AI.Foundry.UnitTests/FoundryFeatureUsageActivationTests.cs |
Tests Foundry activation and emission. |
dotnet/tests/Microsoft.Agents.AI.Foundry.UnitTests/FeatureUsageUserAgentPolicyTests.cs |
Tests policy refresh and origin handling. |
dotnet/tests/Microsoft.Agents.AI.Foundry.UnitTests/AgentFrameworkUserAgentPolicyTests.cs |
Updates base User-Agent tests. |
dotnet/tests/Microsoft.Agents.AI.Foundry.UnitTests/FoundryChatClientTests.cs |
Tests policy registration. |
dotnet/tests/Microsoft.Agents.AI.Foundry.UnitTests/FoundryAgentTests.cs |
Tests agent policy registration. |
dotnet/tests/Microsoft.Agents.AI.Foundry.UnitTests/Microsoft.Agents.AI.Foundry.UnitTests.csproj |
Adds Azure OpenAI test dependency. |
dotnet/tests/Microsoft.Agents.AI.Foundry.Hosting.UnitTests/ServiceCollectionExtensionsTests.cs |
Tests Foundry hosting activation. |
dotnet/tests/Microsoft.Agents.AI.OpenAI.UnitTests/UserAgentPolicyTests.cs |
Tests Azure OpenAI emission. |
dotnet/tests/Microsoft.Agents.AI.OpenAI.UnitTests/FeatureUsageActivationTests.cs |
Tests OpenAI activation. |
dotnet/tests/Microsoft.Agents.AI.OpenAI.UnitTests/Microsoft.Agents.AI.OpenAI.UnitTests.csproj |
Adds Azure OpenAI test dependency. |
dotnet/tests/Microsoft.Agents.AI.Anthropic.UnitTests/FeatureUsageActivationTests.cs |
Tests Anthropic activation. |
dotnet/tests/Microsoft.Agents.AI.GitHub.Copilot.UnitTests/FeatureUsageActivationTests.cs |
Tests GitHub Copilot activation. |
dotnet/tests/Microsoft.Agents.AI.GitHub.Copilot.UnitTests/GitHubCopilotAgentTests.cs |
Updates session and collection tests. |
dotnet/tests/Microsoft.Agents.AI.UnitTests/CopilotStudio/FeatureUsageActivationTests.cs |
Tests Copilot Studio activation. |
dotnet/tests/Microsoft.Agents.AI.A2A.UnitTests/FeatureUsageActivationTests.cs |
Tests A2A activation. |
dotnet/tests/Microsoft.Agents.AI.A2A.UnitTests/A2AAgentTests.cs |
Updates A2A session tests. |
dotnet/tests/Microsoft.Agents.AI.CosmosNoSql.UnitTests/CosmosCheckpointStoreTests.cs |
Tests Cosmos activation. |
dotnet/tests/Microsoft.Agents.AI.Valkey.UnitTests/FeatureUsageActivationTests.cs |
Tests Valkey activation. |
dotnet/tests/Microsoft.Agents.AI.Valkey.UnitTests/ValkeyChatHistoryProviderTests.cs |
Applies minor test cleanup. |
dotnet/tests/Microsoft.Agents.AI.Mem0.UnitTests/FeatureUsageActivationTests.cs |
Tests Mem0 activation. |
dotnet/tests/Microsoft.Agents.AI.Mem0.UnitTests/Mem0ProviderTests.cs |
Applies minor test cleanup. |
dotnet/tests/Microsoft.Agents.AI.Purview.UnitTests/FeatureUsageActivationTests.cs |
Tests Purview activation. |
dotnet/tests/Microsoft.Agents.AI.Purview.UnitTests/PurviewWrapperTests.cs |
Applies minor test cleanup. |
dotnet/tests/Microsoft.Agents.AI.Mcp.UnitTests/FeatureUsageActivationTests.cs |
Tests MCP activation. |
dotnet/tests/Microsoft.Agents.AI.Declarative.UnitTests/FeatureUsageActivationTests.cs |
Tests declarative agent activation. |
dotnet/tests/Microsoft.Agents.AI.DevUI.UnitTests/FeatureUsageActivationTests.cs |
Tests DevUI activation. |
dotnet/tests/Microsoft.Agents.AI.DevUI.UnitTests/DevUIAccessControlTests.cs |
Simplifies middleware test typing. |
dotnet/tests/Microsoft.Agents.AI.Tools.Shell.UnitTests/FeatureUsageActivationTests.cs |
Tests shell activation. |
dotnet/tests/Microsoft.Agents.AI.Hyperlight.UnitTests/FeatureUsageActivationTests.cs |
Tests Hyperlight activation. |
dotnet/tests/Microsoft.Agents.AI.Hyperlight.UnitTests/ProvideAIContextTests.cs |
Updates assignability assertions. |
dotnet/tests/Microsoft.Agents.AI.LocalCodeAct.UnitTests/FeatureUsageActivationTests.cs |
Tests local CodeAct activation. |
dotnet/tests/Microsoft.Agents.AI.LocalCodeAct.UnitTests/LocalCodeActProviderTests.cs |
Updates assignability assertion. |
dotnet/tests/Microsoft.Agents.AI.Harness.UnitTests/FeatureUsageActivationTests.cs |
Tests harness activation. |
dotnet/tests/Microsoft.Agents.AI.Hosting.UnitTests/AgentHostingServiceCollectionExtensionsTests.cs |
Tests hosted-agent activation. |
dotnet/tests/Microsoft.Agents.AI.Hosting.OpenAI.UnitTests/EndpointRouteBuilderExtensionsTests.cs |
Tests OpenAI hosting activation. |
dotnet/tests/Microsoft.Agents.AI.Hosting.AGUI.AspNetCore.UnitTests/AGUIEndpointRouteBuilderExtensionsTests.cs |
Tests AG-UI activation. |
dotnet/tests/Microsoft.Agents.AI.Hosting.A2A.UnitTests/A2AEndpointRouteBuilderExtensionsTests.cs |
Tests A2A hosting activation. |
dotnet/tests/Microsoft.Agents.AI.FeatureRegistry.UnitTests/FeatureRegistryTests.cs |
Validates registry declarations and activations. |
dotnet/tests/Microsoft.Agents.AI.FeatureRegistry.UnitTests/README.md |
Documents registry validation. |
dotnet/tests/Microsoft.Agents.AI.FeatureRegistry.UnitTests/Microsoft.Agents.AI.FeatureRegistry.UnitTests.csproj |
Adds the registry test project. |
dotnet/eng/MSBuild/Shared.props |
Adds shared policy source injection. |
dotnet/agent-framework-dotnet.slnx |
Adds the registry test project. |
dotnet/README.md |
Documents feature telemetry and opt-out. |
Suppressed comments (1)
dotnet/src/Microsoft.Agents.AI.A2A/A2AAgent.cs:91
- This second existing public overload is also changed from instance to static, breaking callers of
agent.CreateSessionAsync(contextId, taskId)at both source and binary compatibility levels. Preserve the instance overload (or introduce a differently named static factory) and update the tests to use the compatible API.
public static ValueTask<AgentSession> CreateSessionAsync(string contextId, string taskId)
💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.
There was a problem hiding this comment.
MAF Automated Review — Iteration 1
Result: Findings reported
Scope: full PR (2 commit(s)): d3b4ded3467c, 38226131e986
Model: gpt-5.6-sol
Overview
The PR implements a process-wide, monotonic feature mask with atomic updates, registry validation, request-time token refresh, an opt-out, and strict direct-request origin checks backed by focused tests. However, automatic redirects can bypass the per-request origin decision and disclose the mask to an unapproved destination. The PR also changes three existing public session-resume methods from instance to static, breaking source and binary compatibility.
Reviewed the supplied pull-request change set across correctness, security/reliability, architecture, and failure behavior.
3 verified findings remained after source verification (2 high, 1 medium) across 3 files. Details are attached to the affected lines below.
Affected areas: dotnet/src/Microsoft.Agents.AI.A2A/A2AAgent.cs, dotnet/src/Microsoft.Agents.AI.CopilotStudio/CopilotStudioAgent.cs, dotnet/src/Shared/FeatureUsage/UserAgentPolicyRegistration.cs
Motivation & Context
Agent Framework currently identifies .NET SDK traffic but does not report which framework capabilities are actually exercised together. This implements ADR-0033’s transparent, privacy-scoped feature-usage signal for .NET.
Description & Review Guide
• Adds a process-wide, monotonic 128-bit feature mask with package-local feature indexes.
• Marks features at their first meaningful activation.
• Emits (feat=v1.) at request time through approved Foundry and Azure OpenAI wrappers.
• Restricts emission to reviewed HTTPS origins and removes stale tokens from ineligible requests.
• Adds registry validation, activation/emission tests, and the
AGENT_FRAMEWORK_FEATURE_MASK_DISABLEDopt-out.Fixes #7422
Contribution Checklist
breaking changelabel (or add "[BREAKING]" to the title prefix, before or after any language prefix) — a workflow keeps the label and title prefix in sync automatically.