Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

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

未关闭
#8,552 0 条评论 0 个 reaction 已指派 1 人 在 GitHub 查看

维护者通常 1 天内回复

@javiercn 已经在做这个了。

开始于 2026年9月20日。

评估

这个 Issue 还没有评估数据。

描述

.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

主要语言
Python
星标
14.2k
派生
2.5k
平均合并
2 天 9 小时
30 天内合并 PR
392

环境准备

在 Codespaces 中打开

在浏览器里用你自己的 GitHub 账号启动这个项目的开发容器。

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

microsoft/agent-framework 的其他 Issue

查看 microsoft/agent-framework 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。