Skip to content

Python: Can't reproduce the result of sample #3279

@lisngt

Description

@lisngt

Hi all,

I would like to follow this example and try to reproduce the same result but it's not possible.

https://github.com/microsoft/agent-framework/blob/main/python/samples/getting_started/workflows/_start-here/step2_agents_in_a_workflow.py

I try with the similar code but the Workflow hat final state of IDLE and therefore the outputs are blank.

import asyncio
from agent_framework import AgentRunEvent, ChatAgent, WorkflowBuilder
from agent_framework.openai import OpenAIChatClient
import os
from dotenv import load_dotenv
from agent_framework.azure import AzureOpenAIChatClient

load_dotenv()


async def main():

    client = AzureOpenAIChatClient(
        api_key=os.getenv("FOUNDRY_APIKEY"),
        endpoint=os.getenv("FOUNDRY_ENDPOINT"),
        api_version="2024-12-01-preview",
        deployment_name="gpt-5-mini"
    )

    writer_agent = client.as_agent(
        instructions="You are an excellent content writer. You create new content and edit contents based on the feedback.",
        name="writer",
    )

    reviewer_agent = client.as_agent(
        instructions=(
            "You are an excellent content reviewer."
            "Provide actionable feedback to the writer about the provided content."
            "Provide the feedback in the most concise manner possible."
        ),
        name="reviewer",
    )

    workflow = (
        WorkflowBuilder()
        .set_start_executor(writer_agent)
        .add_edge(writer_agent, reviewer_agent)
        .build()
    )
    events = await workflow.run(
        "Create one (only one) slogan for a new electric SUV that is affordable and fun to drive."
    )

    for event in events:
        if isinstance(event, AgentRunEvent):
            print(f"{'='*60})")
            print(f"{event.executor_id}:{event.data}")

    print(f"{'='*60}\nWorkflow Outputs:{events.get_outputs()}")
    print("Final State:", events.get_final_state())


if __name__ == "__main__":
    asyncio.run(main())

Image

I'm not sure if I do anything wrong or the framework has changed his behavior and therefore the sample is not updated anymore?

I use Microsoft Agent Framework version: 1.0.0b260116

Thank you.
Regards

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingpythonv1.0Features being tracked for the version 1.0 GAworkflowsRelated to Workflows in agent-framework

Type

No fields configured for Bug.

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions