AI Engineering
/
Tool Calling & Agents
/

Choose a fixed workflow or an agent loop

Tool Calling & Agents · 2 to 3 hours

Choose a fixed workflow or an agent loop

Compare a fixed workflow and an agent loop for a parcel-delivery assistant's rescheduling and stuck-parcel tasks using a pilot's success, cost, and latency figures, then recommend a design per task and say what would change it.

Medium
Conceptual

Conceptual comparison

3 h

Overview

Decide between a fixed workflow and an agent loop the way a technical screen expects: state the product's constraints, compare both designs on the same dimensions, and let pilot evidence settle the choice. You practice on a fictional parcel-delivery assistant with one predictable task and one open-ended task.

Study time: 2 to 3 hours

Interview format: Technical screen comparison with a pilot table and changed constraints

By the end you can

  • State a product's goal and constraints, then compare a fixed workflow and an agent loop on the same dimensions
  • Turn a pilot into cost per successful task and total daily cost, counting the work that failed runs create
  • Use repeated trials and per-slice results to tell a missing path from run-to-run variance
  • Keep validation, required steps, and approvals in code whichever design you choose
  • Recommend a design per task, name the evidence still missing, and say what would change the decision
  • Recognize when a workflow with one bounded agentic step is worth piloting against both pure designs

Prerequisites

Helpful background: Comfort with percentages and per-million-token prices helps.

This topic covers workflows versus agents, typed tools, approval boundaries, state, and termination. Specific frameworks and protocols appear as tags.

Who chooses the next step

In a fixed workflow, code decides the order of steps and every branch; the model fills bounded steps inside that path, such as extracting fields or writing a reply. In an agent loop, the model chooses the next tool call from the goal and the results so far, until it answers or a limit in code stops it.

The difference is who controls the next step, not how many tools or model calls run: a workflow can call a model five times, and an agent can finish in two calls. Most designs sit between the two. A router that picks one of several fixed paths is still a workflow, and a workflow can hold one bounded agentic step where its fixed path runs out.

Scenario: a parcel-delivery assistant

Worked example

Suppose a parcel-delivery company runs a chat assistant on its website. The company, its tools, and every figure in this question are fictional. For each of two tasks, the team built both a fixed workflow and an agent loop. Both designs use the same model, tools, and argument validation; only the control flow differs.

Task A: reschedule a delivery. A customer gives a tracking number and asks for another day. A parcel can be rescheduled only while it is at a depot (not out for delivery, delivered, or held at customs). A rebook is a write: a wrong one sends a driver on the wrong day.

ToolWhat it does
verify_customerChecks the tracking number against the postcode the customer gives
get_shipmentReturns the parcel's state and depot
list_slotsReturns open delivery slots for a day
rebook_deliveryMoves the delivery to a slot (write)
  • Workflow A. The model extracts the tracking number, postcode, and preferred day into validated JSON (one repair attempt). Code verifies the customer, reads the shipment, checks that its state allows rescheduling, and lists slots. The customer picks and confirms a slot with buttons; code rebooks, and the model writes the confirmation from the result. Anything outside this path, such as a redirect to a neighbor, goes to a person.
  • Agent A. The model receives the four tools and instructions that include "verify the customer first" and "confirm the slot with the customer before rebooking". The executor validates arguments and rejects get_shipment, list_slots, and rebook_delivery until verify_customer has succeeded. Cap: 10 model calls, then a hand-off.

Task B: explain why a parcel is stuck. The customer asks why tracking has not moved. The reply must name the cause and the next step and cite the records it used. Every Task B tool is read-only.

ToolWhat it returns
get_tracking_eventsThe public tracking history
get_depot_scansInternal scans at each depot
get_carrier_notesFree-text notes from drivers and partner carriers
get_customs_statusCustoms holds and missing documents
get_partner_trackingA partner carrier's history, given the partner reference found in a carrier note
check_addressWhether the address failed validation at the depot
  • Workflow B. Code calls the first four tools in parallel, and one model call writes the explanation from their results (one repair attempt if the reply fails its format check). Code checks that every cause the reply cites comes from a fetched record; when that check fails or the model finds no record that explains the hold, the conversation goes to a person.
  • Agent B. The model receives all six tools and chooses which to call and in what order. Code applies the same cited-record check to its reply. Cap: 12 model calls, then a hand-off.

Product constraints

ConstraintTask ATask B
Conversations per day6,0002,000
p95 processing time target (excluding customer wait)8 s20 s
Writesrebook_delivery; no wrong rebooks allowedNone

Model spend for both tasks together must stay at or below $100 per day. Prices: $1.00 per million input tokens and $3.00 per million output tokens. Each conversation a person has to finish costs $2.50 of staff time.

Pilot results

Worked example

The team labeled 200 recent conversations per task with the correct outcome. Each design ran every case three times (600 runs per design), and a reviewer graded every run's outcome against its label and read every trace.

  • Successful: the labeled outcome without a person. Task A: the confirmed slot is booked, or the assistant correctly says the parcel cannot be rescheduled and why. Task B: the right cause and next step, with the records cited.
  • Wrong outcome: the assistant finished, but the outcome was wrong.
  • Handed off: the assistant passed the conversation to a person, including every run that hit the cap.

Every unsuccessful run, wrong or handed off, ends with a person finishing the conversation.

Measure (600 runs per design)Workflow AAgent AWorkflow BAgent B
Successful runs582570426516
Wrong outcomes035430
Handed off182712054
Cases successful in all 3 runs (of 200)192176136158
Model calls per run, mean / p952.1 / 35.4 / 91.2 / 24.6 / 10
Mean input tokens per run3,00016,0009,00021,000
Mean output tokens per run3009004001,100
p95 processing time4.1 s11.8 s5.2 s17.5 s
Runs that hit the capn/a6n/a12
Runs with a wrong or unnecessary tool calln/a (code picks every call)41n/a (code picks every call)48

Trace notes:

  • Agent A: in 9 runs (included in the 41) the model called rebook_delivery before verify_customer; the executor rejected each call and the run continued. All 3 wrong outcomes booked a slot the customer had not confirmed.
  • Workflow A: the 18 hand-offs were requests outside the path (redirects, two parcels in one message) and extractions that still failed after the repair.
  • Workflow B: each of its 54 wrong outcomes cited a real fetched record, but not the record that explained the hold.
  • Agent B: the cap hits alternated between get_depot_scans and get_carrier_notes without new information.

Task B by case type (successful runs; each case ran 3 times)

Case typeCasesRunsWorkflow B successfulAgent B successful
Depot backlog80240228216
Customs hold50150138132
Partner carrier handover401203696
Address problem30902472

Compare both designs on the same dimensions

State the goal and constraints first: what a correct outcome is, whether the task ends in a write, the latency target, and the budget. Then compare both designs row by row in one table.

DimensionFixed workflowAgent loop
Next step chosen byCodeThe model, inside limits set in code
TestingUnit tests per step, fixtures per branchOutcome grading over repeated trials, plus transcript review
Cost and latencyA known number of model calls per pathVaries by case; input tokens grow because each call usually resends the conversation
Typical failureA case no path covers: handed off, or answered from partial evidenceLoops, repeated or unnecessary calls, the wrong tool, stopping early, skipping a required step
LimitsPath length fixed in codeStep, time, and cost caps and a no-progress check, all in code
Validation and approvalsEnforced by codeEnforced by the executor, never by the prompt alone
TracesName the failing stepNeed every call and a stop reason
Adding a case typeA new branchA new tool, description, and test cases

Cost per successful task

Cost per run is input tokens times the input price plus output tokens times the output price (prices per million tokens). It undercounts on its own, because failed runs spend tokens too.

  • Cost per successful task: total model spend divided by successful runs.
  • Cost of a failure: the staff time to finish the conversation. Count wrong outcomes separately, since they can also harm the customer.
  • Daily cost: per-run cost times daily volume, plus unsuccessful conversations per day times the handling cost. Compare the model share with the budget.
  • Tails: agent runs vary in length, so read p95 calls and p95 latency, not only the means.

For example, $0.010 per run at 80% success is $0.010 / 0.8 = $0.0125 per successful run, before any handling cost.

Work the pilot figures

Use the pilot results. Work each row for all four columns before you reveal it.

Predict the outcome

Work the pilot figures

Using the pilot results, compute each row for all four columns before you reveal the answers. Write each ratio as a fraction first.

MeasureWorkflow AAgent AWorkflow BAgent B
Success rate per run????
Cases successful in all three runs????
Successful runs among the cases that did not succeed in all three runs????
Model cost per run????
Model cost per 1,000 successful runs????
Daily model spend????
Conversations a person finishes per day, and their cost????
Daily total, model plus handling????
p95 processing time against the task's target????

Evaluate both designs on the same cases

Run both designs on the same labeled cases with the same model, tools, and validation, so only the control flow differs.

  • Grade outcomes. Compare the final state or answer with the label, and review transcripts for blocked, repeated, or unnecessary calls and cap hits; an exact tool-sequence check fails valid paths.
  • Repeat trials. Outputs vary between runs, so run each case several times. pass^k is the chance that all k runs of a case succeed, averaged over cases; with exactly k runs per case, it is the share of cases that succeed every time. A workflow with model steps varies too, usually less.
  • Read where failures fall. The same cases failing on every run means a missing path: add a branch or a tool. Failures spread thinly across many cases mean run-to-run variance: tighten tools, instructions, or limits.
  • Slice by case type. An overall rate can hide that one design wins the common cases and loses the rare ones.

Read Task B by case type

Use the Task B table by case type in the pilot results.

Predict the outcome

Read Task B by case type

For each Task B case type and the two groupings below it, compute both designs' success rates from the pilot table, then say what the comparison shows before you reveal the answers.

Case typeWorkflow BAgent BWhat it shows
Depot backlog (80 cases)???
Customs hold (50 cases)???
Partner carrier handover (40 cases)???
Address problem (30 cases)???
Depot backlog and customs hold together (130 cases)???
Partner handover and address problem together (70 cases)???

Failure modes, limits, and traces

An agent loop fails by looping between tools without new information, repeating a call, choosing a tool the case does not need, stopping early, or skipping a step only the prompt required. A fixed workflow fails when a case falls outside every path: it hands off or, worse, answers from partial evidence.

Both designs need controls in code:

  • A step cap, a deadline, a cost cap, and a no-progress check end an agent run with a stated reason and a hand-off (loop mechanics are in this topic's Medium adapter question).
  • Required steps and approvals are preconditions the executor checks before a tool runs, in either design.
  • A retryable write needs a stable idempotency key per logical operation (this topic's Hard question).

A workflow trace names the failing step. An agent trace needs a record per model call and tool call and a stop reason, so failed runs can be grouped by stop reason and tool sequence.

Hybrids and moving between designs

Common hybrids:

  1. A router that sends each request to a fixed path, with an agent only for requests no path covers.
  2. A fixed sequence first, then one bounded agentic step with a small tool set and its own cap, used only when the fixed steps leave the question open.
  3. An agent whose executor enforces a checklist of required steps.

Move a workflow toward an agent when hand-offs concentrate on cases no branch covers and case types keep changing. Move an agent toward a workflow when one tool sequence dominates its traces: promote that sequence to code. Either way, evaluate the new design on the same labeled cases with repeated trials, and run it in shadow mode before it takes traffic.

When a constraint changes

Start from your own recommendation for each task, then decide whether each change alters it.

Predict the outcome

When a constraint changes

Each row changes one fact of the scenario. For each task, decide whether your recommendation changes and why, using figures where they apply, before you reveal the answers.

ChangeTask ATask B
Volume grows ten times, to 60,000 rescheduling and 20,000 stuck-parcel conversations a day, with the same prices and pilot rates??
A voice channel needs a p95 processing time of 3 seconds for both tasks??
A refund tool is added to Task B: a parcel stuck more than 5 days gets its delivery fee back??
A new partner carrier integration arrives every month, each with its own tracking tool and note format??
The Task B pilot had sampled only depot-backlog and customs-hold cases??
After a round of fixes, Agent A reaches 582 successful runs with no wrong rebooks and the same token use per run, and its p95 drops to 7.9 seconds??

Completion checklist

  • I can say who chooses the next step in a design and place it between a fixed workflow and an agent loop.
  • I can turn pilot counts and token figures into cost per successful task and a daily total that includes hand-offs.
  • I can use repeated trials and per-slice results to tell a missing path from run-to-run variance.
  • I can name the controls that stay in code whichever design runs a task.
  • I can name the changes that would reverse a workflow-or-agent decision and the evidence that would confirm them.

Sources

The parcel company, its tools, pilot cases, prices, handling cost, figures, and rubric are original synthetic teaching material about a fictional application; no real pilot or benchmark result is claimed. Study times and readiness thresholds are editorial estimates. Cited guides and frameworks are examples, not endorsements. Product, protocol, and model details are as of November 2026.

Practice the interview question

Answer it in your own words before you look at the reference answer.