Hacktoberfest 2026: los issues que los mantenedores marcaron para octubre, abiertos y aptos para principiantes. Explorar issues de Hacktoberfest

.NET: Workflow.AsAIAgent drops a terminal executor's ChatMessage output unless includeWorkflowOutputsInResponse is set

Abierto Apto para principiantes
#9,704 2 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
2/5
Tiempo estimado
1-3 horas
Aptitud para principiantes
66/100
Tipo de issue
Error
Claridad
Bien especificado
Estado de actividad
Activo
Stack tecnológico
csharp

Línea de trabajo

Empieza en WorkflowSession.cs, en el caso WorkflowOutputEvent, y compara cómo se reenvían updateContents y updateMessages para las salidas del terminal. Reproduce el comportamiento con la aplicación basada en archivos de .NET 1.25.0 proporcionada y comprueba después que un ejecutor de terminal que devuelve List<ChatMessage> transmite su respuesta cuando includeWorkflowOutputsInResponse es false, como ya ocurre en el caso de string.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

.NET triage
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 updateContents when _includeWorkflowOutputsInResponse || includeTerminalOutput;
  • forwards updateMessages only 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)
Lenguaje dominante
Python
Estrellas
14.3k
Forks
2.5k
Merge medio
2 d 16 h
PR fusionados (30 d)
383

Preparar el entorno

Abrir en Codespaces

Inicia el contenedor de desarrollo del proyecto en tu navegador, con tu propia cuenta de GitHub.

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de microsoft/agent-framework

Todos los issues de microsoft/agent-framework

Issues similares

Más issues de Python

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.