Skip to content

Python: [Bug]: WorkflowAgent drops response metadata when streaming an AgentResponse output #8463

Closed

Description

Description

When a workflow executor emits a message-bearing AgentResponse and the workflow is consumed through Workflow.as_agent().run(stream=True), WorkflowAgent converts the response messages into AgentResponseUpdate objects but silently drops response-level metadata that the update type can represent:

  • agent_id
  • finish_reason
  • continuation_token
  • additional_properties

Actual behavior: the message content is preserved, but all four fields are None on the generated update.

Expected behavior: converting a message-bearing AgentResponse to streaming updates should preserve representable response-level metadata without changing message count or ordering.

Code Sample

import asyncio
from typing import Never

from agent_framework import (
    AgentResponse,
    Message,
    WorkflowBuilder,
    WorkflowContext,
    executor,
)


@executor
async def emit_response(
    _messages: list[Message],
    ctx: WorkflowContext[Never, AgentResponse],
) -> None:  # type: ignore[valid-type]
    await ctx.yield_output(
        AgentResponse(
            messages=[Message(role="assistant", contents=["payload"])],
            agent_id="source-agent",
            finish_reason="length",
            continuation_token={"token": "resume-token"},
            additional_properties={"provider_marker": "preserve-me"},
        )
    )


async def main() -> None:
    workflow = WorkflowBuilder(start_executor=emit_response).build()
    updates = [
        update
        async for update in workflow.as_agent("wrapped-workflow").run(
            "hello",
            stream=True,
        )
    ]

    update = updates[0]
    print(
        {
            "agent_id": update.agent_id,
            "finish_reason": update.finish_reason,
            "continuation_token": update.continuation_token,
            "additional_properties": update.additional_properties,
        }
    )


asyncio.run(main())

Error Messages / Stack Traces

No exception is raised.

On current main, the output is:

{'agent_id': None, 'finish_reason': None, 'continuation_token': None, 'additional_properties': None}

Package Versions

agent-framework-core: local source from main at 0275ebfd026e3549b9377788aedb58f424997fb2

Python Version

Python 3.11.14

Additional Context

#7952 reported the equivalent metadata loss for the neighboring AgentResponseUpdate reconstruction branch. #7999 fixed that branch by preserving these fields and explicitly identified the AgentResponse branch as possible follow-up scope.

Existing workflow-agent tests cover streaming message content from an AgentResponse, but do not cover response metadata preservation on that conversion path.

Activity

  1. added
    pythonUsage: [Issues, PRs], Target: Python
    triageUsage: [Issues], Target: All issues that still need to be triaged
    on Sep 17, 2026
  2. added
    reproducedUsage: [Issues], Target: all issues that can be reproduced by the triage workflow
    on Sep 17, 2026
  3. github-actions commented on Sep 17, 2026

    @github-actions
    Contributor

    🤖 Automated triage reproduction notes (agent-authored — trust but verify)

    Agent analysis

    Repro: python/packages/core/agent_framework/_workflows/_agent.py::_convert_workflow_event_to_agent_response_updates drops response metadata in the AgentResponse branch at lines 672-688. It occurs when a forwarded workflow event contains a message-bearing AgentResponse with agent_id, finish_reason, continuation_token, or additional_properties. Minimal repro: yield such a response from an executor, consume workflow.as_agent().run(stream=True), and inspect the generated updates.

    • Failing test: python/packages/core/tests/workflow/test_workflow_agent.py::TestWorkflowAgent::test_workflow_as_agent_stream_preserves_agent_response_metadata
    • Files examined: python/packages/core/agent_framework/_workflows/_agent.py, python/packages/core/tests/workflow/test_workflow_agent.py, python/packages/core/pyproject.toml
    • Tests run: TestWorkflowAgent::test_workflow_as_agent_stream_preserves_agent_response_metadata, TestWorkflowAgent::test_workflow_as_agent_stream_preserves_response_update_metadata
    • Current version: 1.18.0
  4. added
    workflowsUsage: [Issues, PRs], Target: Workflows
    and removed
    triageUsage: [Issues], Target: All issues that still need to be triaged
    on Sep 17, 2026
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: PythonreproducedUsage: [Issues], Target: all issues that can be reproduced by the triage workflowworkflowsUsage: [Issues, PRs], Target: Workflows

Type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions