Skip to content

.NET: fix service-stored history provider resolution - #6209

Closed
he-yufeng wants to merge 4 commits into
microsoft:mainfrom
he-yufeng:fix/service-history-provider-session
Closed

.NET: fix service-stored history provider resolution#6209
he-yufeng wants to merge 4 commits into
microsoft:mainfrom
he-yufeng:fix/service-history-provider-session

Conversation

@he-yufeng

Copy link
Copy Markdown
Contributor

Summary

  • skip the default chat history provider once a session is backed by a service conversation id
  • keep per-service-call history persistence working when it uses its sentinel conversation id
  • add a regression assertion that service-stored history does not populate the default in-memory provider

Fixes #6120.

To verify

  • dotnet test --project tests\Microsoft.Agents.AI.UnitTests\Microsoft.Agents.AI.UnitTests.csproj -f net10.0 -v Minimal --filter-class Microsoft.Agents.AI.UnitTests.ChatClientAgent_ChatHistoryManagementTests
  • dotnet test --project tests\Microsoft.Agents.AI.UnitTests\Microsoft.Agents.AI.UnitTests.csproj -f net472 -v Minimal --filter-class Microsoft.Agents.AI.UnitTests.ChatClientAgent_ChatHistoryManagementTests
  • dotnet format agent-framework-dotnet.slnx --verify-no-changes --no-restore --include src\Microsoft.Agents.AI\ChatClient\ChatClientAgent.cs tests\Microsoft.Agents.AI.UnitTests\ChatClient\ChatClientAgent_ChatHistoryManagementTests.cs
  • git diff --check

Copilot AI review requested due to automatic review settings May 30, 2026 15:12
@moonbox3 moonbox3 added the .NET Usage: [Issues, PRs], Target: .Net label May 30, 2026
@he-yufeng
he-yufeng force-pushed the fix/service-history-provider-session branch from 1135e79 to db3fc3f Compare June 2, 2026 19:52
@he-yufeng

Copy link
Copy Markdown
Contributor Author

Rebased on current upstream/main and reran the scoped ChatClientAgent validation locally.

Validated:

dotnet build .\tests\Microsoft.Agents.AI.UnitTests\Microsoft.Agents.AI.UnitTests.csproj -f net10.0 -c Debug --tl:off
dotnet test --project .\tests\Microsoft.Agents.AI.UnitTests\Microsoft.Agents.AI.UnitTests.csproj -f net10.0 -c Debug --no-build -v Normal --report-xunit-trx --ignore-exit-code 8 -- --filter-class Microsoft.Agents.AI.UnitTests.ChatClient.ChatClientAgent_ChatHistoryManagementTests
git diff --check upstream/main...HEAD

All passed after the rebase.

@he-yufeng

Copy link
Copy Markdown
Contributor Author

Correction: my first test command used the wrong class namespace and selected 0 tests. I reran with the actual class name.

Validated:

dotnet test --project .\tests\Microsoft.Agents.AI.UnitTests\Microsoft.Agents.AI.UnitTests.csproj -f net10.0 -c Debug --no-build -v Normal --report-xunit-trx --ignore-exit-code 8 -- --filter-class Microsoft.Agents.AI.UnitTests.ChatClientAgent_ChatHistoryManagementTests
git diff --check upstream/main...HEAD

Result: 19/19 tests passed.

@he-yufeng
he-yufeng force-pushed the fix/service-history-provider-session branch from db3fc3f to 5503e3f Compare June 6, 2026 20:00
@he-yufeng

Copy link
Copy Markdown
Contributor Author

Rebased this PR onto the latest upstream main and re-ran the focused validation.

Validation:

  • git diff --check upstream/main..HEAD
  • dotnet build .\dotnet\tests\Microsoft.Agents.AI.UnitTests\Microsoft.Agents.AI.UnitTests.csproj -f net10.0 -c Debug --tl:off
  • dotnet .\dotnet\tests\Microsoft.Agents.AI.UnitTests\bin\Debug\net10.0\Microsoft.Agents.AI.UnitTests.dll --filter-class Microsoft.Agents.AI.UnitTests.ChatClientAgent_ChatHistoryManagementTests --no-progress (19 passed)

@he-yufeng
he-yufeng force-pushed the fix/service-history-provider-session branch from 5503e3f to 756b594 Compare June 10, 2026 19:37
@he-yufeng

Copy link
Copy Markdown
Contributor Author

Rebased this PR onto the latest upstream main and resolved the ChatClientAgent.cs conflict by preserving the new AG-UI provider exception while keeping this PR's service-stored-history behavior for non-AG-UI providers. Validation after the rebase: git diff --check, dotnet build .\dotnet\tests\Microsoft.Agents.AI.UnitTests\Microsoft.Agents.AI.UnitTests.csproj -f net10.0 -c Debug --tl:off, and dotnet .\dotnet\tests\Microsoft.Agents.AI.UnitTests\bin\Debug\net10.0\Microsoft.Agents.AI.UnitTests.dll --filter-class Microsoft.Agents.AI.UnitTests.ChatClientAgent_ChatHistoryManagementTests --no-progress (19 passed).

@he-yufeng
he-yufeng force-pushed the fix/service-history-provider-session branch from 756b594 to 7511346 Compare June 12, 2026 03:41
@he-yufeng

Copy link
Copy Markdown
Contributor Author

Rebased this branch onto current main and pushed the updated head 75113466.

Validation run locally from dotnet/:

  • dotnet build .\src\Microsoft.Agents.AI\Microsoft.Agents.AI.csproj -f net10.0 --tl:off -> passed, 0 warnings/errors
  • dotnet run --project .\tests\Microsoft.Agents.AI.UnitTests\Microsoft.Agents.AI.UnitTests.csproj -f net10.0 -> passed, 1647 tests
  • git diff --check upstream/main..HEAD -> passed

I used dotnet run --project for the xUnit v3/MTP test project because dotnet test is not usable with this checkout's current runner configuration on my Windows machine.

@he-yufeng

Copy link
Copy Markdown
Contributor Author

Rebased this branch onto current main and pushed the updated head $head.

Validation run locally from dotnet/:

  • dotnet build .\src\Microsoft.Agents.AI\Microsoft.Agents.AI.csproj -f net10.0 --tl:off -> passed, 0 warnings/errors
  • dotnet run --project .\tests\Microsoft.Agents.AI.UnitTests\Microsoft.Agents.AI.UnitTests.csproj -f net10.0 -> passed, 1647 tests
  • git diff --check upstream/main..HEAD -> passed

@he-yufeng
he-yufeng force-pushed the fix/service-history-provider-session branch 11 times, most recently from f819d88 to 92fcc19 Compare June 18, 2026 08:59
@he-yufeng
he-yufeng force-pushed the fix/service-history-provider-session branch from 92fcc19 to f999690 Compare June 24, 2026 01:09
@he-yufeng
he-yufeng force-pushed the fix/service-history-provider-session branch from f999690 to 78d5aed Compare June 25, 2026 01:27
@peibekwe
peibekwe temporarily deployed to github-app-auth July 22, 2026 21:18 — with GitHub Actions Inactive
@peibekwe

Copy link
Copy Markdown
Contributor

Closing this PR in preference to #7284

@peibekwe peibekwe closed this Jul 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

.NET Usage: [Issues, PRs], Target: .Net

Projects

None yet

Development

Successfully merging this pull request may close these issues.

.NET: [Bug]: InMemoryChatHistoryProvider used even when service stores history (OpenAI Responses)

3 participants