Your profile

One profile for every MSDEVBUILD site. Only you can see it, and the site owner if you write in.

Lesson 14 of 39
❮Prev Next❯

Workflows, Tool-Augmented Flows and Multistep Reasoning

Module 2: GenAI & Agents ⏱ 12 min read Updated

Your note

My notes for this lesson

Select any text in the lesson to highlight it or add a note. Saved in this browser.

    No highlights yet. Select a sentence in the lesson, then pick a colour or add a note.

    All my bookmarks and notes

    Reading settings

    For every lesson, saved in this browser.

    Text size
    Line spacing
    Font

    With IaaS you rent the virtual machine. Microsoft looks after the building, power and hardware; you patch the operating system.

    30-second answer

    A workflow breaks one AI task into small steps you control, for example classify, extract, call a tool, draft, verify. Use structured outputs with a strict JSON schema between steps, give tool calls timeouts, bounded retries and a fallback, and check the result before anything is sent. Low temperature suits classification and extraction, and a reasoning model suits the one step that needs deep planning.

    Simulate it » No Azure account needed

    Exam objective: 2.1.3 Design workflows, tool-augmented flows and multistep reasoning pipelines. (Skills measured as of April 16, 2026)

    Simulations

    Feel it before you read it. No account needed, nothing leaves this page.

    Azure portal: Build a classify, extract, check and draft flow Build a classify, extract, check and draft flow in a workflow.
    </> Embed

    Embed this simulation

    Free for trainers, teachers and bloggers. Paste this into your page:

    Loading the portal…

    Open <strong>Build ➜ Workflows</strong>. A workflow lets you wire steps together visually, or in code, with branches and checks.

    👆 Click the glowing item in the portal to continue

    Read the steps as text
    1. Open Build ➜ Workflows. A workflow lets you wire steps together visually, or in code, with branches and checks.
    2. Each step has one job. Step 3 calls a real system as a tool, so it has a retry and a branch for when the system is down.
    3. Decide what happens on failure before it happens: retry, then a safe fallback that the next steps respect.
    4. The run history shows which step each run reached. Tracing (a later lesson) shows the detail inside each step.

    🧪 Simulation for learning. Screens are simplified versions of the Azure portal; names, prices and IDs are examples. Nothing here touches real Azure.

    😟 THE PROBLEM

    One giant prompt classifies, extracts, looks things up and replies, and nobody can tell which part failed.

    😊 THE SOLUTION

    Split the work into steps with checks, retries and a safe fallback.

    • One prompt does everything✓ One job per step
    • A system times out✓ Retry, then a fallback value
    • A wrong reply gets sent✓ A verify step before sending
    🛠️ Solved with: Multistep, tool-augmented flows

    Start with a question

    Why does a bakery use a checklist for a wedding cake?

    One person doing everything in one go makes mistakes. A good bakery splits the job: measure, mix, bake, cool, decorate, check. Each stage has one purpose, and someone checks the result before the cake leaves.

    An AI workflow is that checklist. Instead of asking a model to read a claim email, look up the warranty and write a reply in one prompt, you run steps. Each step does one job, and a check at the end stops a wrong cake from leaving the shop.

    Explain it like I’m 10

    The technical explanation

    The five steps of a claims flow

    StepWhat it doesSetting that matters
    1 ClassifyWarranty, refund or otherTemperature 0, short answer
    2 ExtractPull product, serial number and dateStructured output with a strict JSON schema
    3 ToolCall check_warranty(serial)Timeout, bounded retries, fallback value
    4 DraftWrite the reply from the factsOnly the verified facts go in the prompt
    5 VerifyCompare the draft with the factsRules or a second model, refuse to send on mismatch
    kind = openai.responses.create(model=model, temperature=0,
            input=f"Classify as warranty, refund or other: {email}").output_text
    
    fields = json.loads(openai.responses.create(model=model, input=email,
            text={"format": {"type": "json_schema", "name": "claim", "strict": True,
                             "schema": CLAIM_SCHEMA}}).output_text)
    
    status = with_retry(lambda: check_warranty(fields["serial_number"]), attempts=3) or "needs_human_review"
    
    draft = openai.responses.create(model=model, input=f"Write a reply. Facts: {fields} {status}").output_text
    print(draft if verify(draft, fields, status) else "Held for a person to check")

    Structured outputs, not hopeful prompts

    Asking for JSON in words isn’t enough. JSON mode (json_object) only promises something that parses. Structured outputs (json_schema with strict: true) make the reply match your schema: every required field present, no extras when additionalProperties is false. That’s what lets step 3 trust the serial number from step 2.

    Tools and multistep reasoning

    A tool-augmented flow lets a model ask for a tool when it needs data or an action. Your code runs the tool and returns the result. For one step that needs real planning, such as comparing contract clauses, use a reasoning model for that step and keep cheap models for the rest. Foundry also has a workflow builder in preview as of 25 November 2026, where you wire steps, agents and conditions together without writing the control flow by hand.

    Architect level Where to put the checks

    Put a check wherever a mistake becomes expensive. After extraction, validate the schema and the serial number format. After the tool, treat an empty or error result as a failure, not as data. Before sending, compare every fact in the draft with its source. Cheap rule checks catch most errors; a second model can review tone and completeness. Log each step so a held claim shows exactly where it stopped.

    Real-world business scenario

    Consumer goods

    Fabrikam Appliances (fictional)

    The problem
    Claims arrived as free-text emails. One prompt did everything and sometimes promised warranty dates the warranty system didn't show.
    What they used
    A five-step flow: classify at temperature 0, extract to a strict schema, call check_warranty with three retries, draft from the verified facts, then verify the dates before sending. A tool failure sends the claim to human review.
    Why that choice
    Each step is testable, the tool result is the only source of warranty facts, and a failure ends in a person's queue instead of a wrong promise.
    The result
    Wrong-date replies stopped, and the team could see in the run history exactly which step held each claim.

    When to use it and when not to

    ✓ Use it when…

    • The task has natural stages, such as classify, look up, write.
    • A step calls a system that can fail or return data the reply depends on.
    • You need an audit trail of what happened at each step.

    ✕ Think twice when…

    • One simple question and answer. A single call is enough.
    • The steps are not known in advance. An agent that plans may suit better.
    • Every step uses the largest model. Match the model to each step.

    ↔ Alternatives to consider

    • A single prompt for simple tasks.
    • An agent with tools when the model should decide the steps.
    • Multi-agent orchestration when specialists share the work.
    Ready for more?The full lesson adds the technical explanation, when to use it, interview questions and revision notes.

    Test yourself with exercises

    5 original practice questions in the AI-103 style. Pick your answers, then check them. You will see why each option is right or wrong. Score 75% or more and this topic is marked complete.

    Question 1

    Question 1 of 5

    Downstream code parses the model reply and fails when a field name changes between calls.

    Which feature should you use?

    Question 2

    Question 2 of 5

    A claims flow calls a warranty system that sometimes times out. The flow must never send a reply that lacks verified data.

    What should you implement?

    Question 3

    Question 3 of 5

    A single prompt classifies a claim, extracts fields, checks the warranty and writes the reply. Failures are hard to diagnose.

    What is the best redesign?

    Question 4

    Question 4 of 5

    Which setting is most appropriate for the classification step of a flow that must give the same label for the same email?

    Question 5

    Question 5 of 5 · Select 2

    You are designing a reasoning pipeline that has several model calls and one external tool call.

    Which two practices improve reliability? Select two.

    Interview preparation

    Say your answer out loud first, then open the model answer. Interviewers care more about your reasoning than the exact words.

    Beginner Why not put everything in one prompt?

    Model answer

    One big prompt hides where things go wrong. If classification, lookup and writing are separate steps, I can test each one, trace each one and fix the one that fails.

    Intermediate What is the difference between JSON mode and structured outputs?

    Model answer

    JSON mode promises valid JSON, but the keys are the model's choice. Structured outputs with a strict schema promise the exact keys and types, so my code can parse the result without guessing.

    Experienced developer How do you handle a flaky tool inside a flow?

    Model answer

    I set a timeout, retry a limited number of times, and then take a defined fallback such as marking the item for human review. The later steps must respect that fallback, and the verify step must refuse to send anything built without the facts.

    Scenario A claims flow sent a wrong warranty date. What do you add?

    Model answer

    A verify step that compares the draft with the tool result before sending, for example that the date in the text equals the date the tool returned. If it doesn't match, the flow holds the claim.

    Quick revision

    Key points

    • Give each step one job and check between steps.
    • Structured outputs make step outputs parseable.
    • Bound tool calls with timeouts and retries, then fall back safely.
    • Verify the draft against the facts before sending.
    • Use low temperature for classification and extraction.

    Important terminology

    Workflow
    A sequence of steps, some model calls and some code or tools, where each step has one job and its output feeds the next.
    Tool-augmented flow
    A flow where the model can ask for tools, such as a function or an API, to get data or act.
    Structured outputs
    A model setting that forces the reply to match a JSON schema, so code can parse it.
    Fallback
    What the flow does when a step fails, such as holding the item for a person.
    Verification step
    A check, in code or a second model, that the result matches the facts before it is used.
    Multistep reasoning
    Solving a problem by working through several steps, either in a reasoning model or across steps of a flow.

    Common mistakes

    • Assuming a tool will always answer.
    • Parsing free text between steps.
    • Letting a failed step silently produce a guess.

    Exam tips

    • "Code must parse the model reply" = structured outputs with a strict schema.
    • "Tool times out, no wrong reply may be sent" = bounded retries and a fallback.
    • "Hard to diagnose failures" = split into steps.

    Five quick revision questions

    1. 1.What does a strict schema guarantee?Show

      The exact keys and types in the reply.

    2. 2.What should happen when a tool keeps failing?Show

      A safe fallback, such as human review.

    3. 3.Which temperature suits classification?Show

      A low one, often 0.

    4. 4.What is a verify step?Show

      A check of the draft against the facts before sending.

    5. 5.Why split a prompt into steps?Show

      So each step can be tested and traced.

    Official references

    Finished this lesson? Tick it off. Your progress is saved in this browser.

    Next up: Evaluate Models and Apps: Groundedness, Relevance and Safety

    Studying with a friend? Send them this lesson

    It's free and needs no sign-up. Their progress saves in their own browser.

    Lesson done? Make it stick with a quick gameSort It, Match the Pairs, Lightning Round and Who Am I? Earn XP and badges. Play ❯

    Install MSDEVBUILD Azure

    Free · no account · works offline

    Save the whole course for offline ›

    Hi, I’m your Nimbus

    Your study buddy. Pick what we do next.

    MSDEVBUILD · Multi-Stack Dev Build

    Sign in to MSDEVBUILD

    One account for Azure certifications and the blog: sign in here and you are signed in on both. Your XP, streak, practice deck and certificate stay in sync on every device. Optional: everything works without an account.