Skip to content

.NET: Add feature-usage bitmask - #7709

Merged
Evan Mattson (moonbox3) merged 9 commits into
microsoft:mainfrom
peibekwe:bitmask-feature
Aug 21, 2026
Merged

.NET: Add feature-usage bitmask#7709
Evan Mattson (moonbox3) merged 9 commits into
microsoft:mainfrom
peibekwe:bitmask-feature

Conversation

@peibekwe

Copy link
Copy Markdown
Contributor

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_DISABLED opt-out.

Fixes#7422

Contribution Checklist

  • The code builds clean without any errors or warnings
  • All unit tests pass, and I have added new tests where possible
  • The PR follows the Contribution Guidelines
  • This PR is linked to an issue and there is no other open PR for this issue (see Related Issue above).
  • This is not a breaking change. If it is a breaking change, add the breaking change label (or add "[BREAKING]" to the title prefix, before or after any language prefix) — a workflow keeps the label and title prefix in sync automatically.

CopilotAI balanced review requested due to automatic review settings August 18, 2026 06:01
@agent-framework-automationagent-framework-automationBot added documentation Usage: [Issues, PRs], Target: documentation in the code base and learn docs .NET Usage: [Issues, PRs], Target: .Net workflows Usage: [Issues, PRs], Target: Workflows labels Aug 18, 2026
@github-actionsgithub-actionsBot changed the title Add feature-usage User-Agent telemetry.NET: Add feature-usage User-Agent telemetryAug 18, 2026

CopilotAI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
FileDescription
dotnet/src/Shared/FeatureUsage/UserAgentPolicyRegistration.csAdds shared User-Agent policies and origin checks.
dotnet/src/Microsoft.Agents.AI.Abstractions/FeatureUsage.csImplements the process-wide feature mask.
dotnet/src/Microsoft.Agents.AI.Abstractions/FeatureIndex.csRegisters the in-memory history bit.
dotnet/src/Microsoft.Agents.AI.Abstractions/InMemoryChatHistoryProvider.csMarks in-memory history usage.
dotnet/src/Microsoft.Agents.AI/FeatureIndex.csRegisters core feature indexes.
dotnet/src/Microsoft.Agents.AI/ChatClient/ChatClientAgent.csMarks core agent execution.
dotnet/src/Microsoft.Agents.AI/Compaction/CompactionProvider.csMarks compaction usage.
dotnet/src/Microsoft.Agents.AI/TextSearchProvider.csMarks text-search usage.
dotnet/src/Microsoft.Agents.AI/Memory/ChatHistoryMemoryProvider.csMarks memory-provider usage.
dotnet/src/Microsoft.Agents.AI/Skills/AgentSkillsProvider.csMarks skills-provider participation.
dotnet/src/Microsoft.Agents.AI/Skills/AgentInMemorySkillsSource.csMarks in-memory skill loading.
dotnet/src/Microsoft.Agents.AI/Skills/File/AgentFileSkillsSource.csMarks file skill discovery.
dotnet/src/Microsoft.Agents.AI/Skills/Programmatic/AgentInlineSkill.csMarks inline skill access.
dotnet/src/Microsoft.Agents.AI/Skills/Programmatic/AgentClassSkill.csMarks class skill access.
dotnet/src/Microsoft.Agents.AI/Harness/ToolApproval/ToolApprovalAgent.csMarks tool-approval execution.
dotnet/src/Microsoft.Agents.AI/Harness/Todo/TodoProvider.csMarks todo-provider usage.
dotnet/src/Microsoft.Agents.AI/Harness/FileMemory/FileMemoryProvider.csMarks file-memory usage.
dotnet/src/Microsoft.Agents.AI/Harness/FileAccess/FileAccessProvider.csMarks file-access usage.
dotnet/src/Microsoft.Agents.AI/Harness/BackgroundAgents/BackgroundAgentsProvider.csMarks background-agent usage.
dotnet/src/Microsoft.Agents.AI/Harness/AgentMode/AgentModeProvider.csMarks agent-mode usage.
dotnet/src/Microsoft.Agents.AI.Workflows/FeatureIndex.csRegisters workflow indexes.
dotnet/src/Microsoft.Agents.AI.Workflows/WorkflowBuilder.csMarks successful workflow builds.
dotnet/src/Microsoft.Agents.AI.Workflows/SequentialWorkflowBuilder.csMarks sequential workflows.
dotnet/src/Microsoft.Agents.AI.Workflows/ConcurrentWorkflowBuilder.csMarks concurrent workflows.
dotnet/src/Microsoft.Agents.AI.Workflows/GroupChatWorkflowBuilder.csMarks group-chat workflows.
dotnet/src/Microsoft.Agents.AI.Workflows/MagenticWorkflowBuilder.csMarks Magentic workflows.
dotnet/src/Microsoft.Agents.AI.Workflows/HandoffWorkflowBuilder.csMarks handoff workflows.
dotnet/src/Microsoft.Agents.AI.Workflows.Declarative/FeatureIndex.csRegisters declarative workflow usage.
dotnet/src/Microsoft.Agents.AI.Workflows.Declarative/DeclarativeWorkflowBuilder.csMarks successful declarative builds.
dotnet/src/Microsoft.Agents.AI.Foundry/FeatureIndex.csRegisters Foundry feature indexes.
dotnet/src/Microsoft.Agents.AI.Foundry/FoundryFeatureUsage.csCentralizes Foundry marking.
dotnet/src/Microsoft.Agents.AI.Foundry/FoundryChatClient.csMarks Foundry requests and toolbox use.
dotnet/src/Microsoft.Agents.AI.Foundry/ClientHeadersAgent.csMarks Foundry agent execution.
dotnet/src/Microsoft.Agents.AI.Foundry/Memory/FoundryMemoryProvider.csMarks Foundry memory operations.
dotnet/src/Microsoft.Agents.AI.Foundry/Evaluation/FoundryEvals.csMarks Foundry evaluations.
dotnet/src/Microsoft.Agents.AI.Foundry/AgentFrameworkUserAgentPolicy.csConfigures approved Foundry origins.
dotnet/src/Microsoft.Agents.AI.Foundry/Microsoft.Agents.AI.Foundry.csprojInjects shared User-Agent code.
dotnet/src/Microsoft.Agents.AI.Foundry.Hosting/FeatureIndex.csRegisters Foundry hosting usage.
dotnet/src/Microsoft.Agents.AI.Foundry.Hosting/ServiceCollectionExtensions.csMarks Foundry hosting setup.
dotnet/src/Microsoft.Agents.AI.OpenAI/FeatureIndex.csRegisters and wraps OpenAI usage.
dotnet/src/Microsoft.Agents.AI.OpenAI/UserAgentPolicies.csConfigures Azure OpenAI origins.
dotnet/src/Microsoft.Agents.AI.OpenAI/Microsoft.Agents.AI.OpenAI.csprojInjects shared User-Agent code.
dotnet/src/Microsoft.Agents.AI.OpenAI/Extensions/OpenAIChatClientExtensions.csRegisters chat policies and markers.
dotnet/src/Microsoft.Agents.AI.OpenAI/Extensions/OpenAIResponseClientExtensions.csRegisters Responses policies and markers.
dotnet/src/Microsoft.Agents.AI.OpenAI/Extensions/AIAgentWithOpenAIExtensions.csMarks OpenAI interoperability calls.
dotnet/src/Microsoft.Agents.AI.OpenAI/ChatClient/AsyncStreamingResponseUpdateCollectionResult.csMarks streamed Responses usage.
dotnet/src/Microsoft.Agents.AI.OpenAI/ChatClient/AsyncStreamingChatCompletionUpdateCollectionResult.csMarks streamed chat usage.
dotnet/src/Microsoft.Agents.AI.Anthropic/FeatureIndex.csRegisters and wraps Anthropic usage.
dotnet/src/Microsoft.Agents.AI.Anthropic/AnthropicClientExtensions.csApplies Anthropic usage wrappers.
dotnet/src/Microsoft.Agents.AI.Anthropic/AnthropicBetaServiceExtensions.csApplies beta Anthropic wrappers.
dotnet/src/Microsoft.Agents.AI.CopilotStudio/FeatureIndex.csRegisters Copilot Studio usage.
dotnet/src/Microsoft.Agents.AI.CopilotStudio/CopilotStudioAgent.csMarks execution and changes session API.
dotnet/src/Microsoft.Agents.AI.GitHub.Copilot/FeatureIndex.csRegisters GitHub Copilot usage.
dotnet/src/Microsoft.Agents.AI.GitHub.Copilot/GitHubCopilotAgent.csMarks execution and simplifies properties.
dotnet/src/Microsoft.Agents.AI.A2A/FeatureIndex.csRegisters A2A usage.
dotnet/src/Microsoft.Agents.AI.A2A/A2AAgent.csMarks execution and changes session APIs.
dotnet/src/Microsoft.Agents.AI.CosmosNoSql/FeatureIndex.csRegisters Cosmos usage.
dotnet/src/Microsoft.Agents.AI.CosmosNoSql/CosmosCheckpointStore.csMarks checkpoint operations.
dotnet/src/Microsoft.Agents.AI.CosmosNoSql/CosmosChatHistoryProvider.csMarks Cosmos history operations.
dotnet/src/Microsoft.Agents.AI.Valkey/FeatureIndex.csRegisters Valkey usage.
dotnet/src/Microsoft.Agents.AI.Valkey/ValkeyChatHistoryProvider.csMarks Valkey operations.
dotnet/src/Microsoft.Agents.AI.Mem0/FeatureIndex.csRegisters Mem0 usage.
dotnet/src/Microsoft.Agents.AI.Mem0/Mem0Client.csMarks Mem0 HTTP operations.
dotnet/src/Microsoft.Agents.AI.Purview/FeatureIndex.csRegisters Purview usage.
dotnet/src/Microsoft.Agents.AI.Purview/PurviewWrapper.csMarks Purview processing.
dotnet/src/Microsoft.Agents.AI.Mcp/FeatureIndex.csRegisters MCP feature indexes.
dotnet/src/Microsoft.Agents.AI.Mcp/McpClientTaskExtensions.csMarks MCP tool listing.
dotnet/src/Microsoft.Agents.AI.Mcp/Skills/AgentMcpSkillsSource.csMarks MCP skill loading.
dotnet/src/Microsoft.Agents.AI.Declarative/FeatureIndex.csRegisters declarative agent usage.
dotnet/src/Microsoft.Agents.AI.Declarative/PromptAgentFactory.csMarks successful agent creation.
dotnet/src/Microsoft.Agents.AI.Declarative/AggregatorPromptAgentFactory.csMarks aggregated factory creation.
dotnet/src/Microsoft.Agents.AI.Declarative/ChatClient/ChatClientPromptAgentFactory.csMarks chat-based declarative agents.
dotnet/src/Microsoft.Agents.AI.DevUI/FeatureIndex.csRegisters DevUI usage.
dotnet/src/Microsoft.Agents.AI.DevUI/DevUIExtensions.csMarks DevUI endpoint mapping.
dotnet/src/Microsoft.Agents.AI.Tools.Shell/FeatureIndex.csRegisters shell-tool usage.
dotnet/src/Microsoft.Agents.AI.Tools.Shell/LocalShellExecutor.csMarks local shell execution.
dotnet/src/Microsoft.Agents.AI.Tools.Shell/DockerShellExecutor.csMarks Docker shell execution.
dotnet/src/Microsoft.Agents.AI.Hyperlight/FeatureIndex.csRegisters Hyperlight usage.
dotnet/src/Microsoft.Agents.AI.Hyperlight/HyperlightCodeActProvider.csMarks Hyperlight participation.
dotnet/src/Microsoft.Agents.AI.LocalCodeAct/FeatureIndex.csRegisters local CodeAct usage.
dotnet/src/Microsoft.Agents.AI.LocalCodeAct/LocalCodeActProvider.csMarks local CodeAct participation.
dotnet/src/Microsoft.Agents.AI.Harness/FeatureIndex.csRegisters harness-agent usage.
dotnet/src/Microsoft.Agents.AI.Harness/HarnessAgent.csMarks harness execution.
dotnet/src/Microsoft.Agents.AI.Hosting/FeatureIndex.csRegisters hosting-agent usage.
dotnet/src/Microsoft.Agents.AI.Hosting/AIHostAgent.csMarks hosted-agent operations.
dotnet/src/Microsoft.Agents.AI.Hosting.OpenAI/FeatureIndex.csRegisters OpenAI hosting usage.
dotnet/src/Microsoft.Agents.AI.Hosting.OpenAI/EndpointRouteBuilderExtensions.Responses.csMarks Responses endpoint mapping.
dotnet/src/Microsoft.Agents.AI.Hosting.OpenAI/EndpointRouteBuilderExtensions.Conversations.csMarks Conversations endpoint mapping.
dotnet/src/Microsoft.Agents.AI.Hosting.OpenAI/EndpointRouteBuilderExtensions.ChatCompletions.csMarks chat endpoint mapping.
dotnet/src/Microsoft.Agents.AI.Hosting.AGUI.AspNetCore/FeatureIndex.csRegisters AG-UI hosting usage.
dotnet/src/Microsoft.Agents.AI.Hosting.AGUI.AspNetCore/AGUIEndpointRouteBuilderExtensions.csMarks AG-UI endpoint mapping.
dotnet/src/Microsoft.Agents.AI.Hosting.A2A.AspNetCore/FeatureIndex.csRegisters A2A hosting usage.
dotnet/src/Microsoft.Agents.AI.Hosting.A2A.AspNetCore/A2AEndpointRouteBuilderExtensions.csMarks A2A endpoint mapping.
dotnet/tests/FeatureUsageAssert.csAdds shared mask assertions.
dotnet/tests/Directory.Build.propsLinks shared assertions into tests.
dotnet/tests/Microsoft.Agents.AI.Abstractions.UnitTests/FeatureUsageTests.csTests mask semantics and formatting.
dotnet/tests/Microsoft.Agents.AI.UnitTests/FeatureUsageActivationTests.csTests core feature activation.
dotnet/tests/Microsoft.Agents.AI.Workflows.UnitTests/WorkflowBuilderTests.csTests workflow activation.
dotnet/tests/Microsoft.Agents.AI.Workflows.Declarative.UnitTests/DeclarativeWorkflowOptionsTest.csTests declarative workflow activation.
dotnet/tests/Microsoft.Agents.AI.Foundry.UnitTests/PolicyPipelineInvestigationTests.csProbes policy ordering and isolation.
dotnet/tests/Microsoft.Agents.AI.Foundry.UnitTests/FoundryFeatureUsageActivationTests.csTests Foundry activation and emission.
dotnet/tests/Microsoft.Agents.AI.Foundry.UnitTests/FeatureUsageUserAgentPolicyTests.csTests policy refresh and origin handling.
dotnet/tests/Microsoft.Agents.AI.Foundry.UnitTests/AgentFrameworkUserAgentPolicyTests.csUpdates base User-Agent tests.
dotnet/tests/Microsoft.Agents.AI.Foundry.UnitTests/FoundryChatClientTests.csTests policy registration.
dotnet/tests/Microsoft.Agents.AI.Foundry.UnitTests/FoundryAgentTests.csTests agent policy registration.
dotnet/tests/Microsoft.Agents.AI.Foundry.UnitTests/Microsoft.Agents.AI.Foundry.UnitTests.csprojAdds Azure OpenAI test dependency.
dotnet/tests/Microsoft.Agents.AI.Foundry.Hosting.UnitTests/ServiceCollectionExtensionsTests.csTests Foundry hosting activation.
dotnet/tests/Microsoft.Agents.AI.OpenAI.UnitTests/UserAgentPolicyTests.csTests Azure OpenAI emission.
dotnet/tests/Microsoft.Agents.AI.OpenAI.UnitTests/FeatureUsageActivationTests.csTests OpenAI activation.
dotnet/tests/Microsoft.Agents.AI.OpenAI.UnitTests/Microsoft.Agents.AI.OpenAI.UnitTests.csprojAdds Azure OpenAI test dependency.
dotnet/tests/Microsoft.Agents.AI.Anthropic.UnitTests/FeatureUsageActivationTests.csTests Anthropic activation.
dotnet/tests/Microsoft.Agents.AI.GitHub.Copilot.UnitTests/FeatureUsageActivationTests.csTests GitHub Copilot activation.
dotnet/tests/Microsoft.Agents.AI.GitHub.Copilot.UnitTests/GitHubCopilotAgentTests.csUpdates session and collection tests.
dotnet/tests/Microsoft.Agents.AI.UnitTests/CopilotStudio/FeatureUsageActivationTests.csTests Copilot Studio activation.
dotnet/tests/Microsoft.Agents.AI.A2A.UnitTests/FeatureUsageActivationTests.csTests A2A activation.
dotnet/tests/Microsoft.Agents.AI.A2A.UnitTests/A2AAgentTests.csUpdates A2A session tests.
dotnet/tests/Microsoft.Agents.AI.CosmosNoSql.UnitTests/CosmosCheckpointStoreTests.csTests Cosmos activation.
dotnet/tests/Microsoft.Agents.AI.Valkey.UnitTests/FeatureUsageActivationTests.csTests Valkey activation.
dotnet/tests/Microsoft.Agents.AI.Valkey.UnitTests/ValkeyChatHistoryProviderTests.csApplies minor test cleanup.
dotnet/tests/Microsoft.Agents.AI.Mem0.UnitTests/FeatureUsageActivationTests.csTests Mem0 activation.
dotnet/tests/Microsoft.Agents.AI.Mem0.UnitTests/Mem0ProviderTests.csApplies minor test cleanup.
dotnet/tests/Microsoft.Agents.AI.Purview.UnitTests/FeatureUsageActivationTests.csTests Purview activation.
dotnet/tests/Microsoft.Agents.AI.Purview.UnitTests/PurviewWrapperTests.csApplies minor test cleanup.
dotnet/tests/Microsoft.Agents.AI.Mcp.UnitTests/FeatureUsageActivationTests.csTests MCP activation.
dotnet/tests/Microsoft.Agents.AI.Declarative.UnitTests/FeatureUsageActivationTests.csTests declarative agent activation.
dotnet/tests/Microsoft.Agents.AI.DevUI.UnitTests/FeatureUsageActivationTests.csTests DevUI activation.
dotnet/tests/Microsoft.Agents.AI.DevUI.UnitTests/DevUIAccessControlTests.csSimplifies middleware test typing.
dotnet/tests/Microsoft.Agents.AI.Tools.Shell.UnitTests/FeatureUsageActivationTests.csTests shell activation.
dotnet/tests/Microsoft.Agents.AI.Hyperlight.UnitTests/FeatureUsageActivationTests.csTests Hyperlight activation.
dotnet/tests/Microsoft.Agents.AI.Hyperlight.UnitTests/ProvideAIContextTests.csUpdates assignability assertions.
dotnet/tests/Microsoft.Agents.AI.LocalCodeAct.UnitTests/FeatureUsageActivationTests.csTests local CodeAct activation.
dotnet/tests/Microsoft.Agents.AI.LocalCodeAct.UnitTests/LocalCodeActProviderTests.csUpdates assignability assertion.
dotnet/tests/Microsoft.Agents.AI.Harness.UnitTests/FeatureUsageActivationTests.csTests harness activation.
dotnet/tests/Microsoft.Agents.AI.Hosting.UnitTests/AgentHostingServiceCollectionExtensionsTests.csTests hosted-agent activation.
dotnet/tests/Microsoft.Agents.AI.Hosting.OpenAI.UnitTests/EndpointRouteBuilderExtensionsTests.csTests OpenAI hosting activation.
dotnet/tests/Microsoft.Agents.AI.Hosting.AGUI.AspNetCore.UnitTests/AGUIEndpointRouteBuilderExtensionsTests.csTests AG-UI activation.
dotnet/tests/Microsoft.Agents.AI.Hosting.A2A.UnitTests/A2AEndpointRouteBuilderExtensionsTests.csTests A2A hosting activation.
dotnet/tests/Microsoft.Agents.AI.FeatureRegistry.UnitTests/FeatureRegistryTests.csValidates registry declarations and activations.
dotnet/tests/Microsoft.Agents.AI.FeatureRegistry.UnitTests/README.mdDocuments registry validation.
dotnet/tests/Microsoft.Agents.AI.FeatureRegistry.UnitTests/Microsoft.Agents.AI.FeatureRegistry.UnitTests.csprojAdds the registry test project.
dotnet/eng/MSBuild/Shared.propsAdds shared policy source injection.
dotnet/agent-framework-dotnet.slnxAdds the registry test project.
dotnet/README.mdDocuments 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.

Comment threaddotnet/src/Shared/FeatureUsage/UserAgentPolicyRegistration.cs Outdated
Comment threaddotnet/src/Microsoft.Agents.AI.A2A/A2AAgent.cs Outdated
Comment threaddotnet/src/Microsoft.Agents.AI.CopilotStudio/CopilotStudioAgent.cs Outdated

@github-actionsgithub-actionsBot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Comment threaddotnet/src/Microsoft.Agents.AI.A2A/A2AAgent.cs Outdated
Comment threaddotnet/src/Microsoft.Agents.AI.CopilotStudio/CopilotStudioAgent.cs Outdated
Comment threaddotnet/src/Shared/FeatureUsage/UserAgentPolicyRegistration.cs Outdated
This was referenced Aug 24, 2026
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentationUsage: [Issues, PRs], Target: documentation in the code base and learn docs.NETUsage: [Issues, PRs], Target: .NetworkflowsUsage: [Issues, PRs], Target: Workflows

Projects

None yet

Development

Successfully merging this pull request may close these issues.

.NET: [Feature]: Dotnet feature-usage bitmask

7 participants

@peibekwe@TaoChenOSU@moonbox3@SergeyMenshykh@westey-m@chetantoshniwal