Skip to content

Conversation

@SergeyMenshykh
Copy link
Member

This PR prevents the usage of background responses if no agent thread is provided to A2AAgent.Run{Streaming}Async calls. This change aligns the A2A agent's behavior with that of the ChatClientAgent, where the absence of a thread with background responses could cause inconsistency issues.

@SergeyMenshykh SergeyMenshykh self-assigned this Nov 27, 2025
Copilot AI review requested due to automatic review settings November 27, 2025 10:50
@SergeyMenshykh SergeyMenshykh added .NET a2a Issue relates to A2A labels Nov 27, 2025
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 adds validation to prevent background responses without a thread in A2AAgent, aligning its behavior with ChatClientAgent to ensure consistent user experience.

Key Changes

  • Extracted thread validation logic into a new GetA2AThread helper method that validates both the background response requirement and thread type compatibility
  • Added comprehensive unit tests covering both RunAsync and RunStreamingAsync methods for the new validation scenarios

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
dotnet/src/Microsoft.Agents.AI.A2A/A2AAgent.cs Refactored thread validation by introducing GetA2AThread method that enforces thread requirement when AllowBackgroundResponses is enabled and validates thread type compatibility
dotnet/tests/Microsoft.Agents.AI.A2A.UnitTests/A2AAgentTests.cs Added four new test methods covering both sync and streaming scenarios for background responses without thread and invalid thread type, plus a helper class for testing invalid thread types

@SergeyMenshykh SergeyMenshykh added this pull request to the merge queue Nov 27, 2025
Merged via the queue into microsoft:main with commit e769256 Nov 27, 2025
14 of 15 checks passed
@github-project-automation github-project-automation bot moved this from In Review to Done in Agent Framework Nov 27, 2025
This was referenced Dec 5, 2025
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.

3 participants