Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

.NET: [Feature]: Expose a composable AG-UI hosting seam around session restore and agent execution

Open
#8,552 0 comments 0 reactions 1 assignee View on GitHub

Maintainers usually reply within 1 day

@javiercn is already working on this.

Since Sep 20, 2026.

Assessment

This issue has not been assessed yet.

Description

.NET ag-ui hosting

Summary

MapAGUIServer is a good default for the common one-agent / one-request flow, but production hosts sometimes need trusted application checks before session restore and application session initialization after restore but before agent execution.

The public lower-level pieces now make a custom route possible, but using them means effectively reproducing the lifecycle implemented by MapAGUIServer, which creates drift risk.

It would be useful to expose a supported composable hosting seam for this scenario rather than requiring consumers to copy the endpoint pipeline.

Current pipeline

The current ASP.NET Core AG-UI host effectively owns this sequence:

RunAgentInput
  -> ToChatRequestContext(...)
  -> AIHostAgent.GetOrCreateSessionAsync(...)
  -> RunStreamingAsync(...)
  -> AsChatResponseUpdatesAsync()
  -> AsAGUIEventStreamAsync(...)
  -> SSE
  -> AIHostAgent.SaveSessionAsync(...)

Production-host use case

In a multi-user application, a route may conceptually be:

POST /conversations/{conversationId}/runs

Before the untrusted AG-UI threadId is allowed to reach session storage, the host needs to:

  1. authenticate the caller;
  2. load and authorize the route-owned conversation/resource;
  3. verify lifecycle/revision state;
  4. validate a restricted RunAgentInput profile;
  5. acquire an application run lease.

After MAF restores or creates the AgentSession, but before the agent runs, the host may also need to bind trusted application state to that session.

For example:

authorize owned Conversation
  -> acquire run lease
  -> AIHostAgent.GetOrCreateSessionAsync
  -> BindConversation(session, conversationId)
  -> RunStreamingAsync
  -> save on successful framework completion
  -> release lease

ASP.NET middleware can help with ordinary authentication/authorization, but it does not provide a supported hook into the MAF session lifecycle after restore and before execution.

Current workaround

A custom endpoint can reproduce the built-in implementation using:

  • RunAgentInput.ToChatRequestContext(...)
  • AIHostAgent
  • AgentSessionStore / IsolationKeyScopedAgentSessionStore
  • ChatClientAgentRunOptions
  • AsChatResponseUpdatesAsync()
  • AsAGUIEventStreamAsync(...)
  • ASP.NET Core SSE results

That works, but now the application owns a copy of framework lifecycle behavior such as session-save timing, cancellation/error behavior, stream completion, and future AG-UI changes.

Desired direction

I am not proposing a specific API shape, but one of these would help:

  • a lower-level reusable AG-UI request runner used by MapAGUIServer;
  • pre-session / post-session hooks;
  • a builder/delegate model around session resolution and run execution;
  • or documented supported composition APIs that let a custom route reuse the complete native lifecycle without copying it.

The key requirement is the ability to run trusted application code:

before session lookup
after session restore/create
around the streamed run lifecycle

while keeping AG-UI conversion, MAF session semantics and SSE behavior framework-owned.

Related

  • #2988 — dynamic agent resolution
  • #5209 — public AG-UI conversion surface
  • #6152 — Hosting.Channels

#6152 looks relevant long-term, but existing Map* migration is explicitly outside its v1 scope.

Environment

  • Microsoft.Agents.AI: 1.22.0
  • Microsoft.Agents.AI.Harness: 1.22.0
  • Microsoft.Agents.AI.Hosting.AGUI.AspNetCore: 1.22.0-preview.260918.1
  • .NET 10
Code Sample

Language/SDK

.NET

Dominant language
Python
Stars
13.9k
Forks
2.4k
Avg merge
1d 15h
Merged PRs (30d)
440

Getting set up

Open in Codespaces

Starts the project's dev container in your browser, under your own GitHub account.

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.

More from microsoft/agent-framework

All issues in microsoft/agent-framework

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.