Skip to content

Python: [Bug]: WorkflowAgent drops merge_mode from streamed updates #10330

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 has merge_mode=None.
  • get_final_response().text returns draftfinal instead of final.
  • 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

  1. Run the script below against either source checkout listed under Package Versions.
  2. Emit two assistant updates with the same message ID, setting merge_mode="replace" on the second.
  3. Consume the workflow through .as_agent().run(stream=True) and finalize the stream.
  4. 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 at 6811ef8c7d83cf2949679f733aa15ac1bf290fe6.
  • Also reproduced with agent-framework-core 1.25.0: editable source at 30285709c1d60736a9b8b8ad87cd4f94a3719f6a.

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 an AgentResponseUpdate.
  • #8463 / #8464
    addressed metadata when converting a complete AgentResponse into 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.

Activity

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

    @github-actions
    Contributor

    Reproduced on current main (c7e50cc) using an independently written version of the minimal script: forwarded merge_mode values were [None, None] and the final text was draftfinal. _workflows/_agent.py has no merge_mode handling 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

    Generated by Issue Routing for #10330 · copilot · auto · ~22 AIC · ⌖ ~1 AIC · ⊞ 5.2K · ◷

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

agentsUsage: [Issues, PRs], Target: Single agentpythonUsage: [Issues, PRs], Target: PythonreproducedUsage: [Issues], Target: all issues that can be reproduced by the triage workflowtriageUsage: [Issues], Target: All issues that still need to be triagedworkflowsUsage: [Issues, PRs], Target: Workflows

Type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions