[dotnet-port] Preserve AGUI session history across multi-turn runs - #258
Conversation
The AG-UI provider assigns a thread ID to the session on the first run by calling session.SetServiceID(threadID). The agent's history machinery interpreted any non-empty ServiceID as a signal that the service manages history server-side, and therefore disabled the local HistoryProvider for every subsequent run. This caused conversation history to be dropped after the first turn. Add ServiceDoesNotManageHistory bool to ProviderConfig. Providers that never delegate history to the service (e.g. AGUI) set this flag true; the agent then preserves the HistoryProvider across runs regardless of whether the session has a ServiceID. This also prevents the provider from being flagged as a conflict when a user-configured HistoryProvider is present. Set ServiceDoesNotManageHistory: true in the AGUI provider constructor. Add TestAGUIAgentRun_WithSession_PreservesHistoryAcrossMultipleTurns to verify that the second run sends the full conversation history (3 messages) rather than only the new user message. Ports behavior fix from microsoft/agent-framework#5904. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
This PR fixes AG-UI multi-turn sessions dropping conversation history after the first run. The root cause was that the agent treated any non-empty Session.ServiceID as “service-managed history,” which disabled the local HistoryProvider for subsequent turns; AG-UI sets a thread ID into ServiceID but still requires the client to send full history every run.
Changes:
- Add
ServiceDoesNotManageHistorytoagent.ProviderConfigand thread it into the agent’s history selection / conflict logic. - Set
ServiceDoesNotManageHistory: truefor the AG-UI provider so local history is preserved even whenSession.ServiceIDis set. - Add an AG-UI test ensuring the second run includes full history (3 messages) rather than only the new user message.
Show a summary per file
| File | Description |
|---|---|
| agent/provider/aguiagent/agui.go | Marks AG-UI as not service-managing history so the agent keeps local history across turns despite ServiceID usage. |
| agent/provider/aguiagent/agui_test.go | Adds coverage to ensure multi-turn runs with the same session include full prior conversation history. |
| agent/agent.go | Introduces provider-level override (ServiceDoesNotManageHistory) and applies it to history-provider selection, storage, and conflict handling. |
Copilot's findings
Tip
Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Files reviewed: 3/3 changed files
- Comments generated: 0
Cross-repo parity review — PR #258Behavioral parity: ✅ aligned The upstream fix in microsoft/agent-framework#5904 and this Go port address exactly the same bug: the AGUI provider assigns a thread ID ( API approach divergence — worth noting The .NET and Go fixes solve the problem through different extension mechanisms:
The Go approach is more extensible: any provider that never delegates history to the service can set the flag rather than requiring the core agent to grow a new hardcoded provider-name check for each such provider. However, this introduces a new public exported field ( This divergence is intentional and Go-idiomatic — providers in Go are constructed via Python: No Python AGUI provider was found in No blocking parity issues. The behavioral fix is faithfully ported; the API shape difference is justified by the Go architecture and the flag name is self-documenting.
|
The AG-UI provider assigns a thread ID to the session on the first run by calling session.SetServiceID(threadID). The agent's history machinery interpreted any non-empty ServiceID as a signal that the service manages history server-side, and therefore disabled the local HistoryProvider for every subsequent run. This caused conversation history to be dropped after the first turn.
Add ServiceDoesNotManageHistory bool to ProviderConfig. Providers that never delegate history to the service (e.g. AGUI) set this flag true; the agent then preserves the HistoryProvider across runs regardless of whether the session has a ServiceID. This also prevents the provider from being flagged as a conflict when a user-configured HistoryProvider is present.
Set ServiceDoesNotManageHistory: true in the AGUI provider constructor.
Add TestAGUIAgentRun_WithSession_PreservesHistoryAcrossMultipleTurns to verify that the second run sends the full conversation history (3 messages) rather than only the new user message.
Ports behavior fix from microsoft/agent-framework#5904.