Skip to content

Port FeatureUsage tracking and .NET behavioral tests - #1269

Merged
Quim Muntal (qmuntal) merged 2 commits into
mainfrom
port-feature-usage
Oct 9, 2026
Merged

Quim Muntal (qmuntal) merged 2 commits into
mainfrom
port-feature-usage

Conversation

@qmuntal

Copy link
Copy Markdown
Member

Summary

  • Port process-wide FeatureUsage tracking with a concurrency-safe 128-bit mask, cached versioned hexadecimal tokens, and byte-preserving User-Agent comment replacement.
  • Align feature indexes with .NET v1 and track only supported .NET-registered capabilities; add activation marks across agents, context/history providers, skills, tools, workflows, and integrations.
  • Emit feature comments only on approved HTTPS origins for each OpenAI/Foundry adapter family, retaining SDK origin/redirect guards, caller transports, and the existing opt-outs.
  • Add direct .NET behavioral test ports and record 36 verified FeatureUsage test pairings in the catalog. Unsupported integrations, mixed suites requiring unavailable capabilities, and CLR-specific tests remain unpaired.
  • Document the registry, activation points, emission boundaries, and environment controls.

Parity fixes covered by the ports

  • Foundry streams remain cold until enumeration; server-agent requests mark both Foundry agent and chat-client bits before sending.
  • Empty Foundry memory provider hooks mark participation without making a request.
  • Cancelled Copilot runs record usage and return cancellation without starting the runtime.
  • Empty Anthropic streams do not fabricate zero-usage updates.

Validation

  • 194 focused telemetry tests passed.
  • 333 affected OpenAI, Anthropic, Copilot, and Foundry component tests passed.
  • Re-ran all 52 activation cases after the final lint cleanup.
  • Strict catalog test checks: no unresolved references or invalid Go targets.
  • go vet and change-scoped golangci-lint v2.14.0 passed; git diff --check passed.
  • Staged changes were checked for binaries, build artifacts, and credential patterns.

Race detection is unsupported on the validation host (Windows ARM64). Full lint still reports unrelated pre-existing issues; change-scoped lint is clean.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI balanced review requested due to automatic review settings October 8, 2026 13:59
@qmuntal
Quim Muntal (qmuntal) requested a review from a team as a code owner October 8, 2026 13:59
@github-actions github-actions Bot added area:agent Changes files in the agent area area:internal Changes files in the internal area area:provider Changes files in the provider area area:provider/a2a Changes files in the provider / a2a area area:provider/agui Changes files in the provider / agui area area:provider/anthropic Changes files in the provider / anthropic area area:provider/copilot Changes files in the provider / copilot area area:provider/foundry Changes files in the provider / foundry area area:provider/openai Changes files in the provider / openai area area:tool Changes files in the tool area area:workflow Changes files in the workflow area size:xlarge More than 300 changed lines or 10 files labels Oct 8, 2026
@github-actions github-actions Bot added kind:code Changes production behavior or code kind:docs Changes documentation or comments kind:tests Changes tests, fixtures, or test infrastructure labels Oct 8, 2026

Copilot AI 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.

🔵 Needs a closer look

Default-on, process-wide telemetry and HTTP emission boundaries warrant human verification alongside the unresolved correctness issues.

2 open findings
What changed in this PR

Adds process-wide feature tracking to the Go SDK, with .NET-aligned indexes and restricted User-Agent emission.

Changes:

  • Tracks capability activation across agents, providers, tools, and workflows.
  • Adds approved-origin emission, opt-outs, and provider lifecycle fixes.
  • Adds behavioral tests, 36 catalog pairings, and telemetry documentation.
File Description
workflow/​builder.go Records successful workflow builds.
workflow/​agentworkflow/​sequential.go Tracks sequential orchestration.
workflow/​agentworkflow/​groupchat.go Tracks group-chat orchestration.
workflow/​agentworkflow/​concurrent.go Tracks concurrent orchestration.
tool/​shelltool/​localshell.go Tracks shell execution and initialization.
tool/​shelltool/​environment.go Tracks environment-provider participation.
tool/​mcptool/​mcp.go Tracks MCP operations.
README.md Explains telemetry and opt-outs.
provider/​openaiprovider/​responses.go Tracks Responses usage and applies emission policy.
provider/​openaiprovider/​chat.go Applies adapter-specific emission policy.
provider/​foundryprovider/​memory.go Tracks memory-provider participation.
provider/​foundryprovider/​clientheaders.go Defers activation until enumeration.
provider/​foundryprovider/​agent.go Distinguishes server-agent targets.
provider/​copilotprovider/​copilot.go Tracks usage before cancellation handling.
provider/​anthropicprovider/​agent.go Tracks usage and handles empty streams.
provider/​aguiprovider/​hosting.go Tracks AG-UI hosting.
provider/​a2aprovider/​handler.go Tracks A2A request handling.
provider/​a2aprovider/​executor.go Tracks A2A executor operations.
provider/​a2aprovider/​a2a.go Tracks A2A client usage.
provider/​a2aprovider/​a2a_test.go Tests activation and cold streams.
internal/​telemetry/​telemetry_test.go Tests masks, headers, origins, and opt-outs.
internal/​telemetry/​featureusage.go Implements accumulation and header emission.
internal/​telemetry/​featureusage_internal_test.go Tests caching and Foundry policies.
internal/​telemetry/​featureusage_activation_test.go Tests activation and adapter boundaries.
docs/​feature-usage-telemetry.md Documents registry and emission controls.
agent/​skills/​provider.go Tracks skills providers and in-memory sources.
agent/​skills/​fsskills/​source.go Tracks file-backed skill discovery.
agent/​history.go Tracks in-memory history participation.
agent/​harness/​toolapproval/​toolapproval.go Tracks approval middleware.
agent/​harness/​todo/​todo.go Tracks todo-provider participation.
agent/​harness/​agentmode/​agentmode.go Tracks agent-mode participation.
agent/​compaction/​provider.go Tracks context compaction.
agent/​compaction/​historyprovider.go Tracks history compaction.
agent/​agent.go Tracks agent invocation.
_catalog/​dotnet-go-sdk-symbol-mapping.json Records behavioral-test pairings.

🧠 Review effort: Balanced


Give feedback about Copilot approvals in this survey to enter a drawing for a $150 gift card.

Comment thread internal/telemetry/featureusage.go
Comment thread workflow/builder.go Outdated
@github-actions

This comment has been minimized.

@github-actions github-actions Bot added the parity-approved Go API consistency review found no parity issues label Oct 8, 2026
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot AI 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.

🔵 Needs a closer look

Default-on telemetry crosses provider emission boundaries and concurrent execution paths, warranting human validation, especially without race-detector coverage.

0 open findings

2 resolved since last review

🧠 Review effort: Balanced


Give feedback about Copilot approvals in this survey to enter a drawing for a $150 gift card.

@github-actions

github-actions Bot commented Oct 8, 2026

Copy link
Copy Markdown
Contributor

API consistency review

Result Scope
aligned public API / user-visible behavior

Changed Go contract

  • New internal/telemetry package: MarkUsed(index int), ApplyToUserAgent(userAgent string, includeFeatureToken bool) string, ApplyToHTTPRequest/ApplyToFoundryHTTPRequest (origin-gated User-Agent feature-comment injection), feature index constants (FeatureAgent, FeatureWorkflow, FeatureToolApproval, FeatureCompactionProvider, FeatureSkillsProvider, FeatureFileSkillsSource, FeatureInMemorySkillsSource, FeatureMCP, FeatureTodoProvider, FeatureAgentModeProvider, FeatureInMemoryHistoryProvider, FeatureSequentialOrchestration, FeatureConcurrentOrchestration, FeatureGroupChatOrchestration, FeatureFoundryChatClient, FeatureFoundryAgent, FeatureFoundryMemory, FeatureOpenAI, FeatureAnthropic, FeatureGitHubCopilot, FeatureA2A, FeatureHostingAGUI, FeatureShell, FeatureHostingA2A).
  • New AGENT_FRAMEWORK_FEATURE_MASK_DISABLED environment-variable opt-out (mask-only), documented alongside the existing AGENT_FRAMEWORK_USER_AGENT_DISABLED.
  • Observable behavior changes: the OpenAI/Foundry adapters' outbound User-Agent header now carries an additional (feat=vN.hex) comment on approved HTTPS Azure/Foundry hosts only; foundryprovider.clientheadersMiddleware now marks agent/chat-client bits and preserves "cold until enumeration" semantics for streaming; copilotprovider now checks ctx.Err() before starting the client so a cancelled run returns promptly without starting the runtime; anthropicprovider streaming no longer emits a trailing zero-usage update when the stream produced no events.
  • docs/feature-usage-telemetry.md added; README.md updated to describe the mask and opt-outs.

Upstream evidence reviewed

Implementation Source Contract checked
.NET dotnet/src/Microsoft.Agents.AI.Abstractions/FeatureUsage.cs MarkUsed idempotency/range, AGENT_FRAMEWORK_FEATURE_MASK_DISABLED semantics, ApplyToUserAgent/token caching/comment removal algorithm
.NET docs/specs/feature-usage-bit-registry.md Index table — .NET version 1 (indexes 0–74); Go reuses only the subset it has equivalents for, with identical numbering
.NET dotnet/src/Microsoft.Agents.AI.OpenAI/UserAgentPolicies.cs + UserAgentPolicyTests.cs Approved OpenAI host suffixes (cognitiveservices.azure.com, openai.azure.com, services.ai.azure.com), HTTPS-only, subdomain match, lookalike-host rejection
.NET dotnet/src/Microsoft.Agents.AI.Foundry/AgentFrameworkUserAgentPolicy.cs Approved Foundry host suffixes (services.ai.azure.com, inference.ai.azure.com)
.NET ClientHeadersAgent.cs + FoundryChatClient.cs (MarkRequestFeatures) Server-agent path marks both FoundryAgent and FoundryChatClient; marking happens per-request, not at construction
.NET GitHubCopilotAgent.cs Feature mark placed before client-start/session creation in the streaming run path
.NET AnthropicClientExtensions.cs (streaming loop, usageDetails is not null guard) Trailing usage update is only yielded when upstream usage data was actually observed

Assessment

This PR is a direct, well-evidenced port of the .NET FeatureUsage v1 registry and its emission policy. Feature indexes, the registry version/token format (v1.<hex>), the dedicated AGENT_FRAMEWORK_FEATURE_MASK_DISABLED opt-out (mask-only, distinct from the existing whole-User-Agent opt-out), per-adapter-family approved HTTPS host suffixes, and the Foundry agent+chat-client dual-marking all match upstream exactly. The accompanying parity fixes (Copilot cancellation check before client start, Anthropic no-fabricated-usage-on-empty-stream, Foundry memory/stream "cold until enumeration" semantics) are each supported by the corresponding upstream source reviewed above. No Go-only public surface, default divergence, or unconditionally-enabled behavior beyond upstream's equivalent was found. examples/ were not touched by this PR.

Warning

Firewall blocked 4 domains

The following domains were blocked by the firewall during workflow execution:

  • github.com
  • proxy.golang.org
  • storage.googleapis.com
  • sum.golang.org

To allow these domains, add them to the network.allowed list in your workflow frontmatter:

network:
  allowed:
    - defaults
    - "github.com"
    - "proxy.golang.org"
    - "storage.googleapis.com"
    - "sum.golang.org"

See Network Configuration for more information.

Generated by Go API Consistency Review Agent for #1269 · copilot · auto · 227.7 AIC · ⌖ 13.9 AIC · ⊞ 13.9K · ◷

@github-actions github-actions Bot added the public-api-change Pull Request changes public APIs label Oct 8, 2026
@qmuntal
Quim Muntal (qmuntal) added this pull request to the merge queue Oct 9, 2026
Merged via the queue into main with commit 8b1465d Oct 9, 2026
34 of 35 checks passed
@qmuntal
Quim Muntal (qmuntal) deleted the port-feature-usage branch October 9, 2026 09:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:agent Changes files in the agent area area:internal Changes files in the internal area area:provider/a2a Changes files in the provider / a2a area area:provider/agui Changes files in the provider / agui area area:provider/anthropic Changes files in the provider / anthropic area area:provider/copilot Changes files in the provider / copilot area area:provider/foundry Changes files in the provider / foundry area area:provider/openai Changes files in the provider / openai area area:provider Changes files in the provider area area:tool Changes files in the tool area area:workflow Changes files in the workflow area kind:code Changes production behavior or code kind:docs Changes documentation or comments kind:tests Changes tests, fixtures, or test infrastructure parity-approved Go API consistency review found no parity issues public-api-change Pull Request changes public APIs size:xlarge More than 300 changed lines or 10 files

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants