Handbook

Part III · Designing the system · Chapter 7

Workflows before agents

Most requests for an agent are better served by a workflow you design. Five patterns, three lanes, and exits to a person built first.

15 min read

Clients ask for agents. What most of them need is a workflow: a sequence of steps you designed, in which a model handles the parts that need reading or judgment and ordinary code handles the rest. Workflows are cheaper and faster, and when something goes wrong you can point to the exact step.

What you'll take away

  1. 01A simple test for whether a request needs an agent at all.
  2. 02Five public workflow patterns, with the client situations each one fits.
  3. 03How to divide work between code, the model and people.
  4. 04Why the exits to a human are designed first.
  5. 05A real pipeline, the one behind this site's feed, and how to test workflows like it.

Workflow or agent?

Anthropic's engineering note on building effective agents puts the line in a useful place. In a workflow, you decide the steps and the model works within them. In an agent, the model decides what to do next, choosing tools as it goes. The note's advice, which matches field experience, is to start with the simplest thing that works and add autonomy only when it clearly pays.

WorkflowAgent
Who picks the next stepYou, in codeThe model, at run time
Best forWork that follows a known procedure, even a branching oneWork where the path depends on what is discovered
Cost and time per casePredictableVaries; needs a budget
Explaining one outcomeFollow the steps it tookReconstruct its reasoning from logs

One question settles most cases. Ask the client's most experienced person to talk you through how they handle a typical case. If they describe a procedure, with a few branches, you are looking at a workflow. If they say it depends entirely on what they find, an agent might earn its keep, and probably only for that part.

Five patterns that cover most requests

The same note names a handful of patterns that turn up repeatedly. They are worth knowing by name, because naming the pattern in a client meeting turns a vague "AI solution" into a design people can discuss.

CHAINfixed steps in order,each checkede.g.read invoice → checkagainst PO → draft queryROUTEclassify, then sendto a specialist pathe.g.billing / technical /complaint emailsFAN OUTindependent piecesat the same timee.g.check five clausesof one contract at onceCOORDINATEa lead step splitswork it can't predicte.g.a migration touchingan unknown set of filesDRAFT + CRITIQUEone step writes,another checks ite.g.tender answer reviewedagainst the rubricOnly 'coordinate' lets the model decide what the next step is, and it is the one to justify hardest
Fig 1. All five are designed by you. In the fourth, a lead step decides how to split the work, so it carries the most risk and needs the strongest case.

Real systems combine them. An insurer's inbox might route each email by type, chain a few steps for claims, and fan out to check several policy conditions at once, all without the model ever choosing what happens next.

Code, model, person: three lanes

Inside any pattern, give each piece of work to whoever does it best. Models are good at reading messy language and making judgment calls about meaning. They are poor at arithmetic, dates and following a rule exactly every time, which is precisely what code is good at. People are best at the cases that are rare, ambiguous or high-stakes.

Coderules, thresholds, dates and sums, permissions, lookups, anything an auditor will ask aboutModelreading messy text and images, judging meaning, sorting into fixed categories, draftingPersonexceptions, high stakes, anything the client's policy reserves for named peopleunsure? down a lane
Fig 2. When a step in one lane isn't confident, the work moves down a lane, never up.
  • Give the model closed questions. "Which of these five categories?" is far more reliable than "what should we do?". Validate the answer against the list in code and reject anything else.
  • Keep the rule in code, the reading in the model. The model extracts the delivery date from a letter. Code decides whether it is within the 30-day window.
  • Record why. Store each model judgment with its explanation and how sure it was, so a person can audit a decision without rerunning anything.
  • Keep randomness low for sorting and extraction. Two identical cases should get the same answer.

Design the exits before the happy path

Before drawing the normal route through a workflow, ask where cases leave it for a person. Start with the client's own rules. Most organisations already restrict certain decisions to certain people: refunds over a threshold, anything involving a child, a regulator or a complaint about staff. Those restrictions carry straight over. Then add your own: cases where the model isn't confident, where two facts contradict each other, or where the input doesn't match any category you planned for.

Make "send it to a person" the default when nothing else matches. A workflow that guesses on unfamiliar input will eventually guess badly in front of a customer. One that hands over looks cautious, and that is the point. If the client can't say which decisions are reserved for people, help them write it down before you build. It is often the most valuable document of the engagement.

Agree with the client what the system will never decide on its own, and build that first.

Case study: the Fieldwork feed

This site uses a workflow like this. Fieldwork scrapes hundreds of LinkedIn and X posts about forward deployed and GTM engineering. Most are recruiter posts, course promotions and job announcements. Keyword rules could not reliably tell a hiring post from a thoughtful post about hiring. Here is how the pipeline works.

Scraped postsLinkedIn and X471 judgedGate (code)mentions the field, readablelanguage, not duplicate spamOne request, three questionskind: insight, hiring, promotion…about the field: yes / no probabilitysubstance: score on a 0–3 rubricStore rawby field + URLcached by hashPolicy in codeconfidence below 0.3 → fall back to the rule classifierabout the field ≥ 0.5 and substance ≥ 0.3 → keepFeedinsight postswith real substanceJobshiring postsfor this fieldPeopleauthors weightedby what they postDroppedpromos, off-topic,hypeChange a threshold and rebuild, with no new API calls: the judgments are already stored.
Fig 3. The model answers narrow, typed questions. Code owns the thresholds, the fallbacks and what happens to each post.
  1. 1

    A gate in code

    Posts must actually mention the field, be in a readable language, and not be one of many near-identical copies. Rejected posts cost nothing.
  2. 2

    Three narrow questions in one request

    Using Jev, a typed-judgment API from TypeSafe: what kind of post is this (with each option defined, and what it is not), is it substantively about the field (a probability), and how much usable substance does it contain (a four-level rubric).
  3. 3

    Raw judgments are stored

    Probabilities and scores go into a file keyed by field and URL, with a hash of the text. A post is judged again only if its text changes, so daily refreshes cost almost nothing.
  4. 4

    Policy lives in code

    Keep insight posts that are at least 50% likely to be about the field and score at least 0.3 on substance. Below 0.3 confidence on the kind question, ignore the judgment and use the older rule-based classifier.
  5. 5

    Every outcome has a home

    Insights go to the feed, hiring posts become job leads, and authors are ranked by what they post. Promotions and off-topic posts are dropped.

Of 471 posts judged, 231 were classed as insight. 28 were dropped as only mentioning the field, and 17 for having little substance, leaving 186 for the feed. The 147 hiring posts were not wasted either: 129 of them became job leads. Three lessons transfer directly to client work.

  • Ask narrow questions. Three small typed questions were far more stable than one "is this post good?" prompt.
  • Say what each option is not. Most errors were near-misses between neighbouring categories. Writing the "not for" case fixed them.
  • Separate judgment from policy. Thresholds change weekly. Asking the model again should not have to.

Testing a workflow step by step

Because a workflow is made of steps, you can test each step on its own, which is much easier than judging the whole.

  1. 1

    Label a few dozen cases per model step

    Ask the client's experts for the right answer to each, using their own policy. Measure every model step against its own small set.
  2. 2

    Test the code steps like any code

    Unit tests for the rules, the thresholds and the date logic, with the boundary values.
  3. 3

    Run the whole thing end to end

    On a larger sample, and note for each wrong outcome which step it started in.
  4. 4

    Check the exits separately

    Feed it cases that must reach a person and confirm every one does. Count any that slip through as serious, however small the number.
  5. 5

    Replay after every change

    Stored judgments make this cheap. Fieldwork re-applies a changed threshold to every past post without asking the model anything.

When a client complains that too much is going to people, resist loosening the exits in general. Find the specific kind of case that is being sent unnecessarily and fix that, leaving the client's reserved decisions alone.

Try it

Design a tender-response workflow

An engineering consultancy answers about 40 public tenders a month. Each tender has 30 to 80 questions. Staff copy answers from past bids, adapt them, and a bid manager checks compliance with mandatory requirements (for example, insurance levels and certifications). Missing a mandatory item disqualifies the bid.

Choose the patterns, assign each piece of work to code, the model or a person, and name the exits.

Write your answer down first, then reveal the worked answer

Patterns: fan out over the questions, since each can be drafted independently, then draft-and-critique, where a second step checks each draft against the question and past answers. No agent is needed.

Code: extract the mandatory-requirement checklist from the tender into a table, and compare it with the firm's stored certificates and insurance levels. That is a lookup, not a judgment.

Model: find the most relevant past answers for each question, and draft an adapted answer citing which past bid it came from.

Person: every mandatory requirement the code couldn't confirm, any question with no good past answer, pricing, and final sign-off by the bid manager.

Exits: no draft is sent without a person; a missing or uncertain mandatory item stops the bid until someone resolves it. A strong answer keeps compliance checking out of the model entirely.

Go deeper

Practise the skills