Learning by Patrik

Build agent-driven workflows using Microsoft Foundry | AI-103 | Episode 12

Build Agent-Driven Workflows in Microsoft Foundry

When an AI solution becomes multi-step, don't turn one agent into a logic engine. Use a workflow to combine LLM reasoning with deterministic orchestration: agents decide what something means; workflow logic decides what happens next.

Core model: Workflow = Executors (nodes) + Edges

  • Agent node → invokes an agent

  • Variables → carry state/data between nodes (Local.*)

  • If / Switch → deterministic branching

  • For-Each → process collections without duplicating nodes

  • Edges → route execution between nodes

  • Structured output (JSON) → turns probabilistic agent output into predictable data for downstream logic

  • Human-in-the-loop → pause, clarify, approve, or escalate

Typical patterns are Sequential, Human-in-the-loop, Group chat, and Fan-out/Fan-in.

Think in workflows

A support flow could be:

Tickets → For-Each → Triage Agent → {category, confidence} → If confidence → Route

The agent classifies the ticket and returns structured JSON. The workflow then evaluates confidence: low confidence requests clarification; Billing escalates to a human; other categories continue to a Resolution Agent.

Key distinction: use an agent for semantic reasoning; use workflow nodes/edges for loops, routing, state, and business rules.

Calling it from code

The workflow can remain server-side while application code simply starts a conversation and invokes it:

project = AIProjectClient(endpoint, DefaultAzureCredential())
openai = project.get_openai_client()

conversation = openai.conversations.create()

response = openai.responses.create(
    conversation=conversation.id,
    extra_body={
        "agent_reference": {
            "name": "support-workflow",
            "type": "agent_reference"
        }
    },
    input="Process the tickets"
)

print(response.output_text)

Remember: Agent = reasoningStructured JSON = contractWorkflow = orchestrationEdges = routingFor-Each = iterationHuman-in-loop = controlled escalation.

Foundry
Agents
Workflows
Orchestration
Azure

Comments