Skip to content

.NET: Workflow as Agent - unable to get any output from agent run. #2965

@antero-lukkonen

Description

@antero-lukkonen

Hi,

Unable to get output from a Node when running a workflow as an Agent.

System under test:
A dual node Workflow: ChatForwardingExecutor -> CustomExecutor.

CustomExecutor is handling List and is returning List. The expected output is a hardcoded string.

Observations:
Both executors run when debugging with breakpoints.

Expected Behavior:
AgentRunResponse.Text is filled with the output of CustomExecutor.

Actual Behavior:
AgentRunResponse.Text is empty string.
Also no AgentRunUpdateEvent is raised when i run in streaming mode.

Started trying the Workflow as Agent example in git repo. In this case the english and french agents produced messages and they were visinle in AgentRunResponse.Text. The final AggeragatingExecutor output was not.

After simplifying this example i arrived at a minimal repro:

Packages:

  <ItemGroup>
    <PackageReference Include="Azure.AI.OpenAI" Version="2.8.0-beta.1" />
    <PackageReference Include="Azure.Identity" Version="1.18.0-beta.2" />
    <PackageReference Include="Microsoft.Agents.AI.OpenAI" Version="1.0.0-preview.251204.1" />
    <PackageReference Include="Microsoft.Agents.AI.Workflows" Version="1.0.0-preview.251112.1" />
    <PackageReference Include="Microsoft.Extensions.AI.OpenAI" Version="10.1.1-preview.1.25612.2" />
  </ItemGroup>


namespace WorkflowAsAgentTests
{
    using Microsoft.Agents.AI.Workflows;
    using WorkflowAsAnAgentSample;

    public class UnitTest1
    {
        [Fact]
        public async Task WorkflowAsAgentOutput()
        {
            var result = await WorkflowFactory
                .BuildWorkflow()
                .AsAgent()
                .RunAsync("Some Input");

            Assert.NotNull(result);
            Assert.Equal("Expected Output", result.Text);
        }
    }
}

namespace WorkflowAsAnAgentSample;

using Microsoft.Agents.AI.Workflows;
using Microsoft.Extensions.AI;

internal static class WorkflowFactory
{
    internal static Workflow BuildWorkflow()
    {
        var startExecutor = new ChatForwardingExecutor("Start");
        var customExecutor = new CustomExecutor();
        return new WorkflowBuilder(startExecutor)
            .AddEdge(startExecutor, customExecutor)
            .WithOutputFrom(customExecutor)
            .Build();
    }

    private sealed class CustomExecutor() :
        Executor<List<ChatMessage>>("CustomExecutor")
    {
        public override async ValueTask HandleAsync(List<ChatMessage> message, IWorkflowContext context, CancellationToken cancellationToken = default)
        {
// Tried different things, like SendMessageAsync, also returning, raising an event, nothing helped.
            await context.YieldOutputAsync(new ChatMessage(ChatRole.Assistant, "Expected Output"));
            await context.SendMessageAsync(new TurnToken());
        }
    }
}




Metadata

Metadata

Assignees

Labels

.NETv1.0Features being tracked for the version 1.0 GAworkflowsRelated to Workflows in agent-framework

Type

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions