Skip to content

.NET: fix: preserve AG-UI session history#5904

Open
he-yufeng wants to merge 3 commits into
microsoft:mainfrom
he-yufeng:fix/agui-session-preserve-history
Open

.NET: fix: preserve AG-UI session history#5904
he-yufeng wants to merge 3 commits into
microsoft:mainfrom
he-yufeng:fix/agui-session-preserve-history

Conversation

@he-yufeng
Copy link
Copy Markdown
Contributor

Summary

  • keep ChatClientAgent's local history provider active for AG-UI thread ids
  • avoid treating AG-UI ConversationId as service-managed model history
  • add a two-turn AG-UI regression test for sessions after the thread id is set

Fixes #5898

Verified

  • dotnet test --project tests\Microsoft.Agents.AI.AGUI.UnitTests\Microsoft.Agents.AI.AGUI.UnitTests.csproj -f net10.0 --filter-method '*RunStreamingAsync_WithSession_SendsFullHistoryAfterThreadIdIsSetAsync'
  • dotnet test --project tests\Microsoft.Agents.AI.AGUI.UnitTests\Microsoft.Agents.AI.AGUI.UnitTests.csproj -f net10.0 --filter-class Microsoft.Agents.AI.AGUI.UnitTests.AGUIAgentTests
  • dotnet test --project tests\Microsoft.Agents.AI.UnitTests\Microsoft.Agents.AI.UnitTests.csproj -f net10.0 --filter-class Microsoft.Agents.AI.UnitTests.ChatClientAgent_ChatHistoryManagementTests
  • dotnet test --project tests\Microsoft.Agents.AI.AGUI.UnitTests\Microsoft.Agents.AI.AGUI.UnitTests.csproj -f net472 --filter-class Microsoft.Agents.AI.AGUI.UnitTests.AGUIAgentTests
  • dotnet test --project tests\Microsoft.Agents.AI.UnitTests\Microsoft.Agents.AI.UnitTests.csproj -f net472 --filter-class Microsoft.Agents.AI.UnitTests.ChatClientAgent_ChatHistoryManagementTests
  • dotnet test --project tests\Microsoft.Agents.AI.AGUI.UnitTests\Microsoft.Agents.AI.AGUI.UnitTests.csproj -f net10.0
  • dotnet test --project tests\Microsoft.Agents.AI.AGUI.UnitTests\Microsoft.Agents.AI.AGUI.UnitTests.csproj -f net472

Copilot AI review requested due to automatic review settings May 15, 2026 21:09
@moonbox3 moonbox3 added the .NET label May 15, 2026
@github-actions github-actions Bot changed the title fix: preserve AG-UI session history .NET: fix: preserve AG-UI session history May 15, 2026
Copy link
Copy Markdown
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.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

Comment on lines +934 to +937
// AG-UI uses ConversationId as a thread id, not as a signal that the service stores model history.
private bool ConversationIdIndicatesServiceManagedHistory =>
!string.Equals(this._agentMetadata.ProviderName, AGUIProviderName, StringComparison.Ordinal);

Copy link
Copy Markdown
Member

@rogerbarreto rogerbarreto May 15, 2026

Choose a reason for hiding this comment

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

Please use a static private method instead. The Xml comment doesn't align with the member logic.

Suggested change
// AG-UI uses ConversationId as a thread id, not as a signal that the service stores model history.
private bool ConversationIdIndicatesServiceManagedHistory =>
!string.Equals(this._agentMetadata.ProviderName, AGUIProviderName, StringComparison.Ordinal);
// ???
private static bool IsAGUIProviderName(string providerName) =>
string.Equals(providerName, AGUIProviderName, StringComparison.Ordinal);

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Addressed in ef6343528: replaced the instance property with a private static IsAGUIProviderName(...) helper and removed the misleading comment. I used string? for the parameter because ProviderName is nullable under the project settings; the comparison still behaves the same for non-AG-UI providers.

Validation passed locally: AGUI unit-test project build, 3 focused AG-UI history tests, full AGUI unit suite on net10.0 and net472, dotnet format --verify-no-changes, and git diff --check.

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

.NET: [Bug]: AG UI session stops updating after first turn

4 participants