Repository navigation
.NET: [BREAKING] Simplify A2A agent creation and payload handling - #10113
SergeyMenshykh merged 3 commits into
Conversation
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>
There was a problem hiding this comment.
🟢 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
A2AAgentOptionsoptional 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
There was a problem hiding this comment.
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>
Motivation
Simplify A2A agent creation by using one options-based API and remove null-forgiving operators from response handling.
Description
A2AAgentandIA2AClient.AsAIAgent. Callers configuring identity must now useA2AAgentOptions.whenguards for streaming updates.Related Issue
No linked issue.