Skip to content

Python: WorkflowAgent created via .as_agent() does not emit outputs when using ctx.yield_output #2813

Closed

Description

@VanQuy24

High-level description

When building a workflow based on multiple executors and then converting it into an agent using .as_agent(), calls to ctx.yield_output() inside an executor do not produce any output.
The same workflow, when executed directly (without .as_agent()), correctly yields output messages.

Expected behavior

ctx.yield_output() inside a workflow executor should emit output messages even when the workflow is wrapped using .as_agent().
The Workflow Agent should behave consistently with the direct workflow execution: each yield_output call should surface as an agent message/output event.

Actual behavior

When the workflow is executed through the agent returned by .as_agent(), the yield_output calls produce no visible output.
There is no error — the output simply does not appear.
Only the final aggregated result of the workflow is returned, and intermediate yielded messages are ignored.

Minimal reproduction

from typing import List
from agent_framework import WorkflowBuilder, executor, WorkflowContext, ChatMessage

@executor
async def my_executor(text: str | List[ChatMessage], ctx: WorkflowContext):
    await ctx.yield_output(f"processing: {text}")


async def main():
    workflow = (
        WorkflowBuilder()
        .set_start_executor(my_executor)
        .build()
    )

    print("Running workflow...")
    result = await workflow.run("hello from workflow")
    print("Workflow result:", result)

    print("\nRunning as agent...")
    agent = workflow.as_agent("wf-agent")
    result = await agent.run("hello from agent")
    print("WorkflowAgent result:", result)

    print("END")


if __name__ == "__main__":
    import asyncio
    asyncio.run(main())


# Expected:
# Running workflow...
# Workflow result: [ExecutorInvokedEvent(executor_id=my_executor, data=None), WorkflowOutputEvent(data=processing: hello from workflow, source_executor_id=my_executor), ExecutorCompletedEvent(executor_id=my_executor, data=None)]

# Running as agent...
# WorkflowAgent result: [ExecutorInvokedEvent(executor_id=my_executor, data=None), WorkflowOutputEvent(data=processing: hello from workflow, source_executor_id=my_executor), ExecutorCompletedEvent(executor_id=my_executor, data=None)]
# END


# Actual:
# Running workflow...
# Workflow result: [ExecutorInvokedEvent(executor_id=my_executor, data=None), WorkflowOutputEvent(data=processing: hello from workflow, source_executor_id=my_executor), ExecutorCompletedEvent(executor_id=my_executor, data=None)]

# Running as agent...

# END

Environment

  • Agent Framework version: 1.0.0b251114
  • Runtime: Python 3.10.19
  • OS: Windows 10 / Linux / macOS
  • Execution: Local development environment

Activity

  1. added
    workflowsUsage: [Issues, PRs], Target: Workflows
    and removed
    triageUsage: [Issues], Target: All issues that still need to be triaged
    on Dec 12, 2025
  2. moved this from Planned to In Progress in Agent Frameworkon Dec 15, 2025
  3. moved this from In Progress to In Review in Agent Frameworkon Dec 15, 2025
  4. moved this from In Review to Done in Agent Frameworkon Dec 16, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

pythonUsage: [Issues, PRs], Target: PythonworkflowsUsage: [Issues, PRs], Target: Workflows

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions