Skip to content

.NET: Improve session cast error message quality and consistency - #3973

Merged
westey (westey-m) merged 2 commits into
microsoft:mainfrom
westey-m:session-cast-error-consistency
Feb 17, 2026
Merged

.NET: Improve session cast error message quality and consistency#3973
westey (westey-m) merged 2 commits into
microsoft:mainfrom
westey-m:session-cast-error-consistency

Conversation

@westey-m

Copy link
Copy Markdown
Contributor

Motivation and Context

#3677

Description

  • Improve quality and consistency of session cast failures

Contribution Checklist

  • The code builds clean without any errors or warnings
  • The PR follows the Contribution Guidelines
  • All unit tests pass, and I have added new tests where possible
  • Is this a breaking change? If yes, add "[BREAKING]" prefix to the title of the PR.

CopilotAI review requested due to automatic review settings February 16, 2026 18:32
@markwallace-microsoftMark Wallace (markwallace-microsoft) added .NET Usage: [Issues, PRs], Target: .Net workflows Usage: [Issues, PRs], Target: Workflows labels Feb 16, 2026
@github-actionsgithub-actionsBot changed the title Improve session cast error message quality and consistency.NET: Improve session cast error message quality and consistencyFeb 16, 2026
@markwallace-microsoftMark Wallace (markwallace-microsoft) added the documentation Usage: [Issues, PRs], Target: documentation in the code base and learn docs label Feb 16, 2026

CopilotAI 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.

Pull request overview

This PR improves the clarity and consistency of error messages when session type mismatches occur during agent operations. The changes address feedback from issue #3677 that the previous error messages were unclear about whether they referred to the agent instance or the agent type.

Changes:

  • Updated all session type mismatch error messages to include both the actual session type name and the expected session type name
  • Standardized error message format across all agent implementations (ChatClientAgent, CopilotStudioAgent, A2AAgent, GitHubCopilotAgent, DurableAIAgent, DurableAIAgentProxy, WorkflowHostAgent)
  • Applied consistent error messages in test agent implementations

Reviewed changes

Copilot reviewed 13 out of 13 changed files in this pull request and generated 1 comment.

Show a summary per file
FileDescription
dotnet/src/Microsoft.Agents.AI/ChatClient/ChatClientAgent.csUpdated session type mismatch errors in SerializeSessionCoreAsync and RunCoreStreamingAsync to include actual and expected type names
dotnet/src/Microsoft.Agents.AI.CopilotStudio/CopilotStudioAgent.csUpdated session type mismatch errors in SerializeSessionCoreAsync, RunCoreAsync, and RunCoreStreamingAsync
dotnet/src/Microsoft.Agents.AI.A2A/A2AAgent.csUpdated session type mismatch errors in SerializeSessionCoreAsync and GetA2ASessionAsync
dotnet/src/Microsoft.Agents.AI.GitHub.Copilot/GitHubCopilotAgent.csUpdated session type mismatch errors in SerializeSessionCoreAsync and RunCoreStreamingAsync to use consistent format
dotnet/src/Microsoft.Agents.AI.DurableTask/DurableAIAgent.csUpdated session type mismatch error in SerializeSessionCoreAsync
dotnet/src/Microsoft.Agents.AI.DurableTask/DurableAIAgentProxy.csUpdated session type mismatch error in SerializeSessionCoreAsync
dotnet/src/Microsoft.Agents.AI.Workflows/WorkflowHostAgent.csUpdated session type mismatch error in SerializeSessionCoreAsync
dotnet/tests/Microsoft.Agents.AI.Workflows.UnitTests/TestEchoAgent.csUpdated session type mismatch error in test agent
dotnet/tests/Microsoft.Agents.AI.Hosting.AGUI.AspNetCore.UnitTests/AGUIEndpointRouteBuilderExtensionsTests.csUpdated session type mismatch errors in test agents
dotnet/tests/Microsoft.Agents.AI.Hosting.AGUI.AspNetCore.IntegrationTests/SharedStateTests.csUpdated session type mismatch error in test agent
dotnet/tests/Microsoft.Agents.AI.Hosting.AGUI.AspNetCore.IntegrationTests/ForwardedPropertiesTests.csUpdated session type mismatch error in test agent
dotnet/tests/Microsoft.Agents.AI.Hosting.AGUI.AspNetCore.IntegrationTests/BasicStreamingTests.csUpdated session type mismatch error in test agent

Comment threaddotnet/src/Microsoft.Agents.AI.DurableTask/DurableAIAgent.cs
@westey-m
westey (westey-m) added this pull request to the merge queueFeb 17, 2026
@github-merge-queue
github-merge-queueBot removed this pull request from the merge queue due to failed status checks Feb 17, 2026
@westey-m
westey (westey-m) added this pull request to the merge queueFeb 17, 2026
@westey-m
westey (westey-m) removed this pull request from the merge queue due to a manual request Feb 17, 2026
@westey-m
westey (westey-m) added this pull request to the merge queueFeb 17, 2026
@westey-m
westey (westey-m) removed this pull request from the merge queue due to a manual request Feb 17, 2026
@westey-m
westey (westey-m) added this pull request to the merge queueFeb 17, 2026
@github-merge-queue
github-merge-queueBot removed this pull request from the merge queue due to failed status checks Feb 17, 2026
@westey-m
westey (westey-m) added this pull request to the merge queueFeb 17, 2026
Merged via the queue into microsoft:main with commit 08275f6Feb 17, 2026
16 checks passed
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentationUsage: [Issues, PRs], Target: documentation in the code base and learn docs.NETUsage: [Issues, PRs], Target: .NetworkflowsUsage: [Issues, PRs], Target: Workflows

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants

@westey-m@rogerbarreto@SergeyMenshykh@markwallace-microsoft