One interface for scripted, replayed, local and hosted models
About 17 minutes to read, with 4 examples in 5 sections.
Written with AI. Verified by people. How we make books
This book is open to contributions, so anyone can check it or correct it. Its repository · Report an error · How to fix one
Labs
Learn this chapter by doing it
Run every example exactly as the book did, change the code to see what happens, and try your own ideas on the book's code and data. Nothing to install, and your work is saved. Opens in about 30 seconds.
Run every example exactly as the book did, change the code to see what happens, and try your own ideas on the book's code and data. Nothing to install, and your work is saved. Labs runs it for you: 40 hours a month.
On your own machine, free: download the book's notebooks, with its code and data, from GitHub.
Chapter 1 of every book is read aloud for everyone; every chapter with Labs. See plans, or sign in.
Read by an AI voice, word for word from this edition's text. Code, output and tables are on the page.
Pocket TTS by Kyutai, voice alba, from Alba MacKenna's recordings, CC BY 4.0.Pocket TTS by Kyutai, voice eve, from VCTK corpus speaker p361, CSTR, University of Edinburgh, CC BY 4.0, adapted by Kyutai.
Your browser can translate this page from its menu, and the code stays as the book has it.
Or read it with your AI assistant:
By the end of this chapter you can run the same loop on a scripted model, a replayed run, a local model and an OpenAI-compatible endpoint, without changing the loop. You can also say what each adapter keeps from a reply, and what it reads out of the reply's text.
Chapter 1 ran the maintenance agent for unitcraft on a scripted model, then on a stored run, and the loop took both without a change. The next question is what a model has to hand over for that to work. For T-01, the issue that format_quantity drops trailing zeros, so 3.5 kg prints as 3.5 kg where the default of two places gives 3.50 kg, every step needs the same three things back: the model's text, the tool calls the harness can read from that text, and the counts of tokens the request and the reply used. A scripted list of strings can supply all three. So can a file on disk, a model loaded in memory, or an HTTP endpoint. The adapter is the code that makes each of those sources look the same to the loop, and the rest of this chapter takes the four adapters in the order the loop meets them.
Ask every model the same question
The loop needs one thing from a model: given the messages so far and the tool schemas from the schema chapter, return what the model said. A Python Protocol names that contract. Every adapter in this book has the same method, and every adapter returns the same kind of value.
class Model(Protocol):
def reply(self, messages: list[dict], tools: list[dict]) -> Reply: ...
The Reply is a small dataclass. It holds the model's raw text, the tool calls the adapter read from that text, any malformed blocks it could not read, the prompt and completion token counts, and the finish reason, which says whether the model stopped on its own or ran out of tokens. A token here is the unit that chapter 1 counts, from the pinned model's own tokenizer, so the counts belong to that model and mean nothing for another. The adapter never edits text. The loop acts on the calls, but the transcript keeps the text as the model wrote it, so a reader can see what the model actually said.
Keeping both the text and the calls matters because parsing can fail. A reply may hold a <tool_call> block whose JSON does not parse, or a block that is never closed. The adapter cannot quietly turn such a reply into a call, and it cannot throw the reply away, because the loop has to tell the model what went wrong. So the parse leaves the text as it is, records a short reason for each bad block beside it, and lets the loop decide what the model sees next. The local model section shows the parser at work.
A Protocol looks like an interface, but Python checks it by shape. Python's typing documentation says that a runtime_checkable protocol "will check only the presence of the required methods or attributes, not their type signatures or types." So isinstance can confirm that an object has a reply method, and nothing more: a class whose method is written reply(self, prompt) passes, and a class with no reply fails. The book's own Model is not decorated with runtime_checkable, and the same documentation says isinstance on such a protocol raises a TypeError. No example in this book calls isinstance on Model, so both claims are the documentation's and not run here.
Working rule: Test each adapter by calling reply() with the messages and tool schemas the loop sends, and check the fields of the Reply that come back. Use isinstance only to see that a method exists, never to show that its signature is right.
Script the replies, or replay a stored run
Two adapters need no model at all. Chapter 1's scripted run used a scripted model, and its replayed run used a stored one. Both work for the same reason: the loop is the thing under test, and a fixed list of replies keeps the model out of it. This section says what the adapters add to that.
ScriptedModel takes strings or Reply objects. A string is parsed into a Reply for you, and its tool calls are read from the <tool_call> blocks in the text. A Reply object is passed through unchanged. That second form lets a test set the token counts or a malformed entry directly, instead of writing JSON that must fail in exactly the right way. If the loop asks for more replies than the script holds, the model raises an IndexError, so a short script fails loudly rather than returning nothing. The script also keeps a test readable. The reply that causes a behaviour sits in the test beside the assertion about it, and the reader does not have to open a recording to find it.
ReplayModel reads one run's rows from the recording's replies.jsonl, in step order. Each row holds the request's hash as it was sent, the reply's text and the token counts. When the loop asks for a step, ReplayModel hashes the request it was given, the sha256 of its messages and tool schemas in canonical JSON, and compares that hash with the row's. A difference raises ReplayMismatch, which names the step. The counts come from the stored row, so a replay never tokenizes again.
The rows come from a logger, not from a script. LoggedModel wraps a live model and appends each reply to a JSON-lines file before the loop sees it. A run that stops partway leaves its rows on disk, and the recording script removes them before it resumes.
Chapter 1's T-01 run goes through the loop twice in the first example: once on a ScriptedModel that holds the stored reply texts, and once on the ReplayModel for the same run. The scripted replies are read from the stored file, so both runs start from the same source.
1"""Chapter-1-t01 runs through the loop twice: once with a ScriptedModel holding the stored reply texts, once with a2ReplayModel. The assert compares the two runs' step lines, and the lines printed below are the replayed run's."""3import json45from lib.case import load_tasks6from lib.loop import run_task7from lib.models import RECORDED, ReplayModel, ScriptedModel8from lib.tools import CH19from lib.trace import IdCounter1011task = load_tasks(only=["T-01"])[0]12rows = [json.loads(line) for line in (RECORDED / "chapter-1-t01" / "replies.jsonl").read_text(encoding="utf-8").splitlines()]131415def run_once(model):16 run = run_task(model, task, CH1, max_steps=CH1.step_cap, ids=IdCounter()) # counter-based IDs, never random (P-3)17 try:18 return list(run.trace.lines()), run.steps, run.ended19 finally:20 run.close()212223scripted = run_once(ScriptedModel([row["text"] for row in rows]))24replayed = run_once(ReplayModel("chapter-1-t01", "T-01"))25assert scripted == replayed, "the two adapters gave the loop different steps"26lines, steps, ended = replayed27for line in lines:28 print(line)29print(f"steps: {steps}")30print(f"ended: {ended}")
python same-loop-two-models.pystep 1: read_file: 23 lines
step 2: run_tests: 8 failed, 22 passed
step 3: malformed: error: malformed call
step 4: malformed: error: malformed call
step 5: malformed: error: malformed call
step 6: malformed: error: malformed call
step 7: malformed: error: malformed call
step 8: malformed: error: malformed call
steps: 8
ended: step_cap
The loop made the same calls both times, and the example stops if the two runs differ in any step line. The run is the one that hit the step cap in chapter 1: it ended as step_cap after 8 steps. The loop cannot tell the two adapters apart, so whatever the loop does with a reply, it does the same for either source.
The second example checks the recording itself, against its manifest, and then replays it.
1"""The stored chapter-1 run is the recording its manifest describes, and replaying it hands the loop each stored reply text2exactly. The prompt and the check hash to the manifest's values, the first request hashes to the reply row stored with it,3and the stored replies add up to the manifest's counts. The run is then replayed through the loop, which refuses any request4that differs from its recorded hash, and each replayed text is compared with its stored text. No model file is loaded."""5from contextlib import closing67from lib.case import load_tasks8from lib.loop import run_task9from lib.models import RECORDED_SAMPLING, ReplayModel, TextCapture, first_step, load_recording, request_hash, same_texts, stored_totals10from lib.prompts import prompt_sha25611from lib.tasks import check_sha25612from lib.tools import CH113from lib.trace import IdCounter1415task = load_tasks(only=["T-01"])[0]16manifest, rows = load_recording("chapter-1-t01")17messages, tools = first_step(task, CH1)18assert manifest["prompt_sha256"] == prompt_sha256(CH1.system, CH1.descriptions()), "the prompt changed since recording"19assert manifest["check_sha256"] == check_sha256(task), "the check changed since recording"20assert rows[0]["request_sha256"] == request_hash(messages, tools), "the first request differs from the stored reply row"21assert len(rows) == manifest["steps"], "the stored replies and the manifest disagree on the step count"22prompt_tokens, completion_tokens = stored_totals(manifest, rows)23assert manifest["sampling"] == RECORDED_SAMPLING, "the recording's sampling differs from the settings the adapters send"2425capture = TextCapture(ReplayModel("chapter-1-t01", "T-01"))26with closing(run_task(capture, task, CH1, max_steps=CH1.step_cap, ids=IdCounter())) as run:27 steps, ended = run.steps, run.ended28compared = same_texts(rows, capture.texts)29assert steps == manifest["steps"] and ended == manifest["ended"], "the replay did not end as the manifest records"30print(f"stored replies: {len(rows)}")31print(f"prompt tokens: {prompt_tokens}")32print(f"completion tokens: {completion_tokens}")33for key in ("temperature", "top_k", "seed"):34 print(f"{key}: {manifest['sampling'][key]}")35print(f"reply texts compared exactly: {compared}")36print(f"steps: {steps}")37print(f"ended: {ended}")
python replay-byte-for-byte.pystored replies: 8
prompt tokens: 13009
completion tokens: 2128
temperature: 0
top_k: 1
seed: 4217
reply texts compared exactly: 8
steps: 8
ended: step_cap
Here the manifest is the reference, and the example makes four checks. The prompt's hash and the check's hash are compared with the manifest's values, where the check is the hidden test, H-01, that chapter 1 grades T-01 with. The first request's hash is compared with the one stored in its reply row in replies.jsonl, because the manifest holds no request hash. The stored replies must match the manifest's step count and token totals, and the sampling settings are printed from the manifest and compared with RECORDED_SAMPLING in the library, the values loopback_model sends. The stored run has 8 replies, 13009 prompt tokens and 2128 completion tokens. The example prints its sampling settings on their own lines, so a reader sees the temperature, the top k and the seed the recording used.
Then the run goes through the loop. ReplayModel refuses any step whose request hash differs from its row, and the example compares each replayed text with its stored text, exactly. It prints the count it compared, 8, and the run ends as the manifest says. The manifest holds no hash for each reply, so the stored texts are not checked against an independent value. The check shows that replay hands the loop each stored text unchanged. The prompt hash covers the system message and the tool descriptions together, so a changed tool description changes the recording's identity as surely as a changed line of code does.
Working rule: Replay a recorded run only with the prompt and the check it was recorded with. When either changes, its hash in the manifest no longer matches, the example fails, and the run has to be recorded again. Changing a stored reply to make the example pass hides the change that caused the failure.
A local model, and why its settings are fixed
LlamaModel runs a local model. It loads a GGUF file, the single-file format llama.cpp reads, through llama-cpp-python. The adapter imports the library only when a model is built, so the examples never load it. No example loads the GGUF file, and the book has no test of LlamaModel. The recording used it, and the examples read the replies that recording stored. Its reply() calls create_chat_completion with the messages and the tools, and it reads the text and the usage from the answer.
The library's defaults are not the book's. At the pinned release, llama-cpp-python's create_chat_completion defaults to a temperature of 0.2 and a top k of 40. An adapter that leaves those alone samples differently from this one. LlamaModel passes temperature=0 and top_k=1 on every call, so the sampling is written in the code rather than inherited from the library.
What comes back is text. The recording's server ran the pinned llama-cpp-python as python -m llama_cpp.server on the same model file, and it returned the first step's tool call inside the message content. The stored body from the endpoint recording has that content and no tool_calls field at all:
<tool_call>
{"name": "read_file", "arguments": {"path": "unitcraft/format.py"}}
</tool_call>
So the library's reply carries the call as text, and LlamaModel does not read a structured field from it. It parses the text.
Parsing is one function, parse_tool_calls. It finds each <tool_call> block, reads it as JSON with a name and an arguments object, and keeps the call. A block that does not parse becomes a malformed entry with a short reason. The loop shows that entry to the model as a tool error, so a bad call is recorded as a step and not dropped. Chapter 1's T-01 run, in what goes wrong, shows this: after its first two steps, every step is error: malformed call.
The finish reason matters to the loop. stop means the model ended its answer, and length means the reply reached the token limit the adapter set. A length reply can stop in the middle of a <tool_call> block, which is why the parser also reports an unclosed block as malformed rather than reading it as complete.
The counts are the library's own. LlamaModel copies the prompt and completion token counts that llama-cpp-python reports into the Reply, and the recording stores them. They describe the tokenizer of the pinned file, so a different file gives different counts for the same messages, and a count from one model cannot be compared with a count from another.
The constructor takes the file's path, the context size, the thread count, the seed and the token limit, and nothing else about the model. The recording reads its values from recordings/local_model.py, so a reader who wants to load a different file changes the path and those settings together, and records again. The sampling is a choice, and the model card recommends another. The Qwen model card says, "We suggest using Temperature=0.7, TopP=0.8, TopK=20, and MinP=0." Those settings suit answers that vary from one run to the next. This book records a run once and checks later runs against the stored replies, so it uses temperature 0, top k 1 and a fixed seed, 4217, as the manifests record. Those settings give a re-recording its best chance of matching, but temperature 0 does not guarantee that output repeats, so the book claims no more than its examples show. The endpoint example checks that two requests on one recording gave the same text. Replay does not depend on sampling at all, because it reads the stored text.
Working rule: Record with the sampling the manifest names, and keep the model file's hash in the manifest beside it. If you change a setting, the replies change with it, so record the run again rather than compare it with the old one.
A hosted-style endpoint, tested on loopback
A server that accepts OpenAI's chat-completions request shape can be reached by one adapter, given a base URL and, where the host asks for one, a key. OpenAICompatibleModel posts the messages, the tool schemas and the sampling settings to /chat/completions. It uses the standard library's urllib and no SDK. Without an SDK, nothing hides the request: request_body() returns the body the adapter serialises and sends, and a test can compare it with what was recorded. The top_k field is sent only when the adapter was given a value for it. The adapter refuses two things when it is built, before any request: a URL that is not http or https, and a key sent over plain http to any host but loopback. It also never follows a redirect. A redirect raises an error, so a key is never sent to a second URL.
The response has the tool call in one of two places. OpenAI's reference describes a tool call's function.arguments as a string that the model generates in JSON, and tells the caller to "Validate the arguments in your code before calling your function." The adapter parses that string when the reply has a structured tool_calls field. When the field is missing, it falls back to the <tool_call> text, as the local model does. parse_chat_body keeps message.content as the server sent it, reads a missing content as empty text, and copies the usage counts into the Reply, so a stored body parses to the same Reply every time. Either way, the arguments reach the loop as a dictionary, and the dictionary is not yet checked. The tool's argument model from the schema chapter does that check.
No example in this book sends a request that returns a structured tool_calls field, so the first branch exists as code and is not run by any example. The book does not show what other providers return in that field, and this chapter says no more about it than the OpenAI reference does.
The recording used the same file and the same sampling as the local model. It ran the pinned llama-cpp-python's own server on loopback, and sent T-01's first step through the adapter twice. The stored file holds each request as sent and each raw response body. A loopback http.server serves those bodies in order, and it answers 409 to any request whose body differs from the recorded one. The stub compares the request body, every message and every setting. It does not compare the path, the method or the headers, so a change to the endpoint's path or to the Authorization header would pass. If a change to the adapter alters the body it sends, the request fails before any reply is read. The stored bodies keep the server's own id and created fields. Nothing compares or prints them. Because no model is loaded, the adapter's HTTP and parsing code runs every time the book's examples are checked.
1"""The OpenAI-compatible adapter, run live against a loopback stub that serves the bodies recorded from llama.cpp's own2server. The line that matters is "raw text": the server put the call in the message content as text, with no tool_calls3field, so the adapter parses the text, and the tool's own model accepts the arguments. Needs4recordings/openai_compatible.py to have been run; until then this raises."""5import json67from lib.case import load_tasks8from lib.models import first_step, loopback_model, serve_recorded9from lib.tools import CH11011task = load_tasks(only=["T-01"])[0]12messages, tools = first_step(task, CH1)13bodies: list[str] = []14with serve_recorded("openai-compatible") as base_url:15 model = loopback_model(base_url, on_body=bodies.append)16 first = model.reply(messages, tools)17 second = model.reply(messages, tools)18assert first.text.lstrip().startswith("<tool_call>"), "the server should return the call as text"19assert "tool_calls" not in json.loads(bodies[0])["choices"][0]["message"], "the recorded body has a structured tool_calls field"20assert len(first.tool_calls) == 1 and first.tool_calls[0]["name"] == "read_file", "the first step is one read_file call"21assert not first.malformed, "the call should parse"22CH1.get("read_file").args.model_validate(first.tool_calls[0]["arguments"]) # raises if the arguments do not fit the tool23assert first.text == second.text, "the two recorded responses differ"24print(f"requests: {len(bodies)}")25print("raw text:", json.dumps(first.text))26print("structured tool_calls field: absent")27print(f"tool calls: {len(first.tool_calls)}")28print("call:", first.tool_calls[0]["name"], json.dumps(first.tool_calls[0]["arguments"], sort_keys=True))29print(f"malformed: {len(first.malformed)}")30print(f"prompt tokens: {first.prompt_tokens}")31print(f"completion tokens: {first.completion_tokens}")32print(f"finish reason: {first.finish_reason}")
python openai-compatible-loopback.pyrequests: 2
raw text: "<tool_call>\n{\"name\": \"read_file\", \"arguments\": {\"path\": \"unitcraft/format.py\"}}\n</tool_call>"
structured tool_calls field: absent
tool calls: 1
call: read_file {"path": "unitcraft/format.py"}
malformed: 0
prompt tokens: 501
completion tokens: 22
finish reason: stop
The adapter gets back one read_file call, as text. Checking its arguments against the tool's model falls to the caller, and that check is this section's whole point, so the example makes it explicit. The reply carries 1 tool call and 0 malformed blocks, and the request used 501 prompt tokens. The reply stops with stop, which means the model finished its answer on its own and did not run out of tokens.
The helper that builds the adapter for the recordings and the example, loopback_model, fixes the model alias the server was started with, a limit of 1024 tokens for each reply, temperature 0 and top_k 1. A caller that wants other settings builds OpenAICompatibleModel directly, and the request body it sends then differs, which the stub will refuse.
The proxy works as it does for any urllib request, except for loopback hosts, 127.0.0.1, ::1 and localhost, which are reached directly. A remote http URL goes through the proxy the environment names. A stub stands in for the proxy in the refusal example, and it shows both halves: the loopback requests never reach it, and the remote request arrives with its full URL.
1"""The OpenAI-compatible adapter refuses a redirect, a key over plain http to a remote host, and a non-http scheme. It sends2a remote URL through the environment's proxy and a loopback URL around it. Every request goes to a stub on 127.0.0.1, which3stands in for both the endpoint and the proxy, so no network is used. Each refusal prints one labelled line."""4from lib.models import OpenAICompatibleModel, proxy_env, refusal, stub_endpoint56REMOTE = "http://remote-host.invalid/v1"7MESSAGES = [{"role": "user", "content": "ping"}]89with stub_endpoint(200) as proxy, stub_endpoint(302) as target, proxy_env(proxy):10 loopback = f"{target.url}/v1"11 model = OpenAICompatibleModel(loopback, "model", max_tokens=8, api_key="DUMMY-KEY")12 reason = refusal(lambda: model.reply(MESSAGES, []))13 assert target.seen == ["/v1/chat/completions"], "a redirect was followed"14 print("redirect 302 on loopback:", reason)15 target.code = 30716 reason = refusal(lambda: model.reply(MESSAGES, []))17 print("redirect 307 on loopback:", reason)18 assert target.seen == ["/v1/chat/completions"] * 2, "a redirect was followed"19 print(f"requests to the redirect target: {target.seen.count('/collect')}")20 print(f"loopback requests through the proxy: {len(proxy.seen)}")2122 remote = OpenAICompatibleModel(REMOTE, "model", max_tokens=8)23 reply = remote.reply(MESSAGES, [])24 assert reply.text == "ok" and proxy.seen == ["http://remote-host.invalid/v1/chat/completions"]25 print("remote request through the proxy:", proxy.seen[0])26 print("remote reply text:", reply.text)2728 reason = refusal(lambda: OpenAICompatibleModel(REMOTE, "model", max_tokens=8, api_key="DUMMY-KEY"))29 print("key over plain http to a remote host:", reason)30 assert len(proxy.seen) == 1, "a request was made for the refused key"31 OpenAICompatibleModel("https://remote-host.invalid/v1", "model", max_tokens=8, api_key="DUMMY-KEY")32 print("key over https to a remote host: accepted, no request made")33 OpenAICompatibleModel(loopback, "model", max_tokens=8, api_key="DUMMY-KEY")34 print("key over http to loopback: accepted")35 reason = refusal(lambda: OpenAICompatibleModel("file:///v1", "model", max_tokens=8))36 print("file URL:", reason)
python adapter-refuses-unsafe-endpoints.pyredirect 302 on loopback: the endpoint answered 302 with a redirect, and the adapter does not follow redirects
redirect 307 on loopback: the endpoint answered 307 with a redirect, and the adapter does not follow redirects
requests to the redirect target: 0
loopback requests through the proxy: 0
remote request through the proxy: http://remote-host.invalid/v1/chat/completions
remote reply text: ok
key over plain http to a remote host: the adapter sends an API key over https, or over http to a loopback host only
key over https to a remote host: accepted, no request made
key over http to loopback: accepted
file URL: the scheme 'file' is not http or https
The example also shows each refusal: a redirect, a key over plain http to a remote host, and a file address. The redirect's target receives no request, and the other two are refused before any connection is made. Each refusal prints the rule that caused it.
This chapter calls no hosted provider. If you point the adapter at one, use https, which a key needs anyway, and bring your own account and key. The book supplies neither, and its examples never call a model or a remote host.
Working rule: Parse function.arguments as JSON, check the result against the tool's argument model, and send a failure back to the model as a tool result. An endpoint that enforces a strict schema makes such a failure rarer, but the check still runs.
One loop, several models
The loop does not change between adapters. It calls reply(), reads the calls from the Reply, runs the first one, and writes the result into the next step. The adapters differ in where the reply comes from and in what they do with its text, and the loop sees only the Reply each one returns.
| Adapter | Where the reply comes from | Calls are read from | Shown by |
|---|---|---|---|
ScriptedModel |
strings written in the code | the text | same-loop-two-models |
ReplayModel |
the stored replies of one run | the text | same-loop-two-models, replay-byte-for-byte |
LlamaModel |
a local GGUF file, through llama-cpp-python | the text | none; see the local model |
OpenAICompatibleModel |
an HTTP endpoint, on loopback in this book | the structured field if present, else the text | openai-compatible-loopback, adapter-refuses-unsafe-endpoints |
Each row says what an adapter does, and the last column names the examples that run it. Two examples drive ScriptedModel and ReplayModel through the loop, and two call OpenAICompatibleModel's reply() directly.
Production breaks an adapter in three places, and the reader should know which one they are looking at. The first is the transport. urllib raises on an error status, and the adapter does not catch that. The adapter refuses redirects on purpose, so a redirect raises as well. Either way no Reply exists for that step, and the run stops with the error. The second is the reply's shape: a reply can parse and still name a tool the loop does not have, and the name check in chapter 3 refuses it as a tool error. The third is the stored run. If the prompt changes, replay-byte-for-byte fails at its first assertion, before any step runs. If a later version of the loop asks a different question at some step, ReplayModel raises ReplayMismatch at that step, and the message names the step. A malformed tool call from a live model is different again: it is an expected event, and the loop counts it and shows it to the model.
What holds the loop steady is one parser and one Reply. Every adapter, live or stored, hands the loop the same fields, the text stays as the model wrote it, and a request hash stored with each reply makes a changed question fail at the step where it changed. The endpoint adapter is the one that touches a network, and its rules are the ones to re-check before it points at a real host: no redirects, no key over plain http, and the proxy for remote URLs only.
Adding a fifth adapter takes three steps. Write a class with a reply() method that takes the loop's messages and tools. Build its Reply with the same parser the others use, make_reply for text or parse_chat_body for a response body, so every adapter reads tool calls the same way. Then give it the test that the protocol section describes. The loop does not change, and neither does any other adapter.
Working rule: An adapter keeps the raw text and the counts, reads the tool calls in one place, and returns a Reply. It never hands the loop an SDK object. Give each adapter a test that calls reply() with the loop's arguments, and treat a changed prompt or a changed request as a reason to record again.
This chapter, in this edition
Edition 2026.11.2Examples passed Nov 20, 20264 of 4 examples in this chapter pass
This book is open to contributions, so anyone can check it or correct it. Found something wrong? Report it with the section's ID, the last part of the link beside each heading, or fix it yourself with a pull request.