.NET: Workflow.AsAIAgent drops a terminal executor's ChatMessage output unless includeWorkflowOutputsInResponse is set
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
- 难度
- 2/5
- 预计耗时
- 1-3 小时
- 新手友好度
- 66/100
- Issue 类型
- 缺陷
- 描述清晰度
- 描述清楚
- 活跃度
- 活跃
- 技术栈
- csharp
调研方向
从 WorkflowSession.cs 中的 WorkflowOutputEvent 分支开始,比较终端输出的 updateContents 和 updateMessages 是如何转发的。使用提供的基于文件的 .NET 1.25.0 应用复现问题,然后检查返回 List<ChatMessage> 的终端执行器在 includeWorkflowOutputsInResponse 为 false 时是否会流式传输回复,正如字符串情况已经做到的那样。
由索引模型根据 Issue 内容生成。
描述
Description
When a workflow is hosted with Workflow.AsAIAgent(...) and includeWorkflowOutputsInResponse is left at its default (false), an executor designated with WithOutputFrom(...) reaches the agent response only if its output is a string or AIContent. The same executor yielding a ChatMessage or IEnumerable<ChatMessage> produces no update at all: the stream carries only an observability update for the WorkflowOutputEvent.
In WorkflowSession.cs (1.25.0, unchanged on main as of 2026-10-26), the WorkflowOutputEvent case computes includeTerminalOutput = this._workflow.IsTerminalOutput(output.ExecutorId) and then:
- forwards
updateContentswhen_includeWorkflowOutputsInResponse || includeTerminalOutput; - forwards
updateMessagesonly when_includeWorkflowOutputsInResponse.
The comment above that block says response-compatible payloads are forwarded "when the host requests all workflow outputs, or when this executor is an explicit output source for the workflow", so the two branches disagree with it. The same gap was pointed out in an automated review comment on #6212, which introduced the terminal-output path.
Since #8020 the hosted AddAsAIAgent() sets includeWorkflowOutputsInResponse: true, so this shows up only when Workflow.AsAIAgent is called directly, for example to pass an execution environment (#9370).
Steps to reproduce
File-based app (dotnet run repro.cs), Microsoft.Agents.AI.Workflows 1.25.0. The same terminal executor is bound twice, once returning List<ChatMessage> and once returning string, each marked with WithOutputFrom:
#:package [email protected]
#pragma warning disable MAAIW001, MAAI001
using Microsoft.Agents.AI;
using Microsoft.Agents.AI.Workflows;
using Microsoft.Extensions.AI;
static string Last(List<ChatMessage> m) => m.LastOrDefault(x => x.Role == ChatRole.User)?.Text ?? "";
Func<List<ChatMessage>, List<ChatMessage>> asMessages = m => [new(ChatRole.Assistant, $"echo: {Last(m)}")];
Func<List<ChatMessage>, string> asString = m => $"echo: {Last(m)}";
foreach (var (label, answer) in new (string, ExecutorBinding)[]
{
("List<ChatMessage>", asMessages.BindAsExecutor("Answer", threadsafe: true)),
("string", asString.BindAsExecutor("Answer", threadsafe: true)),
})
{
ExecutorBinding start = new Start();
var workflow = new WorkflowBuilder(start).AddEdge(start, answer).WithOutputFrom(answer).Build();
var agent = workflow.AsAIAgent(name: "repro");
var text = "";
await foreach (var u in agent.RunStreamingAsync("hi")) text += u.Text;
Console.WriteLine($"{label,-18} streamed text: \"{text}\"");
}
sealed class Start() : ChatProtocolExecutor("Start", new ChatProtocolExecutorOptions { AutoSendTurnToken = false })
{
protected override ValueTask TakeTurnAsync(List<ChatMessage> messages, IWorkflowContext context, bool? emitEvents, CancellationToken cancellationToken = default)
=> context.SendMessageAsync(messages, cancellationToken);
}
Actual behavior
List<ChatMessage> streamed text: ""
string streamed text: "echo: hi"
In our app (behind the AG-UI server) a branch that answered with a List<ChatMessage> reached the client as RUN_STARTED followed directly by RUN_FINISHED, with no text message, so the user saw an empty reply.
Expected behavior
An executor designated with WithOutputFrom(...) reaches the agent response whatever its payload type, a ChatMessage or a list of them included, as its string and AIContent outputs already do.
Versions
- Microsoft.Agents.AI.Workflows 1.25.0 (.NET 10)
- Same code path on
main(commit at time of writing)
- 主要语言
- Python
- 星标
- 14.3k
- 派生
- 2.5k
- 平均合并
- 2 天 19 小时
- 30 天内合并 PR
- 382
环境准备
在浏览器里用你自己的 GitHub 账号启动这个项目的开发容器。
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
microsoft/agent-framework 的其他 Issue
-
Python: [Bug]: native Windows --files paths skip changed-package tasks可能已有人在做 @leilei3167 于 1 天前认领。 未关闭needs-maintainer-triage python triage
难度 2/5 1-3 小时 新手友好度 76/100
microsoft/agent-framework#9742 · 3 条评论 ·
维护者通常 1 天内回复
-
Python: FileSessionStore.set fails on Windows for long session IDs because its temp file name is 38 characters longer than the snapshot可能已有人在做 @Sonica-B 于 2 天前认领。 未关闭python ready-for-implementation
难度 2/5 1-3 小时 新手友好度 78/100
microsoft/agent-framework#9682 · 已指派 2 人 ·
维护者通常 1 天内回复
-
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 · 3 条评论 ·
维护者通常 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 于 29 天前认领,目前没有进行中的 PR。 未关闭python triage
难度 2/5 1-3 小时 新手友好度 78/100
microsoft/agent-framework#8632 · 2 条评论 ·
维护者通常 1 天内回复
查看 microsoft/agent-framework 的全部 Issue
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 65/100
维护者通常 1 天内回复
-
[oblt-aw][autodoc] Document obs-aw-automerge contract and fix automerge doc inconsistencies可能已有人在做 @github-actions 今天认领。 未关闭
难度 2/5 1-3 小时 新手友好度 76/100
维护者通常 1 天内回复
-
admission-deferred priority: medium status: ready work-class: scoped
难度 2/5 1-3 小时 新手友好度 70/100
melodic-software/claude-code-plugins#10887 · 4 条评论 ·
维护者通常 1 天内回复
-
backend bug good first issue
难度 2/5 1-3 小时 新手友好度 70/100
PoCInnovation/Distribox#255 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 72/100
google/langextract#598 ·
维护者通常 1 天内回复