Repository navigation
Description
Observed Behavior
When an executor emits an AgentResponseUpdate with merge_mode="replace", consuming the workflow through
workflow.as_agent().run(stream=True) drops the update's merge mode.
For two updates with the same message_id, containing draft followed by an authoritative final snapshot:
- The original second update has
merge_mode="replace", but the forwarded update hasmerge_mode=None. get_final_response().textreturnsdraftfinalinstead offinal.- With an
InMemoryHistoryProvider, the persisted assistant message also contains the stale text.
A separate local case including URI content retains both the old and replacement URI in the final response and
history. This is silent incorrect output, rather than a runtime exception.
Expected Behavior
Preserve the incoming update-level merge_mode when forwarding an AgentResponseUpdate.
The replacement should remove the earlier contents of the same logical message, leaving only final in this example.
This follows the existing content identity and protocol metadata contract.
Aggregating the original updates directly with AgentResponse.from_updates() already produces the expected result.
Steps to Reproduce
- Run the script below against either source checkout listed under Package Versions.
- Emit two assistant updates with the same message ID, setting
merge_mode="replace"on the second. - Consume the workflow through
.as_agent().run(stream=True)and finalize the stream. - Observe that the replacement flag is lost and the earlier text remains.
No model, credentials, database, or hosted service is required.
Minimal Reproduction
# Copyright (c) Microsoft. All rights reserved.
import asyncio
from typing import Never
from agent_framework import AgentResponseUpdate, Content, Message, WorkflowBuilder, WorkflowContext, executor
@executor
async def emit_snapshots(messages: list[Message], ctx: WorkflowContext[Never, AgentResponseUpdate]) -> None:
await ctx.yield_output(
AgentResponseUpdate(contents=[Content.from_text("draft")], role="assistant", message_id="m1")
)
await ctx.yield_output(
AgentResponseUpdate(
contents=[Content.from_text("final")], role="assistant", message_id="m1", merge_mode="replace"
)
)
async def main() -> None:
workflow = WorkflowBuilder(start_executor=emit_snapshots, output_from=[emit_snapshots]).build()
stream = workflow.as_agent().run("hello", stream=True)
updates = [update async for update in stream]
response = await stream.get_final_response()
print("forwarded modes:", [update.merge_mode for update in updates])
print("final text:", response.text)
assert response.text == "final"
asyncio.run(main())Error Messages and Stack Traces
The unmodified source produces:
forwarded modes: [None, None]
final text: draftfinal
The final assertion in the reproduction raises AssertionError. Without that assertion, the workflow completes
successfully with the incorrect response.
Package Versions
agent-framework-core 1.26.0: editable source at6811ef8c7d83cf2949679f733aa15ac1bf290fe6.- Also reproduced with
agent-framework-core 1.25.0: editable source at30285709c1d60736a9b8b8ad87cd4f94a3719f6a.
Python Version
Python 3.12.12.
Operating System
macOS, Apple Silicon (arm64).
Regression
Unknown.
Additional Context
The AgentResponseUpdate reconstruction in
WorkflowAgent._convert_workflow_event_to_agent_response_updates()
copies the message identity and other metadata, but omits merge_mode.
Related earlier work covers different fields or input types:
- #7952 / #7999
restored other metadata when forwarding anAgentResponseUpdate. - #8463 / #8464
addressed metadata when converting a completeAgentResponseinto updates.
This report concerns update-level replacement intent, which is still lost on the current forwarding path.
I have reproduced this locally and prepared a minimal candidate patch with regression coverage for text and URI
content in the core final response and session history. I would like to contribute this fix. Given the planned
vNext removal in #8949, would this be a welcome
maintenance change for the current API?
Scope: this report concerns core update forwarding and aggregation. Separate local checks found that the outbound
A2A, AG-UI, Foundry Hosting, and DevUI converters still accumulate the two text snapshots before and after this
candidate; preserving the field in core does not by itself implement replacement in those protocol converters.
AI assistance: Codex assisted with duplicate research, local reproduction, diagnosis, regression tests, and this
report. The reproductions were executed locally against the source checkouts listed above.
Acknowledgements
- I searched existing issues and did not find a duplicate.
- I personally verified this behavior and the reproduction details are authentic.
- I will wait for explicit maintainer agreement before starting implementation of a non-trivial change.
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsNo status
Activity
github-actions commentedon Nov 13, 2026
Reproduced on current
main(c7e50cc) using an independently written version of the minimal script: forwardedmerge_modevalues were[None, None]and the final text wasdraftfinal._workflows/_agent.pyhas nomerge_modehandling when rebuilding the update.Support boundary: direct support. The reporter cites the content identity/protocol metadata spec (
docs/specs/005-...); I did not independently re-verify that spec text. Known-good version and regression status are unknown. Fix PR #10331 is open; I did not test it. Routed to the workflows owner; priority and scope are for maintainers.Run: https://github.com/microsoft/agent-framework/actions/runs/43378220974