Skip to content

.NET: Map additional props <-> A2A metadata#3137

Merged
SergeyMenshykh merged 10 commits intomicrosoft:mainfrom
SergeyMenshykh:a2a-map-metadata-and-additional-props
Jan 8, 2026
Merged

.NET: Map additional props <-> A2A metadata#3137
SergeyMenshykh merged 10 commits intomicrosoft:mainfrom
SergeyMenshykh:a2a-map-metadata-and-additional-props

Conversation

@SergeyMenshykh
Copy link
Member

@SergeyMenshykh SergeyMenshykh commented Jan 8, 2026

Motivation and Context

Currently, the AF A2A agent does not pass the additional properties from the agent run options down to the A2A agent. Moreover, the A2A hosting layer does not pass the metadata received in the A2A call to the run options of an underlying agent and does not return the additional properties returned by the underlying agent in the A2A call result. This prevents consumers from passing additional data from AF to A2A and back. More details can be found here: #2974

Description

This PR:

  • [A2A Agent] Maps properties from AgentRunOptions.AdditionalProperties to A2A.MessageSendParams.Metadata.
  • [A2A Agent] [Not related to the mapping] Removes unnecessary ?? base.Name and ?? base.Description fallbacks for A2A agent Name and Description properties.
  • [A2A Hosting] Maps A2A.MessageSendParams.Metadata to AgentRunOptions.AdditionalProperties.
  • [A2A Hosting] Maps AgentRunResult.AdditionalProperties to A2AResponse.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR implements bidirectional mapping of additional properties between the Agent Framework and A2A protocol metadata:

  • Maps AgentRunOptions.AdditionalProperties to A2A.MessageSendParams.Metadata when sending messages to A2A agents
  • Maps incoming A2A.MessageSendParams.Metadata to AgentRunOptions.AdditionalProperties in the A2A hosting layer
  • Maps AgentRunResult.AdditionalProperties to A2AResponse.Metadata when returning responses from hosted agents

Key changes:

  • Adds extension methods to convert between AdditionalPropertiesDictionary and A2A metadata format (Dictionary<string, JsonElement>)
  • Updates A2AAgent to propagate AdditionalProperties to/from A2A calls
  • Updates AIAgentExtensions hosting layer to handle metadata bidirectionally

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
dotnet/src/Microsoft.Agents.AI.A2A/Extensions/AdditionalPropertiesDictionaryExtensions.cs New extension method to convert AdditionalPropertiesDictionary to A2A metadata format
dotnet/src/Microsoft.Agents.AI.A2A/Extensions/A2AMetadataExtensions.cs Adds documentation remarks to existing ToAdditionalProperties method
dotnet/src/Microsoft.Agents.AI.A2A/A2AAgent.cs Updates RunCoreAsync and RunCoreStreamingAsync to propagate AdditionalProperties to/from A2A calls; simplifies Name and Description properties
dotnet/src/Microsoft.Agents.AI.Hosting.A2A/Converters/AdditionalPropertiesDictionaryExtensions.cs New extension method to convert AdditionalPropertiesDictionary to A2A metadata format (duplicate of A2A project version)
dotnet/src/Microsoft.Agents.AI.Hosting.A2A/Converters/A2AMetadataExtensions.cs New extension method to convert A2A metadata to AdditionalPropertiesDictionary (duplicate of A2A project version)
dotnet/src/Microsoft.Agents.AI.Hosting.A2A/AIAgentExtensions.cs Updates MapA2A to convert incoming metadata to options and outgoing response properties to metadata
dotnet/tests/Microsoft.Agents.AI.A2A.UnitTests/Extensions/AdditionalPropertiesDictionaryExtensionsTests.cs Comprehensive unit tests for ToA2AMetadata extension method
dotnet/tests/Microsoft.Agents.AI.A2A.UnitTests/A2AAgentTests.cs Tests for AdditionalProperties propagation in RunAsync and RunStreamingAsync
dotnet/tests/Microsoft.Agents.AI.Hosting.A2A.UnitTests/AIAgentExtensionsTests.cs Tests for metadata/AdditionalProperties bidirectional conversion in hosting layer

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

a2a Issue relates to A2A .NET

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

4 participants