Lesson 2 of 4 Decomposing Goals into Agents and Workflows

Designing Workflows, Control Loops and Human Checkpoints

This lesson explains how a workflow connects the components of a design: which agent calls which subagent, how each agent loop decides it is finished, and where people review or approve.

Learning outcomes

After completing this lesson, you will be able to:

  • Describe how a parent agent delegates bounded subtasks to subagents.
  • Design control loops with explicit termination conditions.
  • Place human-in-the-loop steps where the expected cost of an error is high.

Agents and subagents

A subagent is an agent that another agent invokes to complete a bounded subtask. The parent passes a focused instruction and the necessary inputs, and the subagent returns a result, usually a structured summary. Subagents keep the parent's context small because the parent sees only the result, not every intermediate step, and they allow different tools, models and permissions per subtask. In Foundry and Agent Framework, a subagent can be exposed to the parent as a tool, or the workflow can route to it explicitly.

True or false

How subagents work

Exam skills 1.1.2

Check how parent agents and subagents divide work.

Log in to try this activity Interactive activities are free with an account.

Control loops and termination

An agent works in a control loop: it plans, calls a tool or subagent, observes the result and decides whether to continue. Without explicit termination, a loop can repeat the same failing call or keep exploring, consuming tokens and quota. Every loop therefore has several stopping conditions, which the following list describes.

  • Goal check: a validator or the agent's structured status reports the task as complete.
  • Iteration cap: a maximum number of model turns or tool calls per run.
  • Budget: a maximum number of tokens, a time limit or a cost limit per run.
  • Stall detection: the same tool with the same arguments, or no progress, for several iterations.
  • Escalation: a hand-off to a person when any limit is reached without success.

Deterministic control loops can also live outside the agent: a workflow can call an agent, validate its output and call it again with feedback, up to a fixed number of attempts. This evaluator-optimizer loop is easier to bound and audit than an open-ended agent loop.

The following diagram shows the control loop and the conditions that stop it.

An agent control loop and its stopping conditions. The agent plans, calls a tool or subagent, observes the result and decides whether to continue. Every loop needs explicit termination: a goal check, an iteration cap, a budget of tokens, time or cost, and stall detection when the same call repeats or nothing progresses. When a limit is reached without success, the run escalates to a person.
Every loop needs explicit termination.
Match the pairs

Stopping conditions for an agent loop

Exam skills 1.1.2

Match each stopping condition with how it ends the loop.

Log in to try this activity Interactive activities are free with an account.

Placing human-in-the-loop steps

Human-in-the-loop (HITL) steps cost time and staff, so they are placed where the expected cost of an error is high: irreversible actions (payments, deletions, external messages), actions above a threshold, low-confidence decisions, policy exceptions and first-time situations. The workflow engine must persist state while it waits, because approvals can take hours or days.

Foundry workflows provide human-input nodes, and Microsoft Agent Framework workflows provide request and response messages with checkpointing; tools marked as requiring approval pause the run automatically. The design states who approves, what information the approver sees (the proposed action, its arguments and the agent's reasoning summary), the time-out behaviour and what happens on rejection.

Sort into groups

Does it need a human step?

Exam skills 1.1.2

Decide where a human-in-the-loop step is worth its cost.

Log in to try this activity Interactive activities are free with an account.
Worked example

A bounded research loop

A research agent gathers evidence from internal reports and the web to answer analysts' questions. Some runs have taken 15 minutes and consumed 400,000 tokens while repeatedly searching for unavailable data.

The loop lacks termination. The design adds an iteration cap (for example 12 tool calls), a token budget per run, stall detection that stops after three searches with no new sources, and a final step that returns the best partial answer with a statement of what could not be found. Raising the model's reasoning effort or adding more search tools would make the loop more expensive without addressing the missing stopping conditions.

Check yourself

Why should a subagent return a result rather than its full transcript?

Show answer

It keeps the parent agent's context small, which lowers token cost and keeps the parent focused on the results it needs.

Exam Tips

Remember for the exam

  • Subagents return results, not transcripts, which keeps the parent's context small.
  • Every loop needs a goal check, an iteration cap, a budget and escalation.
  • HITL steps go before irreversible or high-impact actions and need persisted state.