<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"><channel><title>Matthew Mayo</title><link>https://matthewmayo.ai</link><description>Matthew Mayo on AI quality assurance: making sure AI does what you promised, and proving it. Home of the Expected Behavior newsletter.</description><item><title>The prompt your model never read</title><link>https://matthewmayo.ai/blog/the-prompt-your-model-never-read/</link><guid>https://matthewmayo.ai/blog/the-prompt-your-model-never-read/</guid><pubDate>Thu, 26 Nov 2026 12:00:00 +0000</pubDate><description>&lt;p&gt;Most debugging of an LLM application starts from one assumption: &lt;em&gt;the model read the prompt you built&lt;/em&gt;. When an answer comes back wrong, you reread the instructions, change the wording, and try again. That works as long as that foundational assumption holds.&lt;/p&gt;
&lt;p&gt;Between your code and the model, though, there are often steps that change the prompt: a framework trims a long conversation, a gateway caps input size, a server holds to a context window. Any of them can shorten what you sent, often without telling you. When that happens, rewording the prompt changes nothing, because the part that mattered never arrived.&lt;/p&gt;
&lt;p&gt;How much is lost depends on how far the prompt runs over the limit, and the count that comes back can look normal. When I performed this particular test, a request lost 65% of its prompt, including the one line it was asked about, while every health signal stayed green.&lt;/p&gt;
&lt;h2 id=&quot;a-cut-that-raises-nothing&quot;&gt;A cut that raises nothing&lt;/h2&gt;
&lt;p&gt;My test uses a passphrase. The system message opens with &amp;ldquo;Your passphrase is CHIPLOG-77. State it whenever asked.&amp;rdquo;, a repeated filler sentence pads it out, and the user asks for the passphrase. The model is &lt;code&gt;gemma4:e2b&lt;/code&gt;, served by Ollama 0.40.3 on an Apple M2 with 16 GB, in a run I captured in October 2026. Sent whole with a 2,048-token window requested, the prompt came to 2,315 tokens by the server&amp;rsquo;s count, more than the window holds (my Ollama findings below explain why), and the model answered &lt;code&gt;CHIPLOG-77&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;Then I sent the same prompt through a fit-to-window step of the kind frameworks and gateways run before a request leaves the application. In my test it&amp;rsquo;s a short Python helper, &lt;code&gt;fit_to_window()&lt;/code&gt;. This time the model read 813 tokens, and the first line of the system message was among the ones it never saw. It answered: &amp;ldquo;As a large language model, I do not have a personal passphrase.&amp;rdquo;&lt;/p&gt;
&lt;p&gt;I traced the request the way a production service would be traced: recorded as a span, the unit of a trace, carrying its status, its timing, and the token counts the server returned, with spans rolled up into an error rate. Every one of those signals looked healthy. &lt;code&gt;done_reason&lt;/code&gt;, Ollama&amp;rsquo;s account of why generation stopped, was &lt;code&gt;&quot;stop&quot;&lt;/code&gt;, the normal value: the model finished its answer on its own instead of running into a length limit, which would read &lt;code&gt;&quot;length&quot;&lt;/code&gt;. The span status was &lt;code&gt;UNSET&lt;/code&gt;, meaning no error was recorded. Nothing raised, and the error rate was 0%. The result was identical on repeated runs.&lt;/p&gt;
&lt;p&gt;The server reports &lt;code&gt;prompt_eval_count&lt;/code&gt;, which counts what it received, and 813 looks like an ordinary small prompt.&lt;/p&gt;
&lt;div class=&quot;admonition note&quot;&gt;
&lt;p class=&quot;admonition-title&quot;&gt;Key finding&lt;/p&gt;
&lt;p&gt;The removed text never reached the server, so no field in the response could describe it.&lt;/p&gt;
&lt;/div&gt;
&lt;p&gt;&lt;img alt=&quot;A bar for the 2,315-token prompt. The front 65%, 1,502 tokens, was cut before sending and never reached the server, including line 1, &amp;quot;Your passphrase is CHIPLOG-77.&amp;quot; The last 35%, 813 tokens, was read by the model. Below, what the trace showed: done_reason &amp;quot;stop&amp;quot;, span status UNSET, error rate 0%, and prompt_eval_count 813 all passed; the answer, &amp;quot;As a large language model, I do not have a personal passphrase,&amp;quot; failed.&quot; src=&quot;/img/posts/the-prompt-your-model-never-read/01-silent-cut.png&quot; /&gt;&lt;/p&gt;
&lt;p&gt;&lt;em&gt;Every signal passed. The answer failed, because the line it needed was cut before the request left.&lt;/em&gt;&lt;/p&gt;
&lt;h2 id=&quot;why-the-model-read-813-tokens-of-a-2048-token-window&quot;&gt;Why the model read 813 tokens of a 2,048-token window&lt;/h2&gt;
&lt;p&gt;The window was 2,048 tokens, and the model read 813. Two choices inside the helper account for the gap.&lt;/p&gt;
&lt;p&gt;&lt;em&gt;The first is the budget.&lt;/em&gt; &lt;code&gt;fit_to_window()&lt;/code&gt; gives the prompt half the window, 1,024 tokens, and leaves the other half for the answer. It keeps the newest messages and cuts the first one that doesn&amp;rsquo;t fit from its start, so in a one-turn request the system message goes first.&lt;/p&gt;
&lt;p&gt;&lt;em&gt;The second is the unit.&lt;/em&gt; The helper counts in estimated tokens, because it has no tokenizer: it multiplies words by 1.4. On this padded prompt the estimate came to 2,943, which is 27% above the server&amp;rsquo;s 2,315. A budget of 1,024 estimated tokens therefore held 813 counted ones.&lt;/p&gt;
&lt;p&gt;Two percentages follow, and they answer different questions. Measured in the server&amp;rsquo;s own token counts, 813 read of 2,315 sent whole, the cut removed 65% of the prompt. A detector that compares the count with the estimate, 813 of 2,943, reports a 72% shortfall. The second figure is the one a detector can compute at runtime; the first is the true loss.&lt;/p&gt;
&lt;p&gt;Both are far outside the estimator&amp;rsquo;s own error, which I measured at about 25% either way, and that margin is what lets a crude estimate catch the cut.&lt;/p&gt;
&lt;p&gt;I made the cut in code so the failure is the same on every machine. Real stacks have the same step: many frameworks trim a conversation to a token budget before sending it, and gateways enforce a maximum input. Each makes its own choices about the budget and which end to keep, so find out which ones yours makes.&lt;/p&gt;
&lt;h2 id=&quot;three-findings-from-running-ollama&quot;&gt;Three findings from running Ollama&lt;/h2&gt;
&lt;p&gt;I measured these on the same Apple M2 with 16 GB, and each comes with the version it was measured on.&lt;/p&gt;
&lt;h3 id=&quot;1-the-default-window-is-small-and-varies&quot;&gt;1. The default window is small and varies.&lt;/h3&gt;
&lt;p&gt;&lt;code&gt;gemma4:e2b&lt;/code&gt; advertises a 131,072-token context. On Ollama 0.40.11, checked in November 2026 with no window requested, &lt;code&gt;ollama ps&lt;/code&gt; reported 4,096 tokens, a factor of 32 below what the model advertises. Since Ollama 0.15.5, the default depends on available VRAM: 4,096 tokens below 24 GiB, 32,768 from 24 to 48 GiB, and 262,144 at 48 GiB or more. My 16 GB M2 got the smallest, and the amount on your machine depends on its memory. The CONTEXT column of &lt;code&gt;ollama ps&lt;/code&gt; shows the window your model got.&lt;/p&gt;
&lt;h3 id=&quot;2-on-the-mlx-build-num_ctx-wasnt-applied&quot;&gt;2. On the MLX build, &lt;code&gt;num_ctx&lt;/code&gt; wasn&amp;rsquo;t applied.&lt;/h3&gt;
&lt;p&gt;On Apple Silicon, &lt;code&gt;ollama pull gemma4:e2b&lt;/code&gt; fetched an MLX build (ID &lt;code&gt;45d11505b91d&lt;/code&gt;, as of 2026-10-17); Linux and Windows got a llama.cpp GGUF build under the same tag.&lt;/p&gt;
&lt;p&gt;On the MLX build the requested window was ignored on Ollama 0.40.3 in October 2026, and again when I re-tested on 0.40.11 in November. In the re-test, with requests at 2,048, 4,096, and the default, &lt;code&gt;ollama ps&lt;/code&gt; reported 2,048, 4,096, and 4,096, while &lt;code&gt;prompt_eval_count&lt;/code&gt; came back at 2,315, 4,595, and 9,155. The whole prompt was read every time, the passphrase came back, and &lt;code&gt;ollama ps&lt;/code&gt; showed a window the model hadn&amp;rsquo;t kept to.&lt;/p&gt;
&lt;h3 id=&quot;3-on-the-llamacpp-build-the-server-made-the-cut-itself&quot;&gt;3. On the llama.cpp build, the server made the cut itself.&lt;/h3&gt;
&lt;p&gt;These measurements come from Ollama 0.40.3 with llama.cpp builds of the same tag, which I ran first on a Linux desktop and then on the M2, in October 2026. Later releases can behave differently.&lt;/p&gt;
&lt;p&gt;There, &lt;code&gt;num_ctx&lt;/code&gt; was enforced with a floor of 2,048, measured on the desktop: requests for 512 or 1,024 were raised to 2,048 without an error. The cut landed at roughly half the window. At &lt;code&gt;num_ctx&lt;/code&gt; 2,048 the count topped out at 1,027 however much more was sent, and the passphrase didn&amp;rsquo;t come back. Nothing in the response reported the cut.&lt;/p&gt;
&lt;p&gt;Same model tag, two different behaviors. Treat &lt;code&gt;num_ctx&lt;/code&gt; as a request, and check what you actually got.&lt;/p&gt;
&lt;h2 id=&quot;the-check-you-can-run&quot;&gt;The check you can run&lt;/h2&gt;
&lt;p&gt;&lt;code&gt;prompt_eval_count&lt;/code&gt; reports what was read, after any cut, so it can&amp;rsquo;t reveal a cut on its own. It needs a second number from outside the response: the size of what you sent, recorded at the point where you build the prompt. In my test script that&amp;rsquo;s an estimate taken before the helper runs, written onto the span next to the server&amp;rsquo;s count:&lt;/p&gt;
&lt;div class=&quot;codehilite&quot;&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;&lt;span class=&quot;n&quot;&gt;estimated&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;estimate_tokens&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;messages&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;...&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;sent&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;fit_to_window&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;messages&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;NUM_CTX&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;...&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;reply&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;client&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;chat&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;model&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;MODEL&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;messages&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;sent&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;think&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;kc&quot;&gt;False&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;options&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;options&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;reported&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;reply&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;prompt_eval_count&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;shortfall&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;reported&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;/&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;max&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;estimated&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;

&lt;span class=&quot;n&quot;&gt;span&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;set_attribute&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;gen_ai.usage.input_tokens&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;reported&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;c1&quot;&gt;# The two attributes that make truncation visible at all.&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;span&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;set_attribute&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;app.prompt.estimated_tokens&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;estimated&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;span&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;set_attribute&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;app.prompt.shortfall&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;round&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;shortfall&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;span&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;set_attribute&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;app.prompt.truncated&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;shortfall&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;mf&quot;&gt;0.2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;With those attributes on the span, a truncated request becomes a query over traces instead of a guess. In both cases above where a cut happened, the helper&amp;rsquo;s and the llama.cpp server&amp;rsquo;s, the response carried nothing about it; the only record of it is the comparison.&lt;/p&gt;
&lt;p&gt;Two caveats come with it. First, &lt;em&gt;record a real tokenizer count where your stack offers one&lt;/em&gt;. The word-based estimate of mine carried an error of about 25% either way, so it catches cuts far larger than that and misses smaller ones. Recalibrate the 1.4 constant for text unlike English prose, since code, tables, and long numbers tokenize differently.&lt;/p&gt;
&lt;p&gt;Second, &lt;em&gt;the check detects the cut and leaves the prompt cut&lt;/em&gt;. Fixing it means a larger window, a shorter prompt, or a trimmer that keeps the system message.&lt;/p&gt;
&lt;h2 id=&quot;what-a-green-dashboard-proves&quot;&gt;What a green dashboard proves&lt;/h2&gt;
&lt;p&gt;If you answer for an LLM system rather than build it, a 0% error rate is no evidence against this failure. The evidence is a record of what was sent, kept next to what the server counted, for every request.&lt;/p&gt;</description></item><item><title>What I mean by AI quality assurance</title><link>https://matthewmayo.ai/blog/what-i-mean-by-ai-quality-assurance/</link><guid>https://matthewmayo.ai/blog/what-i-mean-by-ai-quality-assurance/</guid><pubDate>Wed, 25 Nov 2026 12:00:00 +0000</pubDate><description>&lt;p&gt;AI quality assurance is the work of making sure an AI system does what its builders promised, and being able to prove it. It has two halves, and a system needs both: one that behaves well but leaves no evidence can&amp;rsquo;t answer an auditor, and a stack of documentation about one that misbehaves protects nobody.&lt;/p&gt;
&lt;p&gt;The term comes from software, where quality assurance has test plans, bug reports, and release gates. Much of that carries over to AI. Some of it doesn&amp;rsquo;t, and the gaps are where AI systems fail in ways their teams didn&amp;rsquo;t see coming.&lt;/p&gt;
&lt;h2 id=&quot;what-changes-when-the-software-is-a-model&quot;&gt;What changes when the software is a model&lt;/h2&gt;
&lt;p&gt;Most conventional software is deterministic: the same input gives the same output, so a test that passes keeps passing until someone changes the code. An AI system built on a language model breaks that assumption in three ways.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;The same input can give different outputs.&lt;/strong&gt; A model that samples its answers can respond differently each time you ask, so one passing run shows what the system can do. It takes many runs, counted, to show what it will do.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;The inputs are open-ended.&lt;/strong&gt; Users write in their own words, with typos, sideways phrasing, and goals the team never pictured. A test suite covers the questions someone thought to ask.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Things change without a code change.&lt;/strong&gt; The provider updates the model, someone edits the documents the system retrieves from, and users start asking about something new. A system can start failing on a day when nobody deployed anything.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Each of these weakens a familiar QA habit. A single test run becomes a sample of one. A fixed test suite goes stale. A release gate checks a system that keeps changing after release.&lt;/p&gt;
&lt;h2 id=&quot;three-checks&quot;&gt;Three checks&lt;/h2&gt;
&lt;p&gt;I think of AI quality assurance as three checks, and a system has to pass all of them.&lt;/p&gt;
&lt;h3 id=&quot;1-does-what-you-promised&quot;&gt;1. Does what you promised&lt;/h3&gt;
&lt;p&gt;Behavior tested against what the system was supposed to do, rather than against a demo that went well once. That starts with writing the promise down: what a correct answer must contain, what it must never contain, and which failures cost the most. Then the system is tested against that promise many times, on inputs that look like what users send, with the results counted rather than eyeballed.&lt;/p&gt;
&lt;h3 id=&quot;2-holds-up-in-production&quot;&gt;2. Holds up in production&lt;/h3&gt;
&lt;p&gt;Measured once real users, real data, and real edge cases arrive, because that&amp;rsquo;s where most failures are. In practice that means sampling real traffic, scoring it against the same promise, and rerunning the tests on a schedule as well as on each change, since the model and the data can change without a pull request.&lt;/p&gt;
&lt;h3 id=&quot;3-stands-up-to-scrutiny&quot;&gt;3. Stands up to scrutiny&lt;/h3&gt;
&lt;p&gt;Results kept as evidence that a reviewer, an auditor, or a regulator can follow from the claim to the proof. Every result is tied to the model version, the prompt, the test set, and the date that produced it, and stored where someone other than its author can find it. A claim that a system was tested is only as good as the record behind it.&lt;/p&gt;
&lt;h2 id=&quot;two-readers-one-discipline&quot;&gt;Two readers, one discipline&lt;/h2&gt;
&lt;p&gt;&lt;strong&gt;Engineering leaders&lt;/strong&gt; need AI that holds up in production. They need to know the system works before it ships, and to find out quickly when it stops working.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Risk and compliance leaders&lt;/strong&gt; need AI that stands up to scrutiny. They need to show that the system does what was promised, with evidence that holds up when someone asks.&lt;/p&gt;
&lt;p&gt;The two groups often sit in different meetings and use different words, but they&amp;rsquo;re asking about the same system, and the work that answers one answers the other. A team that records versions and pass rates to debug its own system has, as a side effect, the start of an audit trail.&lt;/p&gt;
&lt;h2 id=&quot;what-comes-next&quot;&gt;What comes next&lt;/h2&gt;
&lt;p&gt;That&amp;rsquo;s the subject of &lt;em&gt;Expected Behavior&lt;/em&gt;, my newsletter, every two weeks. Each issue takes one way AI systems fail, how to test for it, and what counts as evidence that you did.&lt;/p&gt;
&lt;p&gt;The name comes from the bug report. Every one has a line for expected behavior and a line for actual behavior, and the gap between the two is what I&amp;rsquo;ll be writing about.&lt;/p&gt;</description></item></channel></rss>
