.NET: [Feature]: Expose a composable AG-UI hosting seam around session restore and agent execution
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
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:
- authenticate the caller;
- load and authorize the route-owned conversation/resource;
- verify lifecycle/revision state;
- validate a restricted
RunAgentInputprofile; - 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(...)AIHostAgentAgentSessionStore/IsolationKeyScopedAgentSessionStoreChatClientAgentRunOptionsAsChatResponseUpdatesAsync()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.0Microsoft.Agents.AI.Harness: 1.22.0Microsoft.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
Starts the project's dev container in your browser, under your own GitHub account.
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from microsoft/agent-framework
-
Python: declarative Search() treats a falsy value (0, 0.0, False) as Blank and returns every rowPossibly taken @Lesereingrape claimed this 2 days ago. Openpython triage
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
microsoft/agent-framework#8973 ·
Maintainers usually reply within 1 day
-
Python: raw-data content mappings lose annotations and attachment metadataPossibly taken @moonbox3 claimed this 4 days ago. Openpython triage
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
microsoft/agent-framework#8632 · 2 comments ·
Maintainers usually reply within 1 day
-
Python: Clarify when to use platformPossibly taken @eavanvalkenburg claimed this 4 days ago. Openpython triage
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
microsoft/agent-framework#8599 · 1 comment ·
Maintainers usually reply within 1 day
-
.NET Compaction - Update docs to refer to `AIContextProvider` deep divePossibly taken A pull request linked to this issue is open or already merged. Open.NET compaction documentation
Difficulty 1/5 Under an hour Newbie friendliness 82/100
microsoft/agent-framework#4629 · 1 comment ·
Maintainers usually reply within 1 day
-
python triage
Difficulty 4/5 3-5 days Newbie friendliness 48/100
microsoft/agent-framework#9031 ·
Maintainers usually reply within 1 day
All issues in microsoft/agent-framework
Similar issues
-
namespace operations
Difficulty 1/5 Under an hour Newbie friendliness 72/100
EclipseFdn/open-vsx.org#13737 ·
Maintainers usually reply within 1 day
-
Zero-token evaluations are treated as missing cost in selectionPossibly taken @sylvesterkaczmarek claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
google-research/rrsi#6 ·
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
aws-samples/sample-aws-genai-db-modernizer#294 ·
Maintainers usually reply within 1 day
-
feedback simulation workshop
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
githubnext/gh-aw-workshop#4174 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
WingedGuardian/GENesis-AGI#2852 ·
Maintainers usually reply within 1 day