.NET: [Feature]: Expose a composable AG-UI hosting seam around session restore and agent execution
维护者通常 1 天内回复
@javiercn 已经在做这个了。
开始于 2026年9月20日。
评估
这个 Issue 还没有评估数据。
描述
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
- 主要语言
- Python
- 星标
- 14.2k
- 派生
- 2.5k
- 平均合并
- 2 天 9 小时
- 30 天内合并 PR
- 392
环境准备
在浏览器里用你自己的 GitHub 账号启动这个项目的开发容器。
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
microsoft/agent-framework 的其他 Issue
-
Python: foundry-hosting drops request `metadata` from the stored response — `_create_response_event_stream` never passes `request` to `ResponseEventStream`可能已有人在做 @its-amann 于 2 天前认领。 未关闭python triage
难度 2/5 1-3 小时 新手友好度 78/100
microsoft/agent-framework#9529 · 1 条评论 ·
维护者通常 1 天内回复
-
Python: [Bug]: A non-positive MCP request timeout silently disables the timeout可能已有人在做 @jpalvarezl 于 8 天前认领。 未关闭python
难度 2/5 1-3 小时 新手友好度 82/100
microsoft/agent-framework#9313 · 已指派 1 人 ·
维护者通常 1 天内回复
-
.NET python triage
难度 1/5 1 小时以内 新手友好度 85/100
microsoft/agent-framework#9092 · 1 条评论 ·
维护者通常 1 天内回复
-
Python: raw-data content mappings lose annotations and attachment metadata可能已有人在做 @moonbox3 于 22 天前认领。 未关闭python triage
难度 2/5 1-3 小时 新手友好度 78/100
microsoft/agent-framework#8632 · 2 条评论 ·
维护者通常 1 天内回复
-
Python: Clarify when to use platform可能已有人在做 @eavanvalkenburg 于 21 天前认领。 未关闭python triage
难度 2/5 1-3 小时 新手友好度 68/100
microsoft/agent-framework#8599 · 1 条评论 ·
维护者通常 1 天内回复
查看 microsoft/agent-framework 的全部 Issue
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 66/100
-
[Bug]: Queen's own Ollama model loses num_ctx when a running session switches to it可能已有人在做 @anasamin26 今天认领。 未关闭bug enhancement
难度 2/5 1-3 小时 新手友好度 78/100
维护者通常 1 天内回复
-
llm translation
难度 2/5 1-3 小时 新手友好度 78/100
BerriAI/litellm#47884 · 1 条评论 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 78/100
维护者通常 1 天内回复
-
bug 🐛
难度 2/5 1-3 小时 新手友好度 72/100
netalertx/NetAlertX#1856 · 1 个 reaction ·
维护者通常 1 天内回复