Python: [BREAKING] updated structure and samples (#875)

* updated structure and samples

* updated names and removed cross tests

* updated projects etc

* updated tests

* updated test

* test fixes

* removed devui for now

* updated all-tests task

* removed old style configs

* remove coverage from tests

* updated to unit tests with all-tests

* updated foundry everywhere

* fix azure ai tests

* fix merge tests

* fix mypy
This commit is contained in:
Eduard van Valkenburg
2025-09-25 09:02:53 +02:00
committed by GitHub
Unverified
parent 366a7f7d47
commit 9355329dfd
169 changed files with 1159 additions and 1761 deletions
@@ -35,7 +35,7 @@ Once comfortable with these, explore the rest of the samples below.
|---|---|---|
| Azure Chat Agents (Streaming) | [agents/azure_chat_agents_streaming.py](./agents/azure_chat_agents_streaming.py) | Add Azure agents as edges and handle streaming events |
| Custom Agent Executors | [agents/custom_agent_executors.py](./agents/custom_agent_executors.py) | Create executors to handle agent run methods |
| Foundry Chat Agents (Streaming) | [agents/foundry_chat_agents_streaming.py](./agents/foundry_chat_agents_streaming.py) | Add Foundry agents as edges and handle streaming events |
| Azure AI Chat Agents (Streaming) | [agents/azure_ai_chat_agents_streaming.py](./agents/azure_ai_chat_agents_streaming.py) | Add Azure AI agents as edges and handle streaming events |
| Workflow as Agent (Reflection Pattern) | [agents/workflow_as_agent_reflection_pattern.py](./agents/workflow_as_agent_reflection_pattern.py) | Wrap a workflow so it can behave like an agent (reflection pattern) |
| Workflow as Agent + HITL | [agents/workflow_as_agent_human_in_the_loop.py](./agents/workflow_as_agent_human_in_the_loop.py) | Extend workflow-as-agent with human-in-the-loop capability |
@@ -119,9 +119,9 @@ concurrents dispatcher and aggregator and can be ignored if you only care abo
### Environment Variables
- **AzureChatClient**: Set Azure OpenAI environment variables as documented [here](https://github.com/microsoft/agent-framework/blob/main/python/samples/getting_started/chat_client/README.md#environment-variables).
These variables are required for samples that construct `AzureChatClient`
- **AzureOpenAIChatClient**: Set Azure OpenAI environment variables as documented [here](https://github.com/microsoft/agent-framework/blob/main/python/samples/getting_started/chat_client/README.md#environment-variables).
These variables are required for samples that construct `AzureOpenAIChatClient`
- **OpenAI** (used in orchestration samples):
- [OpenAIChatClient env vars](https://github.com/microsoft/agent-framework/blob/main/python/samples/getting_started/agents/openai_chat_client/README.md)
- **OpenAI** (used in orchestration samples):
- [OpenAIChatClient env vars](https://github.com/microsoft/agent-framework/blob/main/python/samples/getting_started/agents/openai_chat_client/README.md)
- [OpenAIResponsesClient env vars](https://github.com/microsoft/agent-framework/blob/main/python/samples/getting_started/agents/openai_responses_client/README.md)
@@ -3,7 +3,7 @@
import asyncio
from agent_framework import AgentRunEvent, WorkflowBuilder
from agent_framework.azure import AzureChatClient
from agent_framework.azure import AzureOpenAIChatClient
from azure.identity import AzureCliCredential
"""
@@ -13,12 +13,12 @@ This sample uses two custom executors. A Writer agent creates or edits content,
then hands the conversation to a Reviewer agent which evaluates and finalizes the result.
Purpose:
Show how to wrap chat agents created by AzureChatClient inside workflow executors. Demonstrate how agents
Show how to wrap chat agents created by AzureOpenAIChatClient inside workflow executors. Demonstrate how agents
automatically yield outputs when they complete, removing the need for explicit completion events.
The workflow completes when it becomes idle.
Prerequisites:
- Azure OpenAI configured for AzureChatClient with required environment variables.
- Azure OpenAI configured for AzureOpenAIChatClient with required environment variables.
- Authentication via azure-identity. Use AzureCliCredential and run az login before executing the sample.
- Basic familiarity with WorkflowBuilder, executors, edges, events, and streaming or non streaming runs.
"""
@@ -27,7 +27,7 @@ Prerequisites:
async def main():
"""Build and run a simple two node agent workflow: Writer then Reviewer."""
# Create the Azure chat client. AzureCliCredential uses your current az login.
chat_client = AzureChatClient(credential=AzureCliCredential())
chat_client = AzureOpenAIChatClient(credential=AzureCliCredential())
writer_agent = chat_client.create_agent(
instructions=(
"You are an excellent content writer. You create new content and edit contents based on the feedback."
@@ -2,8 +2,6 @@
import asyncio
from typing_extensions import Never
from agent_framework import (
ChatAgent,
ChatMessage,
@@ -17,8 +15,9 @@ from agent_framework import (
handler,
)
from agent_framework._workflow._events import WorkflowOutputEvent
from agent_framework.azure import AzureChatClient
from agent_framework.azure import AzureOpenAIChatClient
from azure.identity import AzureCliCredential
from typing_extensions import Never
"""
Step 3: Agents in a workflow with streaming
@@ -28,14 +27,14 @@ then passes the conversation to a Reviewer agent that finalizes the result.
The workflow is invoked with run_stream so you can observe events as they occur.
Purpose:
Show how to wrap chat agents created by AzureChatClient inside workflow executors, wire them with WorkflowBuilder,
Show how to wrap chat agents created by AzureOpenAIChatClient inside workflow executors, wire them with WorkflowBuilder,
and consume streaming events from the workflow. Demonstrate the @handler pattern with typed inputs and typed
WorkflowContext[T_Out, T_W_Out] outputs. Agents automatically yield outputs when they complete.
The streaming loop also surfaces WorkflowEvent.origin so you can distinguish runner-generated lifecycle events
from executor-generated data-plane events.
Prerequisites:
- Azure OpenAI configured for AzureChatClient with required environment variables.
- Azure OpenAI configured for AzureOpenAIChatClient with required environment variables.
- Authentication via azure-identity. Use AzureCliCredential and run az login before executing the sample.
- Basic familiarity with WorkflowBuilder, executors, edges, events, and streaming runs.
"""
@@ -51,8 +50,8 @@ class Writer(Executor):
agent: ChatAgent
def __init__(self, chat_client: AzureChatClient, id: str = "writer"):
# Create a domain specific agent using your configured AzureChatClient.
def __init__(self, chat_client: AzureOpenAIChatClient, id: str = "writer"):
# Create a domain specific agent using your configured AzureOpenAIChatClient.
agent = chat_client.create_agent(
instructions=(
"You are an excellent content writer. You create new content and edit contents based on the feedback."
@@ -88,7 +87,7 @@ class Reviewer(Executor):
agent: ChatAgent
def __init__(self, chat_client: AzureChatClient, id: str = "reviewer"):
def __init__(self, chat_client: AzureOpenAIChatClient, id: str = "reviewer"):
# Create a domain specific agent that evaluates and refines content.
agent = chat_client.create_agent(
instructions=(
@@ -111,7 +110,7 @@ class Reviewer(Executor):
async def main():
"""Build the two node workflow and run it with streaming to observe events."""
# Create the Azure chat client. AzureCliCredential uses your current az login.
chat_client = AzureChatClient(credential=AzureCliCredential())
chat_client = AzureOpenAIChatClient(credential=AzureCliCredential())
# Instantiate the two agent backed executors.
writer = Writer(chat_client)
reviewer = Reviewer(chat_client)
@@ -6,7 +6,7 @@ from contextlib import AsyncExitStack
from typing import Any
from agent_framework import AgentRunUpdateEvent, WorkflowBuilder, WorkflowOutputEvent
from agent_framework.foundry import FoundryChatClient
from agent_framework.azure import AzureAIAgentClient
from azure.identity.aio import AzureCliCredential
"""
@@ -24,21 +24,21 @@ Demonstrate:
- The workflow completes when idle and outputs are available in events.get_outputs().
Prerequisites:
- Foundry Agent Service configured, along with the required environment variables.
- Azure AI Agent Service configured, along with the required environment variables.
- Authentication via azure-identity. Use AzureCliCredential and run az login before executing the sample.
- Basic familiarity with WorkflowBuilder, edges, events, and streaming runs.
"""
async def create_foundry_agent() -> tuple[Callable[..., Awaitable[Any]], Callable[[], Awaitable[None]]]:
"""Helper method to create a Foundry agent factory and a close function.
async def create_azure_ai_agent() -> tuple[Callable[..., Awaitable[Any]], Callable[[], Awaitable[None]]]:
"""Helper method to create a Azure AI agent factory and a close function.
This makes sure the async context managers are properly handled.
"""
stack = AsyncExitStack()
cred = await stack.enter_async_context(AzureCliCredential())
client = await stack.enter_async_context(FoundryChatClient(async_credential=cred))
client = await stack.enter_async_context(AzureAIAgentClient(async_credential=cred))
async def agent(**kwargs: Any) -> Any:
return await stack.enter_async_context(client.create_agent(**kwargs))
@@ -50,7 +50,7 @@ async def create_foundry_agent() -> tuple[Callable[..., Awaitable[Any]], Callabl
async def main() -> None:
agent, close = await create_foundry_agent()
agent, close = await create_azure_ai_agent()
try:
writer = await agent(
name="Writer",
@@ -3,7 +3,7 @@
import asyncio
from agent_framework import AgentRunUpdateEvent, WorkflowBuilder, WorkflowOutputEvent
from agent_framework.azure import AzureChatClient
from agent_framework.azure import AzureOpenAIChatClient
from azure.identity import AzureCliCredential
"""
@@ -21,7 +21,7 @@ Demonstrate:
- The workflow completes when idle and outputs are available in events.get_outputs().
Prerequisites:
- Azure OpenAI configured for AzureChatClient with required environment variables.
- Azure OpenAI configured for AzureOpenAIChatClient with required environment variables.
- Authentication via azure-identity. Use AzureCliCredential and run az login before executing the sample.
- Basic familiarity with WorkflowBuilder, edges, events, and streaming runs.
"""
@@ -30,7 +30,7 @@ Prerequisites:
async def main():
"""Build and run a simple two node agent workflow: Writer then Reviewer."""
# Create the Azure chat client. AzureCliCredential uses your current az login.
chat_client = AzureChatClient(credential=AzureCliCredential())
chat_client = AzureOpenAIChatClient(credential=AzureCliCredential())
# Define two domain specific chat agents. The builder will wrap these as executors.
writer_agent = chat_client.create_agent(
@@ -10,7 +10,7 @@ from agent_framework import (
WorkflowContext,
handler,
)
from agent_framework.azure import AzureChatClient
from agent_framework.azure import AzureOpenAIChatClient
from azure.identity import AzureCliCredential
"""
@@ -20,12 +20,12 @@ This sample uses two custom executors. A Writer agent creates or edits content,
then hands the conversation to a Reviewer agent which evaluates and finalizes the result.
Purpose:
Show how to wrap chat agents created by AzureChatClient inside workflow executors. Demonstrate the @handler pattern
Show how to wrap chat agents created by AzureOpenAIChatClient inside workflow executors. Demonstrate the @handler pattern
with typed inputs and typed WorkflowContext[T] outputs, connect executors with the fluent WorkflowBuilder, and finish
by yielding outputs from the terminal node.
Prerequisites:
- Azure OpenAI configured for AzureChatClient with required environment variables.
- Azure OpenAI configured for AzureOpenAIChatClient with required environment variables.
- Authentication via azure-identity. Use AzureCliCredential and run az login before executing the sample.
- Basic familiarity with WorkflowBuilder, executors, edges, events, and streaming or non streaming runs.
"""
@@ -41,8 +41,8 @@ class Writer(Executor):
agent: ChatAgent
def __init__(self, chat_client: AzureChatClient, id: str = "writer"):
# Create a domain specific agent using your configured AzureChatClient.
def __init__(self, chat_client: AzureOpenAIChatClient, id: str = "writer"):
# Create a domain specific agent using your configured AzureOpenAIChatClient.
agent = chat_client.create_agent(
instructions=(
"You are an excellent content writer. You create new content and edit contents based on the feedback."
@@ -83,7 +83,7 @@ class Reviewer(Executor):
agent: ChatAgent
def __init__(self, chat_client: AzureChatClient, id: str = "reviewer"):
def __init__(self, chat_client: AzureOpenAIChatClient, id: str = "reviewer"):
# Create a domain specific agent that evaluates and refines content.
agent = chat_client.create_agent(
instructions=(
@@ -106,7 +106,7 @@ class Reviewer(Executor):
async def main():
"""Build and run a simple two node agent workflow: Writer then Reviewer."""
# Create the Azure chat client. AzureCliCredential uses your current az login.
chat_client = AzureChatClient(credential=AzureCliCredential())
chat_client = AzureOpenAIChatClient(credential=AzureCliCredential())
# Instantiate the two agent backed executors.
writer = Writer(chat_client)
@@ -25,7 +25,7 @@ from agent_framework import (
WorkflowStatusEvent,
handler,
)
from agent_framework.azure import AzureChatClient
from agent_framework.azure import AzureOpenAIChatClient
from azure.identity import AzureCliCredential
# NOTE: the Azure client imports above are real dependencies. When running this
@@ -203,7 +203,7 @@ def create_workflow(*, checkpoint_storage: FileCheckpointStorage | None = None)
# The Azure client is created once so our agent executor can issue calls to
# the hosted model. The agent id is stable across runs which keeps
# checkpoints deterministic.
chat_client = AzureChatClient(credential=AzureCliCredential())
chat_client = AzureOpenAIChatClient(credential=AzureCliCredential())
writer = AgentExecutor(
chat_client.create_agent(
instructions="Write concise, warm release notes that sound human and helpful.",
@@ -18,7 +18,7 @@ from agent_framework import (
WorkflowContext,
handler,
)
from agent_framework.azure import AzureChatClient
from agent_framework.azure import AzureOpenAIChatClient
from azure.identity import AzureCliCredential
if TYPE_CHECKING:
@@ -51,7 +51,7 @@ What you learn:
- How workflows complete by yielding outputs when idle, not via explicit completion events.
Prerequisites:
- Azure AI or Azure OpenAI available for AzureChatClient.
- Azure AI or Azure OpenAI available for AzureOpenAIChatClient.
- Authentication with azure-identity via AzureCliCredential. Run az login locally.
- Filesystem access for writing JSON checkpoint files in a temp directory.
"""
@@ -161,7 +161,7 @@ def create_workflow(checkpoint_storage: FileCheckpointStorage) -> "Workflow":
reverse_text_executor = ReverseTextExecutor(id="reverse-text")
# Configure the agent stage that lowercases the text.
chat_client = AzureChatClient(credential=AzureCliCredential())
chat_client = AzureOpenAIChatClient(credential=AzureCliCredential())
lower_agent = AgentExecutor(
chat_client.create_agent(
instructions=("You transform text to lowercase. Reply with ONLY the transformed text.")
@@ -16,7 +16,7 @@ from agent_framework import ( # Core chat primitives used to build requests
WorkflowContext, # Per-run context and event bus
executor, # Decorator to declare a Python function as a workflow executor
)
from agent_framework.azure import AzureChatClient # Thin client wrapper for Azure OpenAI chat models
from agent_framework.azure import AzureOpenAIChatClient # Thin client wrapper for Azure OpenAI chat models
from azure.identity import AzureCliCredential # Uses your az CLI login for credentials
from pydantic import BaseModel # Structured outputs for safer parsing
@@ -35,7 +35,7 @@ Purpose:
Prerequisites:
- You understand the basics of WorkflowBuilder, executors, and events in this framework.
- You know the concept of edge conditions and how they gate routes using a predicate function.
- Azure OpenAI access is configured for AzureChatClient. You should be logged in with Azure CLI (AzureCliCredential)
- Azure OpenAI access is configured for AzureOpenAIChatClient. You should be logged in with Azure CLI (AzureCliCredential)
and have the Azure OpenAI environment variables set as documented in the getting started chat client README.
- The sample email resource file exists at workflow/resources/email.txt.
@@ -132,7 +132,7 @@ async def to_email_assistant_request(
async def main() -> None:
# Create agents
# AzureCliCredential uses your current az login. This avoids embedding secrets in code.
chat_client = AzureChatClient(credential=AzureCliCredential())
chat_client = AzureOpenAIChatClient(credential=AzureCliCredential())
# Agent 1. Classifies spam and returns a DetectionResult object.
# response_format enforces that the LLM returns parsable JSON for the Pydantic model.
@@ -22,7 +22,7 @@ from agent_framework import (
WorkflowOutputEvent,
executor,
)
from agent_framework.azure import AzureChatClient
from agent_framework.azure import AzureOpenAIChatClient
from azure.identity import AzureCliCredential
from pydantic import BaseModel
@@ -184,7 +184,7 @@ async def database_access(analysis: AnalysisResult, ctx: WorkflowContext[Never,
async def main() -> None:
# Agents
chat_client = AzureChatClient(credential=AzureCliCredential())
chat_client = AzureOpenAIChatClient(credential=AzureCliCredential())
email_analysis_agent = AgentExecutor(
chat_client.create_agent(
@@ -16,7 +16,7 @@ from agent_framework import (
WorkflowOutputEvent,
handler,
)
from agent_framework.azure import AzureChatClient
from agent_framework.azure import AzureOpenAIChatClient
from azure.identity import AzureCliCredential
"""
@@ -28,7 +28,7 @@ What it does:
- The workflow completes when the correct number is guessed.
Prerequisites:
- Azure AI/ Azure OpenAI for `AzureChatClient` agent.
- Azure AI/ Azure OpenAI for `AzureOpenAIChatClient` agent.
- Authentication via `azure-identity` — uses `AzureCliCredential()` (run `az login`).
"""
@@ -122,7 +122,7 @@ async def main():
guess_number_executor = GuessNumberExecutor((1, 100))
# Agent judge setup
chat_client = AzureChatClient(credential=AzureCliCredential())
chat_client = AzureOpenAIChatClient(credential=AzureCliCredential())
judge_agent = AgentExecutor(
chat_client.create_agent(
instructions=(
@@ -20,7 +20,7 @@ from agent_framework import ( # Core chat primitives used to form LLM requests
WorkflowContext, # Per-run context and event bus
executor, # Decorator to turn a function into a workflow executor
)
from agent_framework.azure import AzureChatClient # Thin client for Azure OpenAI chat models
from agent_framework.azure import AzureOpenAIChatClient # Thin client for Azure OpenAI chat models
from azure.identity import AzureCliCredential # Uses your az CLI login for credentials
from pydantic import BaseModel # Structured outputs with validation
@@ -42,7 +42,7 @@ on that type.
Prerequisites:
- Familiarity with WorkflowBuilder, executors, edges, and events.
- Understanding of switch-case edge groups and how Case and Default are evaluated in order.
- Working Azure OpenAI configuration for AzureChatClient, with Azure CLI login and required environment variables.
- Working Azure OpenAI configuration for AzureOpenAIChatClient, with Azure CLI login and required environment variables.
- Access to workflow/resources/ambiguous_email.txt, or accept the inline fallback string.
"""
@@ -155,7 +155,7 @@ async def handle_uncertain(detection: DetectionResult, ctx: WorkflowContext[Neve
async def main():
"""Main function to run the workflow."""
chat_client = AzureChatClient(credential=AzureCliCredential())
chat_client = AzureOpenAIChatClient(credential=AzureCliCredential())
# Agents. response_format enforces that the LLM returns JSON that Pydantic can validate.
spam_detection_agent = AgentExecutor(
@@ -21,7 +21,7 @@ from agent_framework import (
WorkflowStatusEvent, # Event emitted on run state changes
handler, # Decorator to expose an Executor method as a step
)
from agent_framework.azure import AzureChatClient
from agent_framework.azure import AzureOpenAIChatClient
from azure.identity import AzureCliCredential
from pydantic import BaseModel
@@ -42,7 +42,7 @@ Demonstrate:
- Driving the loop in application code with run_stream and send_responses_streaming.
Prerequisites:
- Azure OpenAI configured for AzureChatClient with required environment variables.
- Azure OpenAI configured for AzureOpenAIChatClient with required environment variables.
- Authentication via azure-identity. Use AzureCliCredential and run az login before executing the sample.
- Basic familiarity with WorkflowBuilder, executors, edges, events, and streaming runs.
"""
@@ -158,7 +158,7 @@ class TurnManager(Executor):
async def main() -> None:
# Create the chat agent and wrap it in an AgentExecutor.
# response_format enforces that the model produces JSON compatible with GuessOutput.
chat_client = AzureChatClient(credential=AzureCliCredential())
chat_client = AzureOpenAIChatClient(credential=AzureCliCredential())
agent = chat_client.create_agent(
instructions=(
"You guess a number between 1 and 10. "
@@ -4,7 +4,7 @@ import asyncio
from typing import Any
from agent_framework import ChatMessage, ConcurrentBuilder
from agent_framework.azure import AzureChatClient
from agent_framework.azure import AzureOpenAIChatClient
from azure.identity import AzureCliCredential
"""
@@ -21,14 +21,14 @@ Demonstrates:
- Workflow completion when idle with no pending work
Prerequisites:
- Azure OpenAI access configured for AzureChatClient (use az login + env vars)
- Azure OpenAI access configured for AzureOpenAIChatClient (use az login + env vars)
- Familiarity with Workflow events (AgentRunEvent, WorkflowOutputEvent)
"""
async def main() -> None:
# 1) Create three domain agents using AzureChatClient
chat_client = AzureChatClient(credential=AzureCliCredential())
# 1) Create three domain agents using AzureOpenAIChatClient
chat_client = AzureOpenAIChatClient(credential=AzureCliCredential())
researcher = chat_client.create_agent(
instructions=(
@@ -13,7 +13,7 @@ from agent_framework import (
WorkflowContext,
handler,
)
from agent_framework.azure import AzureChatClient
from agent_framework.azure import AzureOpenAIChatClient
from azure.identity import AzureCliCredential
"""
@@ -25,21 +25,21 @@ and emit AgentExecutorResponse outputs, which allows reuse of the high-level
ConcurrentBuilder API and the default aggregator.
Demonstrates:
- Executors that create their ChatAgent in __init__ (via AzureChatClient)
- Executors that create their ChatAgent in __init__ (via AzureOpenAIChatClient)
- A @handler that converts AgentExecutorRequest -> AgentExecutorResponse
- ConcurrentBuilder().participants([...]) to build fan-out/fan-in
- Default aggregator returning list[ChatMessage] (one user + one assistant per agent)
- Workflow completion when all participants become idle
Prerequisites:
- Azure OpenAI configured for AzureChatClient (az login + required env vars)
- Azure OpenAI configured for AzureOpenAIChatClient (az login + required env vars)
"""
class ResearcherExec(Executor):
agent: ChatAgent
def __init__(self, chat_client: AzureChatClient, id: str = "researcher"):
def __init__(self, chat_client: AzureOpenAIChatClient, id: str = "researcher"):
agent = chat_client.create_agent(
instructions=(
"You're an expert market and product researcher. Given a prompt, provide concise, factual insights,"
@@ -59,7 +59,7 @@ class ResearcherExec(Executor):
class MarketerExec(Executor):
agent: ChatAgent
def __init__(self, chat_client: AzureChatClient, id: str = "marketer"):
def __init__(self, chat_client: AzureOpenAIChatClient, id: str = "marketer"):
agent = chat_client.create_agent(
instructions=(
"You're a creative marketing strategist. Craft compelling value propositions and target messaging"
@@ -79,7 +79,7 @@ class MarketerExec(Executor):
class LegalExec(Executor):
agent: ChatAgent
def __init__(self, chat_client: AzureChatClient, id: str = "legal"):
def __init__(self, chat_client: AzureOpenAIChatClient, id: str = "legal"):
agent = chat_client.create_agent(
instructions=(
"You're a cautious legal/compliance reviewer. Highlight constraints, disclaimers, and policy concerns"
@@ -97,7 +97,7 @@ class LegalExec(Executor):
async def main() -> None:
chat_client = AzureChatClient(credential=AzureCliCredential())
chat_client = AzureOpenAIChatClient(credential=AzureCliCredential())
researcher = ResearcherExec(chat_client)
marketer = MarketerExec(chat_client)
@@ -4,7 +4,7 @@ import asyncio
from typing import Any
from agent_framework import ChatMessage, ConcurrentBuilder, Role
from agent_framework.azure import AzureChatClient
from agent_framework.azure import AzureOpenAIChatClient
from azure.identity import AzureCliCredential
"""
@@ -12,7 +12,7 @@ Sample: Concurrent Orchestration with Custom Aggregator
Build a concurrent workflow with ConcurrentBuilder that fans out one prompt to
multiple domain agents and fans in their responses. Override the default
aggregator with a custom async callback that uses AzureChatClient.get_response()
aggregator with a custom async callback that uses AzureOpenAIChatClient.get_response()
to synthesize a concise, consolidated summary from the experts' outputs.
The workflow completes when all participants become idle.
@@ -23,12 +23,12 @@ Demonstrates:
- Workflow output yielded with the synthesized summary string
Prerequisites:
- Azure OpenAI configured for AzureChatClient (az login + required env vars)
- Azure OpenAI configured for AzureOpenAIChatClient (az login + required env vars)
"""
async def main() -> None:
chat_client = AzureChatClient(credential=AzureCliCredential())
chat_client = AzureOpenAIChatClient(credential=AzureCliCredential())
researcher = chat_client.create_agent(
instructions=(
@@ -4,7 +4,7 @@ import asyncio
from typing import cast
from agent_framework import ChatMessage, Role, SequentialBuilder, WorkflowOutputEvent
from agent_framework.azure import AzureChatClient
from agent_framework.azure import AzureOpenAIChatClient
from azure.identity import AzureCliCredential
"""
@@ -23,13 +23,13 @@ Note on internal adapters:
You can safely ignore them when focusing on agent progress.
Prerequisites:
- Azure OpenAI access configured for AzureChatClient (use az login + env vars)
- Azure OpenAI access configured for AzureOpenAIChatClient (use az login + env vars)
"""
async def main() -> None:
# 1) Create agents
chat_client = AzureChatClient(credential=AzureCliCredential())
chat_client = AzureOpenAIChatClient(credential=AzureCliCredential())
writer = chat_client.create_agent(
instructions=("You are a concise copywriter. Provide a single, punchy marketing sentence based on the prompt."),
@@ -13,7 +13,7 @@ from agent_framework import (
WorkflowContext,
handler,
)
from agent_framework.azure import AzureChatClient
from agent_framework.azure import AzureOpenAIChatClient
from azure.identity import AzureCliCredential
"""
@@ -35,7 +35,7 @@ Note on internal adapters:
for completion—similar to concurrent's dispatcher/aggregator.
Prerequisites:
- Azure OpenAI access configured for AzureChatClient (use az login + env vars)
- Azure OpenAI access configured for AzureOpenAIChatClient (use az login + env vars)
"""
@@ -53,7 +53,7 @@ class Summarizer(Executor):
async def main() -> None:
# 1) Create a content agent
chat_client = AzureChatClient(credential=AzureCliCredential())
chat_client = AzureOpenAIChatClient(credential=AzureCliCredential())
content = chat_client.create_agent(
instructions="Produce a concise paragraph answering the user's request.",
name="content",
@@ -18,7 +18,7 @@ from agent_framework import ( # Core chat primitives to build LLM requests
WorkflowOutputEvent, # Event emitted when workflow yields output
handler, # Decorator to mark an Executor method as invokable
)
from agent_framework.azure import AzureChatClient # Client wrapper for Azure OpenAI chat models
from agent_framework.azure import AzureOpenAIChatClient # Client wrapper for Azure OpenAI chat models
from azure.identity import AzureCliCredential # Uses your az CLI login for credentials
"""
@@ -35,7 +35,7 @@ Show how to construct a parallel branch pattern in workflows. Demonstrate:
Prerequisites:
- Familiarity with WorkflowBuilder, executors, edges, events, and streaming runs.
- Azure OpenAI access configured for AzureChatClient. Log in with Azure CLI and set any required environment variables.
- Azure OpenAI access configured for AzureOpenAIChatClient. Log in with Azure CLI and set any required environment variables.
- Comfort reading AgentExecutorResponse.agent_run_response.text for assistant output aggregation.
"""
@@ -107,7 +107,7 @@ class AggregateInsights(Executor):
async def main() -> None:
# 1) Create agent executors for domain experts
chat_client = AzureChatClient(credential=AzureCliCredential())
chat_client = AzureOpenAIChatClient(credential=AzureCliCredential())
researcher = AgentExecutor(
chat_client.create_agent(
@@ -17,7 +17,7 @@ from agent_framework import (
WorkflowContext,
executor,
)
from agent_framework.azure import AzureChatClient
from agent_framework.azure import AzureOpenAIChatClient
from azure.identity import AzureCliCredential
from pydantic import BaseModel
@@ -35,7 +35,7 @@ Show how to:
- Compose agent backed executors with function style executors and yield the final output when the workflow completes.
Prerequisites:
- Azure OpenAI configured for AzureChatClient with required environment variables.
- Azure OpenAI configured for AzureOpenAIChatClient with required environment variables.
- Authentication via azure-identity. Use AzureCliCredential and run az login before executing the sample.
- Familiarity with WorkflowBuilder, executors, conditional edges, and streaming runs.
"""
@@ -157,7 +157,7 @@ async def handle_spam(detection: DetectionResult, ctx: WorkflowContext[Never, st
async def main() -> None:
# Create chat client and agents. response_format enforces structured JSON from each agent.
chat_client = AzureChatClient(credential=AzureCliCredential())
chat_client = AzureOpenAIChatClient(credential=AzureCliCredential())
spam_detection_agent = chat_client.create_agent(
instructions=(
@@ -19,7 +19,7 @@ from agent_framework import (
WorkflowViz,
handler,
)
from agent_framework.azure import AzureChatClient
from agent_framework.azure import AzureOpenAIChatClient
from azure.identity import AzureCliCredential
"""
@@ -31,7 +31,7 @@ What it does:
- Visualization: generate Mermaid and GraphViz representations via `WorkflowViz` and optionally export SVG.
Prerequisites:
- Azure AI/ Azure OpenAI for `AzureChatClient` agents.
- Azure AI/ Azure OpenAI for `AzureOpenAIChatClient` agents.
- Authentication via `azure-identity` — uses `AzureCliCredential()` (run `az login`).
- For visualization export: `pip install agent-framework[viz]` and install GraphViz binaries.
"""
@@ -103,7 +103,7 @@ class AggregateInsights(Executor):
async def main() -> None:
# 1) Create agent executors for domain experts
chat_client = AzureChatClient(credential=AzureCliCredential())
chat_client = AzureOpenAIChatClient(credential=AzureCliCredential())
researcher = AgentExecutor(
chat_client.create_agent(