microsoft / microsoft/agent-framework

.NET: [Bug]: AG-UI endpoint sends duplicate conversation messages to providers

Open
#7,930 0 comments 0 reactions 1 assignee View on GitHub

@javiercn is already working on this.

Since Aug 28, 2026.

.NET
Dominant language
Python
Stars
13.6k
Forks
2.3k
Avg merge
2d 45m
Merged PRs (30d)
358

Description

### Description

When an AG-UI client sends the full chat history on every turn, `MapAGUIServer` (`AGUIEndpointRouteBuilderExtensions`) forwards `RunAgentInput.Messages` (full chat history) together with the session - which was restored from the session store and already carries the previous turns, either as locally persisted chat history or as a provider conversation id - to the underlying agent. As a result, duplicates are sent to the inference service/model regardless of whether provider storage is enabled or disabled.

**Provider storage disabled (`store = false`)**

The session keeps chat history locally. On each turn the agent loads the persisted chat history from the session and prepends it to the incoming messages. Because the incoming messages are the full chat history from the AG-UI client and the session already contains the previous messages, every earlier message appears twice in the request sent to the model. That merged, already-duplicated list is then written back into the session's chat history, so the duplication compounds on every subsequent turn.

**Provider storage enabled (`store = true`)**

The session is bound to a provider-side conversation, so local chat history is not used and only the incoming messages are sent. Since the incoming messages are the full chat history from the AG-UI client, all previously sent messages are re-submitted on each turn to a conversation that already contains them, and the provider appends them again.

In both cases the underlying model receives duplicated prior messages, which increases token usage and can degrade response quality.

### Package Versions

Microsoft.Agents.AI.Hosting.AGUI.AspNetCore (main)

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.