microsoft / microsoft/agent-framework
Python: [Bug]: WorkflowAgent drops response metadata when streaming an AgentResponse output
@eavanvalkenburg is already working on this.
Since Sep 17, 2026.
- Dominant language
- Python
- Stars
- 13.6k
- Forks
- 2.3k
- Avg merge
- 2d 45m
- Merged PRs (30d)
- 358
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
```python
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:
```text
{'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](https://github.com/microsoft/agent-framework/issues/7952) reported the equivalent metadata loss for the neighboring `AgentResponseUpdate` reconstruction branch. [#7999](https://github.com/microsoft/agent-framework/pull/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.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.