close
Skip to content

[dotnet-port] Preserve AGUI session history across multi-turn runs - #258

Merged
George Adams (gdams) merged 1 commit into
mainfrom
dotnet-port/agui-session-history-fix-aaccb6f14ccbd050
Jun 9, 2026
Merged

[dotnet-port] Preserve AGUI session history across multi-turn runs#258
George Adams (gdams) merged 1 commit into
mainfrom
dotnet-port/agui-session-history-fix-aaccb6f14ccbd050

Conversation

@qmuntal

Copy link
Copy Markdown
Member

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.

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>
Copilot AI review requested due to automatic review settings June 9, 2026 11:24
@qmuntal
Quim Muntal (qmuntal) requested a review from a team as a code owner June 9, 2026 11:24

Copilot AI 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 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 ServiceDoesNotManageHistory to agent.ProviderConfig and thread it into the agent’s history selection / conflict logic.
  • Set ServiceDoesNotManageHistory: true for the AG-UI provider so local history is preserved even when Session.ServiceID is 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

@github-actions

github-actions Bot commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

Cross-repo parity review — PR #258

Behavioral 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 (ServiceID) to the session on the first run, which was previously misread as "service manages history server-side," causing local history to be dropped on subsequent turns. Both ports fix this and add an equivalent two-turn regression test.


API approach divergence — worth noting

The .NET and Go fixes solve the problem through different extension mechanisms:

.NET (PR #5904) Go (this PR)
Mechanism Private constant AGUIProviderName = "ag-ui" + private IsAGUIProviderName() helper inside ChatClientAgent.cs New public exported field ServiceDoesNotManageHistory bool on ProviderConfig
Scope Hardcoded per provider name, entirely internal Generic opt-in flag, set by any provider implementation
Public API change None Yes — new exported field on ProviderConfig

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 (ProviderConfig.ServiceDoesNotManageHistory) that has no direct counterpart in the .NET public surface.

This divergence is intentional and Go-idiomatic — providers in Go are constructed via ProviderConfig rather than via a named string matched inside a monolithic agent type. The semantic contract is the same; only the extension point differs. If .NET later adds more providers with the same "caller supplies full history" behavior, they may want to revisit the hardcoded IsAGUIProviderName approach in favor of something analogous to this Go flag.

Python: No Python AGUI provider was found in python/packages/; this fix is .NET/Go-specific.


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.

Generated by Go API Consistency Review Agent for issue #258 · ● 2.4M ·

@gdams
George Adams (gdams) merged commit 716c391 into main Jun 9, 2026
17 checks passed
@gdams
George Adams (gdams) deleted the dotnet-port/agui-session-history-fix-aaccb6f14ccbd050 branch June 9, 2026 11:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[dotnet-port] Preserve AGUI session history across multi-turn runs

3 participants