Skip to content

.NET: [BREAKING] Simplify A2A agent creation and payload handling - #10113

Merged
SergeyMenshykh merged 3 commits into
microsoft:mainfrom
SergeyMenshykh:sergeymenshykh-a2a-agent-identity
Nov 5, 2026
Merged

SergeyMenshykh merged 3 commits into
microsoft:mainfrom
SergeyMenshykh:sergeymenshykh-a2a-agent-identity

Conversation

@SergeyMenshykh

@SergeyMenshykh SergeyMenshykh commented Nov 5, 2026 •

Copy link
Copy Markdown
Collaborator

Motivation

Simplify A2A agent creation by using one options-based API and remove null-forgiving operators from response handling.

Description

  • Remove the individual identity-parameter overloads from A2AAgent and IA2AClient.AsAIAgent. Callers configuring identity must now use A2AAgentOptions.
  • Make options nullable and optional, clone supplied options, and avoid allocating default options when none are supplied.
  • Use payload case checks with non-null patterns for responses and when guards for streaming updates.
  • AI assistance was used for implementation, tests, documentation, and this PR description.

Related Issue

No linked issue.

semenshi-m (semenshi) and others added 2 commits November 5, 2026 10:33
Remove individual identity-parameter overloads and use nullable, optional A2AAgentOptions for constructors and client extensions. Update callers, documentation, and tests.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Use payload case checks with non-null patterns for responses and when guards for streaming updates.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot AI balanced review requested due to automatic review settings November 5, 2026 10:49
@agent-framework-automation agent-framework-automation Bot added documentation Usage: [Issues, PRs], Target: documentation in the code base and learn docs .NET Usage: [Issues, PRs], Target: .Net breaking change Usage: [PRs], Target: all PRs that introduce changes that are not backward compatible labels Nov 5, 2026
@SergeyMenshykh SergeyMenshykh self-assigned this Nov 5, 2026
@SergeyMenshykh SergeyMenshykh moved this to In Review in Agent Framework Nov 5, 2026
@SergeyMenshykh
SergeyMenshykh marked this pull request as ready for review November 5, 2026 10:50

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.

🟢 Approval recommended

No active review issues remain for the options-based API consolidation and null-safe response handling.

No open issues 🎉

What changed in this PR

Simplifies .NET A2A agent creation around a single options-based API and makes response payload handling explicitly null-safe. Removing the identity-parameter overloads is a breaking change for callers configuring agent identity.

Changes:

  • Make A2AAgentOptions optional and nullable, preserving cloning when supplied and avoiding default-options allocation.
  • Replace null-forgiving payload access with non-null patterns in regular and streaming responses.
  • Migrate agent-card creation, sample documentation, and tests to the options-based API.
File Description
dotnet/​tests/​Microsoft.Agents.AI.A2A.UnitTests/​Extensions/​A2AClientExtensionsTests.cs Migrate identity tests and cover omitted options, null options, and null clients.
dotnet/​tests/​Microsoft.Agents.AI.A2A.UnitTests/​A2AAgentTests.cs Update constructor tests for options-based identity and default behavior.
dotnet/​src/​Microsoft.Agents.AI.A2A/​Extensions/​A2AClientExtensions.cs Consolidate client conversion into one optional-options overload.
dotnet/​src/​Microsoft.Agents.AI.A2A/​Extensions/​A2AAgentCardExtensions.cs Pass card identity through A2AAgentOptions.
dotnet/​src/​Microsoft.Agents.AI.A2A/​A2AAgentOptions.cs Remove documentation referring to individual constructor parameters.
dotnet/​src/​Microsoft.Agents.AI.A2A/​A2AAgent.cs Consolidate construction, handle absent options, and guard response payloads.
dotnet/​samples/​02-agents/​A2A/​A2AAgent_ProtocolSelection/​README.md Update the direct-client example to use options.

Review effort: Balanced

@github-actions github-actions Bot 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: No findings
Scope: full PR (2 commit(s)): 9ddf897ada77, 3d887614129e
Model: gpt-5.6-sol

Overview

This PR intentionally consolidates public A2A creation APIs around nullable optional options, clones supplied identity data, and replaces null-forgiving payload access with guarded patterns that fail closed on malformed unions. Constructor and extension tests cover omitted, null, and empty options, stable fallback identity, null-client guards, and mutation isolation; existing agent-card paths preserve card metadata. The sole compatibility concern is the deliberately declared breaking overload removal, which follows the repository's breaking-change policy for this preview package and is not a defect against the stated contract.

Reviewed the supplied pull-request change set across correctness, security/reliability, architecture, and failure behavior.
No publishable findings remained after source verification for this scope.

Remove unnecessary identity options and the unused namespace import from the direct gRPC example.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@SergeyMenshykh
SergeyMenshykh added this pull request to the merge queue Nov 5, 2026
Merged via the queue into microsoft:main with commit 89cb64c Nov 5, 2026
34 of 36 checks passed
@SergeyMenshykh
SergeyMenshykh deleted the sergeymenshykh-a2a-agent-identity branch November 5, 2026 13:11
@github-project-automation github-project-automation Bot moved this from In Review to Done in Agent Framework Nov 5, 2026

This branch was previously deployed

1 inactive deployment
github-app-auth — c45c0286 Deployed Nov 5, 2026 by SergeyMenshykh via add_label #27148
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

breaking change Usage: [PRs], Target: all PRs that introduce changes that are not backward compatible documentation Usage: [Issues, PRs], Target: documentation in the code base and learn docs .NET Usage: [Issues, PRs], Target: .Net

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

5 participants