Skip to content

.NET: Sync AG-UI conversation history from backend #2510

Closed

Description

@Kermittt

We're creating a thin web client so we want to store message history in the backend, and send it to the client on initial connection. I don't see any support anywhere for MESSAGE_SNAPSHOT events so I attempted to implement it in agent middleware by creating and managing an AgentThread. The theory is I could just pass some flag from the frontend which would skip the normal agent run in the middleware and retrieve and emit the thread messages as a snapshot instead. This all worked well up till the point that I realised that there is no MessageSnapshotEvent and so AsAGUIEventStreamAsync can never emit a message snapshot, and all that stuff is internal so there appears to be no way to define or emit some other AGUI event at all.

Do you have a plan to add message snapshot support at some point, or are you ever going to provide a way to more directly emit the AG UI events?

Activity

  1. added
    .NETUsage: [Issues, PRs], Target: .Net
    triageUsage: [Issues], Target: All issues that still need to be triaged
    on Nov 28, 2025
  2. added and removed
    triageUsage: [Issues], Target: All issues that still need to be triaged
    on Nov 28, 2025
  3. javiercn commented on Nov 28, 2025

    @javiercn
    Contributor

    Nathan Keir (@Kermittt) thanks for contacting us.

    Yes, this is a current limitation as we work through how we want to best expose AG-UI concepts.

  4. Kermittt commented on Dec 2, 2025

    @Kermittt
    Author

    Also, other little things like message timestamps... Ultimately I think it's fine if Agent Framework chooses not to support these (which it doesn't seem to currently) but it would be great if we had a way to add things like this ourselves if we deem them necessary. I think this falls into the same category of more direct control over the AG-UI events as described above.

  5. imranshams commented on Dec 2, 2025

    @imranshams

    Hey Javier Calvarro Nelson (@javiercn),

    I had the same problem, it will be great if at the end we could have a sample in Repo which demonstrate how to implement chat-history with AG-UI Frameworks like Copilotkit in C#.

  6. javiercn commented on Aug 18, 2026

    @javiercn
    Contributor

    Backend-to-client message synchronization is now supported through the public MessagesSnapshotEvent in AGUI.Abstractions.

    A delegating agent can load its authoritative history and emit it directly:

    yield return new AgentResponseUpdate(new ChatResponseUpdate
    {
        Role = ChatRole.Assistant,
        RawRepresentation = new MessagesSnapshotEvent
        {
            Messages = history.AsAGUIMessages().ToList(),
        },
    });

    The current AG-UI conversion pipeline forwards this event unchanged:

    RUN_STARTED
    MESSAGES_SNAPSHOT
    RUN_FINISHED
    

    We verified that message IDs, roles, authors, and ordering are preserved.

    Hosting does not automatically infer which store represents an application's authoritative history. The application loads that history from its ChatHistoryProvider, session store, or database and emits the snapshot at the appropriate synchronization point.

    Since MessagesSnapshotEvent and direct public event emission are now available, this issue can be closed as resolved.

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

Metadata

Metadata

Labels

.NETUsage: [Issues, PRs], Target: .Netag-uiUsage: [Issues, PRs], Target: AG-UI protocol integration

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions