Skip to content

Python: Dev UI does not show the output of each agent in concurrent workflow correctly #2351

@tsuting

Description

@tsuting

Description

When running a concurrent workflow in the development UI, all agent messages are shown under the last executed agent. The messages are mixed together, combining responses from different agents instead of keeping them separate.

Image

Script to Reproduce

Modified from https://github.com/microsoft/agent-framework/blob/main/python/samples/getting_started/workflows/orchestration/concurrent_custom_aggregator.py

# Copyright (c) Microsoft. All rights reserved.
from agent_framework import ConcurrentBuilder, ChatMessage, Role
from agent_framework.azure import AzureOpenAIChatClient
from azure.identity import AzureCliCredential
from agent_framework.observability import setup_observability
from agent_framework.devui import serve
from typing import Any

setup_observability()


def main() -> None:
    chat_client = AzureOpenAIChatClient(credential=AzureCliCredential())

    researcher = chat_client.create_agent(
        instructions=(
            "You're an expert market and product researcher. Given a prompt, provide concise, factual insights,"
            " opportunities, and risks."
        ),
        name="researcher",
    )
    marketer = chat_client.create_agent(
        instructions=(
            "You're a creative marketing strategist. Craft compelling value propositions and target messaging"
            " aligned to the prompt."
        ),
        name="marketer",
    )
    legal = chat_client.create_agent(
        instructions=(
            "You're a cautious legal/compliance reviewer. Highlight constraints, disclaimers, and policy concerns"
            " based on the prompt."
        ),
        name="legal",
    )

    # Define a custom aggregator callback that uses the chat client to summarize
    async def summarize_results(results: list[Any]) -> str:
        # Extract one final assistant message per agent
        expert_sections: list[str] = []
        for r in results:
            try:
                messages = getattr(r.agent_run_response, "messages", [])
                final_text = messages[-1].text if messages and hasattr(
                    messages[-1], "text") else "(no content)"
                expert_sections.append(
                    f"{getattr(r, 'executor_id', 'expert')}:\n{final_text}")
            except Exception as e:
                expert_sections.append(
                    f"{getattr(r, 'executor_id', 'expert')}: (error: {type(e).__name__}: {e})")

        # Ask the model to synthesize a concise summary of the experts' outputs
        system_msg = ChatMessage(
            Role.SYSTEM,
            text=(
                "You are a helpful assistant that consolidates multiple domain expert outputs "
                "into one cohesive, concise summary with clear takeaways. Keep it under 200 words."
            ),
        )
        user_msg = ChatMessage(Role.USER, text="\n\n".join(expert_sections))

        response = await chat_client.get_response([system_msg, user_msg])
        # Return the model's final assistant text as the completion result
        return response.messages[-1].text if response.messages else ""

    workflow = (
        ConcurrentBuilder().participants(
            [researcher, marketer, legal]).with_aggregator(summarize_results).build()
    )

    serve(entities=[workflow], port=7860, auto_open=True)


if __name__ == "__main__":
    main()

Expected Behavior

Each agent’s messages should be displayed under its own section or context, clearly separated from other agents’ responses.

Actual Behavior

Messages from multiple agents are combined and shown under the last executed agent, resulting in confusion and incorrect responses.

Version

  • agent-framework 1.0.0b251114
  • agent-framework-a2a 1.0.0b251114
  • agent-framework-ag-ui 1.0.0b251117
  • agent-framework-anthropic 1.0.0b251114
  • agent-framework-azure-ai 1.0.0b251114
  • agent-framework-azurefunctions 1.0.0b251114
  • agent-framework-chatkit 1.0.0b251114
  • agent-framework-copilotstudio 1.0.0b251114
  • agent-framework-core 1.0.0b251114
  • agent-framework-devui 1.0.0b251114
  • agent-framework-lab 1.0.0b251024
  • agent-framework-mem0 1.0.0b251114
  • agent-framework-purview 1.0.0b251114
  • agent-framework-redis 1.0.0b251114

Metadata

Metadata

Assignees

Labels

devuiDevUI-related itemspythonworkflowsRelated to Workflows in agent-framework

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions