Skip to content
The AI Agent Factory

Check yourself

Approved by
Panaversity ·
8 min read

Answer each question in a few lines, then compare with the outline below it.

  1. 25.1. You want to change one word of the extraction prompt. What must happen before the 7:10 run uses the new words, and who reads the results? Outline: the change goes into a copy of the file with the next version in its name. A pull request shows a reviewer only what changed, and the suite runs on it. The suite reads the results, because nobody reads every answer.
  2. 25.2. Code writes every turn of the extraction request. Where do the rules, the task and the invoice go, and which wins on a conflict? Outline: the operator's rules go in the system prompt, and the task for this run goes in the user turn. On a conflict, the rule wins. The invoice goes in neither, because a vendor wrote it. It goes in a tool result.
  3. 25.3. What does an output constraint say, and why does the check in code stay? Outline: the field names, the type of each and the allowed values, whether any text may come before or after, and what to write when the data is absent. A constraint in a prompt is a request, and the model can still miss it, so it never replaces the check.
  4. 25.4. When is the right number of examples none, one, and a few? Outline: none while the instruction and the constraint pass the suite. One when the form is wrong and the task is simple. A few that differ when one example narrowed the output, or when hard cases need showing. An example is never one of the suite's cases.
  5. 25.5. Name the three rules for third-party text, and say what they do not do. Outline: put it only in a tool result, JSON-encode it, and put none of your own instructions in a tool result. Marking tells the model whose text it is reading. It does not stop a model from being fooled, and those defenses are Chapter 28's subject.
  6. 25.6. One case is red. What are the six steps, and why is the last run before a merge never the one case alone? Outline: reproduce it, name the failure, find the missing piece, change one thing, run the whole suite, and keep the case. A change that fixes one case can break others, and only the suite re-reads them.
  7. 25.7. Why does the list of terms end with "other", and why is poNumber nullable? Outline: with only five values allowed, the model must pick one of them even when the invoice prints something else. "other" lets it say "this is not one of yours", and null lets it say "not on the invoice", both inside the form. The schema holds the shape, never the truth.
  8. 25.8. The extraction step fetches the invoice and returns its fields. Which feature holds each, and how does the code know the invoice was fetched? Outline: fetching is an action, so get_invoice is a strict tool. The fields are data, so they are a structured output. Current Claude models reject a forced tool, so tool choice stays on auto, and the code checks that the tool was called.
  9. 25.9. Name the five value checks, and say when the code sends a failure back to the model. Outline: each number is in its range, the total is the subtotal plus tax, the vendor exists, the purchase order exists when one is named, and the terms are not "other". A failure goes back, at most twice, only when the invoice can settle it. Everything else goes to Ana as needs_review, with the gate and the reason.
  10. 25.10. A response arrives. What does the code read first, and what does it do with a decline, and with an answer cut at the output limit? Outline: the stop reason, before it parses anything. A decline is marked needs_review, and the same request is never sent again unchanged. A cut answer is failed even if its text parses. The code asks once more with a higher limit, and a second cut answer goes to needs_review.
  11. 25.11. You move the extraction step to another API. Which jobs can an API do, and which stay in your code on every runtime? Outline: an API can rank who is speaking, hold a schema and report why it stopped. No API re-reads after a change, knows a wrong value or asks someone. Those stay yours: the versioned prompt file and the suite, the value checks, and needs_review.

Chapter 25: Prompts and Structured Output

Recall cards for the seven jobs a person did when they read the worker's answer, and what does each job now that code reads it.

1 / 16

Chapter quiz

Practice

Question 1 / 10 · drawn from 77

0 answered

On Friday, April 9, a pull request shortened the worker's prompt. What kept the broken prompt away from the morning run?

Owner
Panaversity

On this page