GOAT EngineerPreparing your learning space…

AI Engineering · The Wrenlet Saga · Free article

Ship an AI Reply-Drafter This Sprint

Your first task at Wrenlet: an AI that drafts replies to support tickets, by Friday. It works on the demo and lies to a customer by Monday. To trust it, you first have to understand the one thing it actually does, and why that one thing makes it fast, cheap in some places and shockingly expensive in others, and confidently wrong.

This is where the arc starts: a single prompt, a hard deadline, and a model you don't yet understand. You'll ship a working reply-drafter, watch it fail in the exact way models fail, and come away with the three mental models the rest of Wrenlet is built on: what the model actually does, what a token is, and why it states false things with total confidence. Each one opens into a full page you can go as deep as you like on; this chapter is the story that makes you want to.

It's your first week at Wrenlet. There is no product yet, just a landing page, an API key, and a bet that AI can handle customer support better than a wall of canned macros. On Tuesday your co-founder Priya drops a ticket in your lap: “Support is drowning. Can you get us an AI that drafts the reply for an agent to approve? Nothing fancy. By Friday.”

You wire it up in an afternoon. Take the customer's message, paste it after a one-line instruction (“You are a friendly Wrenlet support agent. Draft a reply to this ticket.”), send it to the model, show the draft in the agent console. On the demo it is genuinely good: warm, on-point, faster than anyone typing by hand. Priya ships it Friday. You feel great.

You cannot fix this with a try/catch. There was no exception: the model did exactly what it was built to do, and what it was built to do is not what you assumed. Before you can make this thing trustworthy, you have to understand it. Not the training math. Just three things: what the machine actually does, what it charges you for, and why it lies without knowing it's lying. The rest of Wrenlet, every chapter after this one, is a response to those three facts.

What you actually built

You did not build a program that knows about refunds and decides what to say. You built a wrapper around a machine that does exactly one thing: read a sequence of tokens and guess the next one. It computes a probability for every possible next token (“refunded” at 34%, “escalated” at 16%, and a long tail below), then a sampler picks one, sticks it on the end, and the whole thing runs again on the now-longer text. Word by word, that loop is your entire reply.

That single fact explains almost everything you'll see. It's why the same ticket can produce two different drafts: you're drawing from a distribution, not reading a fixed answer. It's why the reply streams in word by word instead of appearing at once. And it's why a confident opening line drags the rest of the reply along with it, true or not. There's a knob called temperature that controls how much of that tail the sampler is allowed to reach for. Drag it and watch both the odds and the draw change:

The interactive version of this example is available when JavaScript loads.

Low temperature makes the model predictable and a little boring, which is the right setting when you want it to pull one field out of a ticket or pick which macro to send. High temperature buys variety and surprise, which is fun for brainstorming and dangerous for a support reply. “More creative” and “less reliable” are the same dial turned the same way. This is the surface of it; the full mechanism (attention, training, why “bigger” isn't always better) is the How LLMs Actually Work page, and it's the one to read first.

What it charges you for, and why your bill will surprise you

The model never sees your words. Before anything happens, your prompt is chopped into tokens: chunks that are often a whole common word, sometimes a fragment, sometimes a single character. You are billed per token, in and out; latency is paid per token; the context window is measured in tokens. So a token is not a trivia detail. It's the unit your invoice, your speed, and your limits are all denominated in. Type into Wrenlet's drafter below and watch your text break into the pieces the model actually charges for:

The interactive version of this example is available when JavaScript loads.

A few things fall out immediately. English prose is efficient, roughly a token per short word. But a customer's order ID like WRN-8842-XZ, a snippet of JSON, an emoji, or a message in Turkish or Japanese can cost several tokens per piece, because the model's vocabulary was mostly learned on common English. That's why pasting a raw log or a big JSON blob into the prompt “to give it context” can quietly triple the cost of a call. And it's why a bloated system prompt is a tax you pay on every single request, forever. Deciding what earns its place in that prompt is a discipline of its own: context engineering does the arithmetic on it, and Chapter 3 is where Wrenlet is forced to.

Why it lied, and why you can't patch it out

Back to Monday. The model invented “section 7.4” because inventing it was the most plausible continuation of the text “…as described in our refund policy, ”. Plausibility is the only thing the machine optimizes. It has no refund policy to look at, no sense of not knowing, and a strong learned habit of sounding confident and helpful. Asked a question it has no basis for, its default is not “I don't know.” Its default is to produce a fluent, confident, wrong answer, because that's what the text around it makes likely.

Watch it happen on purpose. Ask Wrenlet's drafter about a policy that doesn't exist. With the “may abstain” instruction off, it fabricates, and it does it smoothly. Turn abstention on and give it an honest exit, and it takes it:

The interactive version of this example is available when JavaScript loads.

This is the single most important thing to internalize in your first week: the confident tone carries no information about whether the fact is true. The invented answer and the correct answer look, sound, and score identically to your code. You can reduce hallucination. You cannot patch it to zero, because it's not a bug in a line you can find; it's a property of a machine that completes plausible text. What you can do is engineer around it, and that's the whole job.

What you ship instead

You don't rip the drafter out. It was genuinely useful. You make it honest. None of this requires anything you haven't met in this chapter; it's the same model, wired with respect for what it is. Monday's reply is still sitting in the queue, so make the calls yourself before you read what they're called:

The interactive version of this example is available when JavaScript loads.

Two of those switches decide what the same reply costs you and whether it reads the same way tomorrow. The rest decide whether a customer is told something false, which is why the draft stays marked until all of them are on. Written down, the five calls and the fact each one respects:

Turning the Friday hack into something you'd trust on Monday
What went wrongThe changeWhich fact it respects
It invented a policy sectionTell it explicitly it may say “I don’t know,” and to never cite a policy or number it wasn’t given.It completes plausible text, not true text, so remove the incentive to bluff.
An agent sent it verbatimKeep a human in the loop: it drafts, a person approves. Ship autonomy later, once you can measure quality.Confidence ≠ correctness; a fluent draft is not a checked one.
A pasted log tripled the costTrim the prompt to what the reply needs; stop stuffing raw blobs “for context.”You pay per token, in and out, on every call.
Refund amounts came out wrongNever let the model copy digits or do the math; pull those from your own systems.It sees tokens, not characters, so letters and digits are a blind spot.
Two drafts, two different answersLower the temperature for anything factual; save the warmth for phrasing.Output is sampled from a distribution, not looked up.

Notice what just happened: you didn't learn five tricks. You learned three facts about the machine: it predicts plausible tokens, it's billed and bounded in tokens, and it states falsehoods with confidence. Every fix is just one of those facts taken seriously. That's the pattern for the whole arc. Understand the constraint, and the “fix” is obvious.

Go deep on the three that matter

This chapter is the tour. Each stop opens into a full, hands-on page. Read them in this order and the rest of Wrenlet will feel like common sense:

The Chapter 1 reads

  1. How LLMs Actually Work. The next-token loop in full: attention without the math, what training bakes in, sampling knobs, and how to predict a model's behavior before it surprises you. Read this one first.
  2. LLM Tokenization. What a token really is, why code and other languages cost more, the letter-and-digit blind spot, and the token math you'll use to size prompts and forecast a bill.
  3. LLM Hallucination. Why confident wrong answers are structural, how to tell factuality from faithfulness, and the ladder of defenses that actually reduces, detects, and bounds it.

Where the story goes next

Wrenlet's drafter is honest now, and agents are approving its drafts. Then the complaints change: it's slow, eight seconds of nothing before a reply appears, and every so often it returns a draft your console can't even display, because you asked for structured fields and got back not-quite-JSON. The model is fine. The plumbing around it isn't. That's the next crisis: streaming, structured outputs, retries, and the first honest look at what each reply costs. That is Chapter 2: Make It Fast, and Stop It Falling Over.

By GOAT Engineer. Back to The Wrenlet Saga. Privacy Policy · Contact.