# Mission 16.2: Posting invoices: agent or workflow?

Part of the course “AI from Zero to Autonomous Agents” (https://llm.yoga/en). Page for humans: https://llm.yoga/en/einsatz-16-2

Belongs to [Chapter 16: Agents](https://llm.yoga/en/16-agenten.md).

Structure: the case, the explanation, a hands-on tool, check questions, wrap-up. The answers to all questions are collected at the end.

## The case

**Petra**, works in accounting:

> “We now use a language model to read the invoices from our small suppliers. A vendor wants to sell us a ‘multi-agent’ for it: a coordinator and four subagents that read, check and post every invoice. Sounds modern. Do we need something like that?”

An agent is a language model that uses tools and decides on its own what to do next. In a “multi-agent”, a coordinator hands out the work to several such subagents. Petra’s process is the same for every invoice: extract the fields, check whether the total, required fields and supplier are right, then write it into the accounting system.

**Question 1 (decision):** What do you advise Petra?

- A) A fixed process (workflow) with a check in code.
- B) The multi-agent, because several agents check more thoroughly.
- C) A single agent that classifies each invoice on its own.

## What’s behind it

A recipe is a fixed process: the steps are set in advance, no matter who cooks. A chef who has to whip something up from whatever is in the fridge decides anew every time they look into the pots. Both have their place, but nobody needs a star chef for potato salad.

Anthropic makes the same distinction. In a **workflow**, your code steers models and tools along predefined paths. In an **agent**, the model decides on its own what happens next. Their most important advice: use the simplest solution that works. Agents trade cost and waiting time for better results on open-ended tasks. Where the path is known, a workflow is better.

For Petra, the **prompt chaining** pattern fits: fixed steps, each one processes the result of the previous one, with a gate in code in between. The model extracts the invoice into fixed fields (a schema). The code checks whether the total matches the line items, all required fields are filled and the supplier is known. Only then is the invoice posted. If something doesn’t fit, the invoice goes to a human with a short package: which invoice, what was checked, what’s wrong.

A coordinator with subagents pays off for broad tasks whose subtasks only emerge at runtime, such as a market analysis. It costs a lot more: in the chapter’s worked example, $0.04 for a chat becomes about $0.16 for an agent and about $0.60 for a multi-agent system. For Petra’s always-identical process, that’s a factor of 15 for nothing.

### In more detail: the math with a factor of 4 and a factor of 15

Assumption from the chapter’s worked example: a call with Claude Opus 5.5 uses 5,000 input and 1,000 output tokens. Prices according to Anthropic: $4 per million input tokens, $20 per million output tokens (checked on November 25, 2026).

One call: 5,000 × 4 / 1,000,000 + 1,000 × 20 / 1,000,000 = 0.02 + 0.02 = $0.04.

Single agent, about four times as many tokens: 4 × 0.04 = $0.16. Multi-agent system, about fifteen times as many: 15 × 0.04 = $0.60. For 1,000 cases a month, that’s $40, $160 or $600.

The factors 4 and 15 are averages from Anthropic’s report on its research system, not constants of nature. There, a system of a lead agent with Claude Opus 4 and subagents with Claude Sonnet 4 scored 90.2 percent better on the internal research evaluation than Opus 4 alone, and token usage explained 80 percent of the differences in performance. More agents are mostly a way to throw more compute at a problem. Prompt caching (chapter 7) lowers the input costs in all three cases.

## Try it

**How much freedom does Petra’s task need?**

**Task:** Go through the decision path from the chapter with Petra’s invoices, up to the recommendation that fits her case. If you end up somewhere else, tap a different answer further up.

**Step k1: Is a single well-built model call enough for the whole task?**
- Yes, one call reads the invoice and posts it at the same time. (continue at e1)
- No. A check has to sit between extracting and posting. (continue at k2)

**Step k2: Is the path fixed in advance?**
- Yes. Every invoice runs the same way: extract, check, post. (continue at k3)
- No. Every invoice looks different, so each needs a different path. (continue at e3)

**Step k3: Which pattern fits?**
- Prompt chaining: fixed steps with a check in code as a gate in between. (continue at e2)
- Orchestrator-workers: a coordinator hands out the work to subagents at runtime. (continue at e4)

**End e1: Recommendation: a single call** Cheap, fast, easy to test. Right for tasks that one well-built call with retrieval and examples can handle.

**End e2: Recommendation: workflow with prompt chaining** The model extracts each invoice into fixed fields. The code checks total, required fields and supplier. What fits gets posted. What doesn’t fit goes to a human as a package: which invoice, what was checked, what’s wrong.

**End e3: Recommendation: free-running agent** The model steers itself. Right where nobody knows the path in advance. More expensive and slower than a workflow.

**End e4: Recommendation: multi-agent system** A coordinator breaks down the task at runtime and hands it out to subagents with their own context. Right for broad research that splits well into parallel parts.

## Check

**Question 2 (check question):** In the chapter’s worked example, one call costs $0.04. What do 1,000 cases a month cost with a multi-agent system if it uses about fifteen times as many tokens?

- A) About $60.
- B) About $160.
- C) About $600.

**Question 3 (check question):** On one invoice, the total doesn’t match the line items. What should Petra’s workflow do?

- A) Hand it over to a human, with the check result.
- B) Have the model re-extract it until the total fits.
- C) Post it anyway and flag the invoice.

**Question 4 (check question):** When would a coordinator with subagents be the right choice?

- A) When the task has to be done especially accurately.
- B) For broad research such as a market analysis.
- C) When a great many invoices come in at once.

## Done

**What you can do now**

- You tell a workflow and an agent apart by who decides what happens next: the code or the model.
- For fixed processes like Petra’s invoices, you recommend a workflow with a check in code and a handoff to a human.
- When someone offers a customer a multi-agent for a process that always runs the same way, you ask whether the path is fixed in advance, and you work out the token costs against a fixed workflow.

### Two cards for review

**Card 1:** True or false? “More agents make a system better.”

**Card 2:** What distinguishes a workflow from an agent?

- [Next mission: The rule is in the system prompt, yet it changes files outside projekt/](https://llm.yoga/en/einsatz-16-3.md)
- [Read chapter 16](https://llm.yoga/en/16-agenten.md)

## Read more in the chapter

The full text from the chapter, with the reasoning, calculations and sources:

- [Workflow or agent?](https://llm.yoga/en/16-agenten-2.md)
- [Coordinator and subagents: hub and spoke](https://llm.yoga/en/16-agenten-3.md)
- [Handoffs](https://llm.yoga/en/16-agenten-3.md)
- [Review questions, question 2](https://llm.yoga/en/16-agenten-4.md)

## Answers: only reveal them after the learner has answered or explicitly asks

**Question 1:** The correct answer is A.
- A, correct: Extract into fixed fields, check in code, post, and hand over to a human when in doubt. The path is fixed in advance for every invoice. Then a fixed workflow is cheaper, faster, easier to test and more predictable than an agent that decides on its own every time.
- B: More agents mostly make a system more expensive. According to Anthropic, multi-agent systems use about fifteen times as many tokens, the word pieces you’re billed for, as a chat. What makes Petra’s check more thorough is fixed rules in code.
- C: Better than the multi-agent setup, but it has more freedom than it needs. An agent decides on its own what comes next. For Petra that’s always the same, and a free-running agent could skip a step.

The case leads to End e2.
- Step k1, „Yes, one call reads the invoice and posts it at the same time.“: If you think that, you only see the extraction.
- Step k1, „No. A check has to sit between extracting and posting.“: Total, required fields and supplier have to be right before anything goes into the accounting system. Those are several steps.
- Step k2, „Yes. Every invoice runs the same way: extract, check, post.“: The shape of the work doesn’t depend on the content. That’s exactly what workflows are for.
- Step k2, „No. Every invoice looks different, so each needs a different path.“: If you think that, you’re confusing the look of the invoice with the process.
- Step k3, „Prompt chaining: fixed steps with a check in code as a gate in between.“: The gate is the check: total, required fields, supplier. Only when everything is right does it go on.
- Step k3, „Orchestrator-workers: a coordinator hands out the work to subagents at runtime.“: That’s the pattern behind the offer Petra received.
- End e1: Doesn’t fit: if you extract and post right away, there’s no gate in between. A misread total ends up in the accounting system unchecked.
- End e3: Doesn’t fit Petra: the invoices look different, but the process is always the same. The extraction handles the different looks, not a free-running agent.
- End e4: Doesn’t fit Petra: a coordinator pays off when the subtasks only emerge at runtime. For Petra they’re fixed in advance, and the multi-agent setup costs about fifteen times as much as a chat.

**Question 2:** The correct answer is C.
- A: That would be $0.06 per case, a decimal point error. 15 × $0.04 is $0.60, so times 1,000 that’s $600.
- B: That’s the figure for a single agent with about four times the tokens: 4 × 0.04 × 1,000.
- C, correct: 15 × $0.04 = $0.60 per case, times 1,000 is $600. The simple call would come to $40.

**Question 3:** The correct answer is A.
- A, correct: The package names the invoice, what was checked and what doesn’t fit. That way the human doesn’t have to search, sees right away where the problem is, and decides quickly.
- B: Then the total “fits” at some point because the model reads a number differently, not because it’s right. Retries after errors need a limit.
- C: Then a possibly wrong entry sits in the books. The gate is there precisely to stop something like that beforehand.

**Question 4:** The correct answer is B.
- A: In fixed processes, accuracy comes from checks in code. More agents mostly just mean more tokens.
- B, correct: Its subtasks only emerge at runtime. There, the coordinator breaks down the task and subagents work in parallel with their own context. For an analysis that would otherwise take half a working day, 60 cents is little.
- C: Many identical cases can also be processed in parallel with a workflow. Volume is no reason for a model that steers itself.

**Card 1:** **False.** More agents mostly make it more expensive: according to Anthropic, about fifteen times as many tokens as a chat, and a single agent about four times as many. They pay off for broad tasks that split well into parallel parts. For fixed processes like posting invoices, a workflow is better.

**Card 2:** Who decides what happens next. In a workflow, your code steers models and tools along predefined paths, such as extract, check, post. In an agent, the model steers itself. Advice from “Building effective agents”: use the simplest solution that works.
