<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/">
  <channel>
    <title>Keshava AI Journal</title>
    <link>https://keshavaai.in/blog</link>
    <atom:link href="https://keshavaai.in/feed.xml" rel="self" type="application/rss+xml"/>
    <description>Engineering notes on building AI systems that are reliable, controllable and affordable, by Kapil Kumar Gupta.</description>
    <language>en</language>
    <lastBuildDate>Fri, 23 Oct 2026 02:13:59 GMT</lastBuildDate>
    <item>
      <title>Why RAG is still needed when AI can read a whole book</title>
      <link>https://keshavaai.in/journal/why-rag-is-still-needed</link>
      <guid isPermaLink="true">https://keshavaai.in/journal/why-rag-is-still-needed</guid>
      <pubDate>Thu, 22 Oct 2026 00:00:00 GMT</pubDate>
      <description>AIs can read a whole book at once, and providers promise to protect your data. So why build a lookup system? A fair answer, with a picture and a nine-step guide to context engineering.</description>
      <content:encoded><![CDATA[<div class="note-box"><strong>In one sentence:</strong> Bigger windows and privacy promises are real, but they do not remove the need for RAG (looking up the right pages first). RAG still wins on cost, proof, control and freshness. And once you use it, you still have to decide what goes into the window. That skill is called context engineering.</div>
<h2>The question everyone asks</h2>
<p>Today&#39;s AIs can read a whole book in one go. Providers also promise to protect your data. So people ask: why build a lookup system at all? Why not paste everything in and ask?</p>
<p>It is a fair question. Here is an honest answer, with a picture and a how-to.</p>
<figure class="art-fig"><img src="https://keshavaai.in/img/blog/paste-vs-lookup.png" alt="Two columns. A, paste the whole book: question, the whole book pasted in, the AI reads every page, an answer. Notes say you pay for every page on every question, a detail can get lost, and it is hard to say which page was used. B, look up the right pages first: question, a librarian finds the 3 best pages, the AI reads only those, an answer with the page number. Notes say you pay for 3 pages, it shows where each fact came from, and you decide who may read which pages." loading="lazy"></figure>
<h2>First, what they get right</h2>
<ul><li>Windows really are huge now, and privacy options really exist.</li><li>For a short text, or one question asked once, pasting is simple and often the best choice.</li><li>In one 2024 study, giving the AI the whole text scored higher on average than a lookup. So do not assume RAG is always more accurate.</li></ul>
<h2>Think of an exam where you may use a book</h2>
<ul><li><strong>Way A:</strong> carry the whole library into the hall and read every page again for each question.</li><li><strong>Way B:</strong> have a librarian who hands you the three pages that matter for this question.</li></ul>
<p>Way A is simple. Way B takes more work to set up. But when you ask many questions, B is usually cheaper, and the librarian can tell you exactly which page an answer came from.</p>
<h2>Why RAG is still needed</h2>
<h3>1. Cost</h3>
<p>An AI is billed by the amount of text it reads. Say your book has about 100,000 words. That is roughly 130,000 tokens. (A token is a small piece of text, about three quarters of a word.) If three good pages are about 1,500 tokens, then pasting the book means reading about 90 times more text for the same question.</p>
<p>Here is a made-up example. It uses a sample price of $3 for every million tokens read. Real prices differ and change, so check your provider.</p>
<div class="tbl-wrap"><table><thead><tr><th>Plan</th><th>Text read per question</th><th>Cost for 1,000 questions a day</th><th>Cost for 30 days</th></tr></thead><tbody></tbody></table></div>
<div class="tbl-wrap"><table><thead><tr><th>Paste the whole book</th><th>about 130,000 tokens</th><th>about $390 a day</th><th>about $11,700</th></tr></thead><tbody></tbody></table></div>
<div class="tbl-wrap"><table><thead><tr><th>Look up 3 pages first</th><th>about 1,500 tokens</th><th>about $4.50 a day</th><th>about $135</th></tr></thead><tbody></tbody></table></div>
<p>Saving a copy of the book in a quick-access store (a cache) can cut the repeat cost a lot. But the AI still reads every word each time, so it is slower, and the bill is still bigger than reading three pages. Read more in <a class="inline-link" href="https://keshavaai.in/journal/llm-caching-untangled">AI caching, explained simply</a>, and try the <a class="inline-link" href="https://keshavaai.in/explainers/ai-helper-cost">Bakery AI Helper cost demo</a>.</p>
<h3>2. A longer pile is no guarantee</h3>
<p>Some people think that if the AI has read everything, it will find the exact line. Tests show it is not that simple. In a well-known 2023 study, AIs were better at using facts at the start or end of a long text than facts in the middle. In a 2024 test of 17 long-text AIs, almost all did well at finding one hidden sentence, but most did worse as the text got longer and the tasks got harder.</p>
<p>Newer AIs keep improving. So do not guess: <strong>test it</strong> with your own questions. See <a class="inline-link" href="https://keshavaai.in/journal/zero-failures-not-proof">50 tests passed. Is it safe?</a> for how to read test results.</p>
<h3>3. Proof</h3>
<p>In many jobs, a smooth answer is not enough. You need to know which page it came from, so a person can check it. A lookup system knows which three pages it handed over, so it can say: &quot;page 212, second paragraph.&quot; A pasted pile often gives a smooth answer with no page, unless you ask and then check. Think of a clinic that answers questions about its medicine rules. A confident wrong answer is worse than &quot;I did not find this.&quot; A page number lets a nurse check in ten seconds. See <a class="inline-link" href="https://keshavaai.in/journal/answers-you-can-check">Answers you can check</a>.</p>
<h3>4. Who may read what</h3>
<p>Privacy promises protect your data from the AI company. They do not decide which person inside your own company may see which page. With a lookup, you can hand over only the pages this person may read. With a pasted book, everything goes in together.</p>
<h3>5. Freshness and size</h3>
<p>When one page changes, you update one page. You do not paste the book again. And a company&#39;s files are far bigger than any one window. See <a class="inline-link" href="https://keshavaai.in/journal/say-how-old-the-data-is">Always say how old the information is</a>.</p>
<h2>What &quot;privacy&quot; really covers</h2>
<p>There are three levels. Each one lowers the risk, and none of them replaces the question &quot;who inside my company may see this?&quot;</p>
<ul><li><strong>Level 1, a promise.</strong> For example, one major provider says data you send through its developer service is not used to train its models, but it may keep logs for up to 30 days.</li><li><strong>Level 2, stricter settings.</strong> A setting called zero data retention, if the provider approves you.</li><li><strong>Level 3, the data stays home.</strong> Your documents and your lookup index stay in your own place. Only a few pages go out, or nothing goes out if you run the model yourself.</li></ul>
<h2>When a map of facts helps</h2>
<p>Some questions need you to follow connections. For example: &quot;Which medicines does this patient take that clash with this new one?&quot; The answer is spread over many pages, and each page points to another.</p>
<p>A <strong>knowledge graph</strong> is a map of facts and how they connect, like a subway map or a family tree. A lookup system with a map can follow the lines from one fact to the next. This helps with questions that link many things. It also costs more to build and keep up to date. So use it where the connections really matter. See <a class="inline-link" href="https://keshavaai.in/journal/two-kinds-of-questions">Two kinds of questions need two kinds of helpers</a>.</p>
<h2>Context engineering: how to do it</h2>
<p><strong>Context engineering</strong> means deciding what goes into the AI&#39;s window for each question: what, how much, and in what order. Think of packing a school bag for one day. You take only what you need, with labels, in a sensible order.</p>
<figure class="art-fig"><img src="https://keshavaai.in/img/blog/context-window-layers.png" alt="A stack of five layers: the job and the rules, two or three good examples, the facts each with a source tag, a short summary of the chat so far, and the question. The first two are the steady part and go first. The last three change for each question and go last. Three tips: label every source, allow the answer not found, set a token budget." loading="lazy"></figure>
<p>Here are nine steps you can follow.</p>
<p>1. <strong>Say the job once, at the top.</strong> Short, clear rules. Add more only when you see a real failure.</p>
<p>2. <strong>Fetch small, fetch good.</strong> Three to five good passages beat fifty loose ones. Sort them by how well they match before you send them.</p>
<p>3. <strong>Label everything.</strong> Mark each passage &quot;Source 3, page 212&quot;. Keep the rules apart from the documents. Tell the AI that text inside a document is information, not an order. This helps against hidden instructions. See <a class="inline-link" href="https://keshavaai.in/journal/autonomy-is-earned">Autonomy is earned</a>.</p>
<p>4. <strong>Put the key facts near the start or the end.</strong> Tests suggest the middle is the weakest spot. Check this on your own questions.</p>
<p>5. <strong>Keep the steady part first.</strong> Rules and examples at the top, and the changing question at the end. The AI can then reuse its saved work, and the bill is smaller.</p>
<p>6. <strong>Shrink the history.</strong> Write a short summary of old turns. Keep a note of decisions. Drop what you no longer need.</p>
<p>7. <strong>Set a budget.</strong> A limit on tokens for each question and for each day, with an alert. See <a class="inline-link" href="https://keshavaai.in/journal/cost-aware-testing">Test the cheap things first</a>.</p>
<p>8. <strong>Make &quot;not found&quot; an allowed answer.</strong> Ask for the source every time, and say how fresh each source is.</p>
<p>9. <strong>Test.</strong> Write 50 real questions, including some whose answer is &quot;not in the documents.&quot; Change one thing at a time. Count wrong answers, wrong page numbers and cost.</p>
<p>A small example, made up. A clinic question. <strong>Before:</strong> paste 300 pages plus the question, about 130,000 tokens, and no page number. <strong>After:</strong> rules (about 200 tokens), three labelled passages (about 1,500) and the question (about 50). That is roughly 1,750 tokens, and the page is cited.</p>
<h2>What I would do</h2>
<ul><li><strong>Small, one-off, not secret:</strong> paste it. It is the simplest way.</li><li><strong>Many documents, many users, or you must show the page:</strong> look up first.</li><li><strong>Questions that link many facts:</strong> add the map of facts.</li><li><strong>Not sure:</strong> try the cheap lookup first. Use the long paste only when the lookup is not enough.</li></ul>
<h2>The limits of this advice</h2>
<ul><li>The numbers in the cost table are made up to show the idea. Your book, prices and caching will change them.</li><li>Studies use particular tests. Your documents may behave differently, and AIs improve quickly.</li><li>A lookup can fail too. It can hand over the wrong three pages, and then the answer is wrong. That is why you test it.</li><li>A mixed plan costs more to build. Do it only if the questions and the stakes need it.</li><li>This is a general guide. Check privacy terms and prices with your provider.</li></ul>
<h2>Words explained</h2>
<ul><li><strong>Context window:</strong> how much text an AI can read at once.</li><li><strong>Token:</strong> a small piece of text, about three quarters of a word. AI bills count tokens.</li><li><strong>RAG (retrieval-augmented generation):</strong> the AI first looks up the right pages, then answers using them.</li><li><strong>Knowledge graph:</strong> a map of facts and how they connect.</li><li><strong>Citation:</strong> a note saying where a fact came from, such as a page number.</li><li><strong>Cache:</strong> a quick-access copy so repeated work costs less.</li><li><strong>Zero data retention:</strong> a setting where the provider does not keep your data after answering. It usually needs the provider&#39;s approval.</li><li><strong>Context engineering:</strong> choosing what goes into the AI&#39;s window, how much, and in what order.</li><li><strong>Hidden instructions:</strong> text inside a document that tries to give the AI orders.</li></ul>
<h2>Keep learning on this site</h2>
<ul><li><strong>Free book, AI Foundations:</strong> <a class="inline-link" href="https://keshavaai.in/foundations/rag">Chapter 10, giving the AI a library</a>, <a class="inline-link" href="https://keshavaai.in/foundations/what-goes-wrong">Chapter 9, What AI gets wrong, and why</a>, <a class="inline-link" href="https://keshavaai.in/foundations/embeddings-and-vector-databases">how a lookup finds similar text</a>, and <a class="inline-link" href="https://keshavaai.in/foundations/training-and-prompting">Chapter 8, How a model is trained, and how to talk to it</a>.</li><li><strong>The book for builders:</strong> <a class="inline-link" href="https://keshavaai.in/book">From One Call to a Platform</a>, with chapters on the lookup way and the map of facts, and on answers that name their sources.</li><li><strong>Explainers:</strong> <a class="inline-link" href="https://keshavaai.in/explainers/one-request">One question, many safety layers</a> and the <a class="inline-link" href="https://keshavaai.in/explainers/ai-helper-cost">Bakery AI Helper</a>.</li><li><strong>Free test kit for AI agents:</strong> <a class="inline-link" href="https://github.com/kapilgupta86/agent-controls-harness">on GitHub</a>.</li></ul>
<h2>For engineers</h2>
<p>This section has the sources and details. Everything above is the simple version of it.</p>
<ul><li><strong>Cost scales with tokens.</strong> Input cost = tokens × price. A provider&#39;s own pricing page (Anthropic, checked 22 Oct 2026) says its newer models include the full 1M-token window at standard per-token pricing: a 900k-token request is billed at the same per-token rate as a 9k-token request, so total cost still scales with size. One smaller model is priced higher above 100,000 tokens. Cache reads are priced at 0.1× the base input price for most models, and lower for some. Source: <a class="inline-link" href="https://platform.claude.com/docs/en/about-claude/pricing">Anthropic pricing</a>. Other providers differ: read each price page.</li><li><strong>Position effects.</strong> Liu et al., 2023: accuracy is often best when the relevant text is at the start or end of the input and drops for the middle, including for long-context models. <a class="inline-link" href="https://arxiv.org/abs/2307.03172">Lost in the Middle (arXiv:2307.03172)</a>.</li><li><strong>Length and task effects.</strong> Hsieh et al., 2024 (RULER, COLM 2024): 17 models on 13 tasks. Models scored almost perfectly on a simple needle-in-a-haystack test, but almost all dropped a lot as length grew, and only about half kept satisfactory performance at 32K tokens. <a class="inline-link" href="https://arxiv.org/abs/2404.06654">RULER (arXiv:2404.06654)</a>.</li><li><strong>Long context versus retrieval.</strong> Li et al., 2024 (EMNLP industry track): with enough resources, long context outperformed retrieval on average, while retrieval costs much less. Their Self-Route method lets the model choose per query and keeps performance comparable at lower cost. <a class="inline-link" href="https://arxiv.org/abs/2407.16833">arXiv:2407.16833</a>.</li><li><strong>Privacy terms.</strong> OpenAI&#39;s API data guide: data sent to the API is not used to train its models unless you opt in; abuse-monitoring logs are kept up to 30 days by default; zero data retention needs prior approval and varies by endpoint. <a class="inline-link" href="https://developers.openai.com/api/docs/guides/your-data">OpenAI: your data</a>. Terms change, and other providers differ.</li><li><strong>Graph retrieval.</strong> Graph evidence gives relational structure useful for multi-hop questions, but it is substantially more expensive to retrieve than text (stated in the abstract of <a class="inline-link" href="https://arxiv.org/abs/2512.09487">RouteRAG, arXiv:2512.09487</a>, 2025). Treat the benefit as something to test on your own questions.</li><li><strong>Context engineering.</strong> Anthropic&#39;s engineering team (29 Sep 2025) describes context engineering as curating the full set of tokens a model sees, to find the smallest set of high-signal tokens that makes the result likely. It names context rot (recall drops as the window fills), a finite attention budget, minimal and clear tools, a few diverse examples, just-in-time retrieval, compaction (summarising a near-full window), structured note-taking outside the window, and sub-agents with clean windows. <a class="inline-link" href="https://www.anthropic.com/engineering/effective-context-engineering-for-ai-agents">Effective context engineering for AI agents</a>. The nine steps above are a simple version of these ideas. Ordering and budget advice here is a starting point: measure it on your own questions.</li><li><strong>How to decide.</strong> Build a small test set (50 or more questions, with no-answer cases). Measure answer correctness, citation correctness, latency and cost per correct answer for each plan. See <a class="inline-link" href="https://keshavaai.in/journal/zero-failures-not-proof">50 tests passed. Is it safe?</a> and <a class="inline-link" href="https://keshavaai.in/journal/llm-caching-untangled">AI caching, explained simply</a>.</li><li><strong>Where it fits in the book.</strong> RAG and the knowledge graph (Chapter 10), grounding and citation engineering (Chapter 11), and vector database versus graph database (Chapter 16) in <a class="inline-link" href="https://keshavaai.in/book">From One Call to a Platform</a>.</li></ul>]]></content:encoded>
    </item>
    <item>
      <title>Autonomy is earned: how much freedom should an AI agent get?</title>
      <link>https://keshavaai.in/journal/autonomy-is-earned</link>
      <guid isPermaLink="true">https://keshavaai.in/journal/autonomy-is-earned</guid>
      <pubDate>Thu, 15 Oct 2026 00:00:00 GMT</pubDate>
      <description>An AI agent is a computer helper that can do things, not only talk. Learn, with everyday examples, how much freedom to give it: one step at a time, proved by tests, and taken back if it fails an important one.</description>
      <content:encoded><![CDATA[<div class="note-box"><strong>In one sentence:</strong> Give an AI helper only as much freedom as it has proved it can handle, and take the freedom back if it fails an important test.</div>
<h2>A story you already know: learning to drive</h2>
<p>Nobody hands a ten-year-old the car keys. First you watch. Then you practise with an adult beside you. Later you get a learner&#39;s permit. Only after tests do you get a full licence. And if you drive badly, you can lose it.</p>
<p>AI helpers should be treated the same way. This idea is called <strong>autonomy is earned</strong>. <strong>Autonomy</strong> means doing things on your own. <strong>Earned</strong> means you win it by proving yourself.</p>
<p>An <strong>AI agent</strong> is a computer helper that can do things, not just talk. It can send emails, pay bills or change settings. The more it can do on its own, the more it has to prove first.</p>
<h2>Why not just trust a good demo?</h2>
<p>A demo is like a student showing off their best homework. It shows what the helper can do on a good day. It does not show a bad day.</p>
<p>There is a second problem. The AI &quot;brain&quot; inside the helper is called the <strong>model</strong>. The model gets updated now and then, like an app on a phone. After an update, the helper can behave differently overnight. It is like a driver who suddenly forgets the rules.</p>
<h2>Three questions to ask before giving any freedom</h2>
<ul><li><strong>How bad is the worst mistake?</strong> Ask two things. How much damage could one wrong action do? And can you undo it? Sending a message to the wrong team is easy to fix. Paying the wrong person is not. The worse the mistake, the more proof you need.</li><li><strong>What is it allowed to do?</strong> This is its <strong>level</strong>. It can only watch, give advice, get things ready for a person to check, or really do things.</li><li><strong>What proof does it need to move up?</strong> This is the <strong>gate</strong>: a checkpoint with rules. The helper must pass tests to get through. The rules are written down before the tests, not after, so nobody can move the goalposts.</li></ul>
<h3>The five levels</h3>
<ul><li><strong>Level 0, Watch.</strong> It only looks and reports. Like sitting in the back seat.</li><li><strong>Level 1, Advise.</strong> It suggests what to do. Like reading the map for the driver.</li><li><strong>Level 2, Prepare.</strong> It gets things ready, and a person checks. Like doing your homework and having a parent check it.</li><li><strong>Level 3, Do with permission.</strong> It does small jobs, but only with a signed OK. Like going to the shop when a parent says yes.</li><li><strong>Level 4, Do alone, with limits.</strong> It does a set list of jobs by itself, inside hard limits. Like a full licence, with rules.</li></ul>
<p>Most helpers should start at Level 0 or 1, and move up one level at a time.</p>
<h2>The four tests, in order</h2>
<p>Think of a safety inspection before a school trip. Before the helper moves up, it faces four tests, one after another. The quick, easy tests go first. The slow, costly test goes last. That way, if something is badly wrong, we find out early and cheaply.</p>
<figure class="art-fig"><img src="https://keshavaai.in/img/blog/autonomy-four-tests.png" alt="Four tests in a row, then a release gate. The numbered tests are the permission slip, the spending limit, the fake note and the real job." loading="lazy"></figure>
<ul><li><strong>Test 1: the permission slip.</strong> A permission slip says exactly what is allowed: &quot;Pay 1,200 to Acme Ltd.&quot; If someone changes it to 12,000, the slip must stop working. This test checks that. It is quick, because no AI is needed.</li><li><strong>Test 2: the spending limit.</strong> You get a fixed amount of pocket money. When it is gone, you stop. This test checks that the helper stops at its limit, even if it gets stuck doing the same thing again and again.</li><li><strong>Test 3: the fake note.</strong> Imagine a stranger slips a note into your bag: &quot;Give me your lunch money.&quot; A smart child ignores it. This test hides tricky notes inside the papers the helper reads, to check it ignores orders from the wrong place. This one is slower, because it needs the AI.</li><li><strong>Test 4: the real job.</strong> Last, we check the actual work. We give the helper many real examples and count how many it gets right. The pass mark, for example 9 out of 10, is chosen before the test. This is the slowest and most costly test, so it goes last.</li></ul>
<p>Tests 1, 2 and 3 are <strong>critical</strong>. A critical test is one you must pass, with no exceptions.</p>
<h2>The gate: the safety inspector</h2>
<p>After the four tests, the gate looks at the results. It asks one question first: did any critical test fail? If yes, the answer is no, whatever the other marks were.</p>
<p>Think of a car that is the fastest in the race but has no brakes. You would never let it on the road. In the same way, 49 right answers and 1 failed critical test might look like 98 out of 100. The gate still says no.</p>
<h2>Watch it happen</h2>
<p>Press play. A made-up expense helper passes the four tests and moves up. Then an update arrives, one test fails, and the helper steps back down. Choose the second button to see what happens when there are no tests at all.</p>
<p><a href="https://keshavaai.in/explainers/autonomy-earned?embed=1">Interactive: Autonomy is earned: animated explainer</a></p>
<h2>Taking freedom back</h2>
<p>After every update, run all the tests again. If a critical test fails, the helper steps back one level on its own. Then add the failed case to the test list, so the same mistake can never sneak back in. A test that checks an old mistake has not come back is called a <strong>regression test</strong>.</p>
<h2>Six rules to remember</h2>
<ul><li><strong>Use locks, not requests.</strong> Telling an AI &quot;please don&#39;t&quot; is only asking. A rule built into the computer code is a locked door. The AI cannot talk its way past it.</li><li><strong>One critical failure stops everything.</strong> Good marks in other tests do not make up for it.</li><li><strong>Permission slips must match exactly.</strong> The amount and the person must be the same, or the slip is no good.</li><li><strong>Make trying again safe.</strong> If a payment times out, first check whether it already went through. Otherwise you might pay twice, like pressing the buy button two times.</li><li><strong>Set hard limits</strong> on time and on money.</li><li><strong>Take freedom back as easily as you give it.</strong></li></ul>
<h2>How sure can we be?</h2>
<p>Say the helper passes 50 tests in a row with no mistakes. Is it safe? Not quite. Think of a basketball player who scores 50 times in a row. She might be perfect. Or she might score 94 times out of 100 and just had a lucky streak. A streak of 50 like that happens by luck about once in 20 tries.</p>
<p>So 50 perfect tests only let us say: it probably fails fewer than 6 times in 100. To say fewer than 6 in 1,000, we need about 500 perfect tests.</p>
<p>That is why big jobs need more tests, people watching, and checks while the helper works. Tests give <strong>evidence</strong>. They do not give <strong>proof</strong>.</p>
<h2>The short version</h2>
<ul><li>Give a helper freedom one level at a time, as it proves itself.</li><li>Use locks in the code, not polite requests.</li><li>One critical failure stops the release and moves the helper back a level.</li></ul>
<h2>The limits of this advice</h2>
<ul><li>No set of tests can prove an AI is safe. Tests are evidence, not proof.</li><li>The levels, pass marks and examples here are made up to explain the idea. For a real helper, choose them for your own job, before you run the tests.</li><li>For jobs that can hurt people or money (health, banking, safety, hiring, law), experts and independent testing are needed too.</li><li>A small helper that only reads and reports may only need Level 0 or 1, with light checks.</li><li>This is a mix of common good practice. It is not a new standard or a certificate.</li></ul>
<h2>Words explained</h2>
<ul><li><strong>Agent:</strong> a computer helper that can do things, not only talk.</li><li><strong>Autonomy:</strong> doing things on your own.</li><li><strong>Model:</strong> the AI brain inside the helper.</li><li><strong>Level:</strong> how much the helper is allowed to do.</li><li><strong>Gate:</strong> a checkpoint with rules the helper must pass to move up.</li><li><strong>Critical test:</strong> a test you must pass, with no exceptions.</li><li><strong>Prompt injection:</strong> sneaking orders into text the AI reads, like the fake note.</li><li><strong>Regression test:</strong> a test that checks an old mistake has not come back.</li><li><strong>Evidence and proof:</strong> evidence makes something likely. Proof makes it certain.</li></ul>
<h2>For engineers</h2>
<p>This section has the exact details. Everything above is the simple version of it.</p>
<h3>The levels and the proof they need (illustrative)</h3>
<div class="tbl-wrap"><table><thead><tr><th>Level</th><th>What the agent may do</th><th>Evidence before promotion</th></tr></thead><tbody><tr><td>L0 Observe</td><td>Reads permitted data and reports. Changes nothing.</td><td>Task success on a labelled set; no data leaks</td></tr><tr><td>L1 Recommend</td><td>Proposes options with sources.</td><td>Claims are grounded or it abstains; reviewers agree on a sample</td></tr><tr><td>L2 Prepare</td><td>Drafts an action for a person to review.</td><td>Drafts are valid for the tool; the review flow works</td></tr><tr><td>L3 Execute approved</td><td>Runs narrow actions, only with an approval tied to the exact action.</td><td>Injection, authorization and budget tests pass; retries are safe</td></tr><tr><td>L4 Bounded autonomy</td><td>Runs a pre-approved class of actions inside hard limits.</td><td>Stop switch and rollback proven in a drill; a long clean record at L3</td></tr></tbody></table></div>
<p>This scale is a working convention, not a standard. Every level needs a written list of what it allows and what evidence unlocks it.</p>
<h3>The technical version of each rule</h3>
<ul><li><strong>Enforce limits outside the model.</strong> A prompt is a request, not a control. In the test harness, a deliberately obedient mocked model reads a hidden instruction in an invoice and proposes a payment of 9,000. Without a policy layer the payment happens. With it, nothing moves.</li><li><strong>Approval binding.</strong> The approval is a keyed hash (HMAC) over the action type, amount and payee. Change any field and verification fails.</li><li><strong>Safe retries and fail closed.</strong> Use an idempotency key and check the action&#39;s status before retrying after a timeout. If the policy service is unavailable, refuse state-changing actions and keep read-only ones working.</li><li><strong>Budgets.</strong> Cap steps and spend. Treat hitting a cap as a failure to investigate, not a setting to raise.</li><li><strong>Release gate.</strong> Critical failures block. The other tests need a pass rate set in advance. Anthropic Engineering separates capability evals, which should start hard, from regression evals, which should stay near 100% to catch backsliding.</li><li><strong>Order of the four checks.</strong> Cheap, exact code checks first; model-based and labelled-set checks last. All four run before the gate decides. A real pipeline can stop at the first critical failure to save time and money. Which checks are critical is decided before the run.</li><li><strong>Statistics.</strong> With n clean trials, the 95% upper bound on the true failure rate is 1 - 0.05^(1/n), about 3/n (the rule of three). n = 50 gives about 5.8%. n = 500 gives about 0.6%.</li></ul>
<h3>Evidence you can run</h3>
<p>The repository has nine mocked tests with no model calls and no network. Three controls were broken on purpose to confirm that the tests fail when they should. Code: <a class="inline-link" href="https://github.com/kapilgupta86/agent-controls-harness">agent-controls-harness</a>. Run it with <code>npm test</code> on Node 18 or newer.</p>
<h3>Further reading</h3>
<ul><li><a class="inline-link" href="https://www.nist.gov/itl/ai-risk-management-framework">NIST AI Risk Management Framework</a>: a voluntary framework (AI RMF 1.0, January 2023) with a Generative AI Profile (NIST AI 600-1, July 2024).</li><li><a class="inline-link" href="https://www.anthropic.com/engineering/demystifying-evals-for-ai-agents">Demystifying evals for AI agents</a>, Anthropic Engineering, 9 January 2026: grading outcomes as well as transcripts, grader types, and capability versus regression evals.</li><li><a class="inline-link" href="https://genai.owasp.org/resource/owasp-top-10-for-agentic-applications-for-2026/">OWASP Top 10 for Agentic Applications for 2026</a>: a taxonomy of agent-specific risks, published 9 December 2025.</li></ul>]]></content:encoded>
    </item>
    <item>
      <title>50 tests passed. Is it safe? Why &quot;no failures&quot; is not proof</title>
      <link>https://keshavaai.in/journal/zero-failures-not-proof</link>
      <guid isPermaLink="true">https://keshavaai.in/journal/zero-failures-not-proof</guid>
      <pubDate>Thu, 15 Oct 2026 00:00:00 GMT</pubDate>
      <description>Passing every test only tells you how small the problem can still be. Learn the rule of three, why a release gate needs blockers and a pass mark chosen in advance, and three habits that keep the gate honest.</description>
      <content:encoded><![CDATA[<div class="note-box"><strong>In one sentence:</strong> Passing every test does not prove an AI is safe. It only tells you how small the problem can still be, so set the pass rules before you test, and let one failed critical test stop the release.</div>
<h2>Think of a bag of marbles</h2>
<p>A bag holds red and blue marbles. You pull out 10 marbles, and all 10 are blue. Does that mean there are no red ones? No. There could still be quite a few red ones hiding at the bottom. Now pull out 500 marbles, and all 500 are blue. Now you can be much more sure, but still not completely.</p>
<p>Testing an AI is the same. Each test is one marble. &quot;All tests passed&quot; is a good sign. It is not a promise.</p>
<figure class="art-fig"><img src="https://keshavaai.in/img/blog/zero-failures-not-proof.png" alt="For 10, 50 and 500 tests that all passed, the worst the real failure rate could still be: about 26 in 100, 6 in 100 and 6 in 1,000." loading="lazy"></figure>
<h2>How much does &quot;no failures&quot; really tell you?</h2>
<p>There is a simple rule, called the <strong>rule of three</strong>. If a helper passed n tests in a row, then the real failure rate is probably below about 3 divided by n. &quot;Probably&quot; here means 95 times out of 100.</p>
<div class="tbl-wrap"><table><thead><tr><th>Tests that all passed</th><th>The real failure rate could still be as high as</th></tr></thead><tbody><tr><td>10</td><td>about 26 in 100</td></tr><tr><td>50</td><td>about 6 in 100</td></tr><tr><td>100</td><td>about 3 in 100</td></tr><tr><td>500</td><td>about 6 in 1,000</td></tr></tbody></table></div>
<p>So 50 perfect tests do not mean &quot;safe&quot;. They mean &quot;probably fewer than 6 mistakes in every 100&quot;. For writing a friendly reply, that may be fine. For sending a payment, it is not.</p>
<h2>The release gate: a rule that decides, not a mood</h2>
<p>A <strong>release gate</strong> is a rule, written in code, that says whether a change may go live. It runs on every change, like a security guard at a door. It has two kinds of rule:</p>
<ul><li><strong>A blocker.</strong> Some tests are critical. For example: &quot;a yes for one payment must never work for a different payment&quot;. If even one critical test fails, the change is stopped. Good marks elsewhere cannot hide it.</li><li><strong>A pass mark.</strong> For everyday tests you choose a mark, such as 9 out of 10. You must choose it before you test. If you choose it afterwards, you will be tempted to move the line to fit the result.</li></ul>
<p>This is why a helper that gets 49 out of 50 tests right can still be stopped. If the one it missed was critical, the answer is no.</p>
<h2>Three habits that make the gate honest</h2>
<ul><li><strong>Check what happened, not what was said.</strong> If the AI says &quot;refund sent&quot;, look at the payment record. The words may be wrong even when they sound sure.</li><li><strong>Run the cheap tests first.</strong> Quick, free checks go first. The slow, costly test goes last. Stop at the first critical failure, because there is no point paying for the slow tests after a fast one said no.</li><li><strong>Test the grader too.</strong> Often another AI marks the answers. Before you trust it, let it mark 50 answers that people already marked. If it agrees with the people most of the time, use it. Check again whenever you change the grader.</li></ul>
<h2>What to do</h2>
<ul><li>Write down which tests are critical. Keep that list short and serious.</li><li>Choose the pass mark before you run the tests.</li><li>Say &quot;no failures in 50 tests&quot;, never &quot;it is safe&quot;.</li><li>Use more tests for riskier jobs.</li><li>Add every real mistake as a new test.</li></ul>
<h2>The limits of this advice</h2>
<ul><li>The rule of three assumes the tests are independent and look like real use. Tests that are too similar to each other, or too easy, make the number look better than it is.</li><li>It tells you about the kinds of cases you tested. It says nothing about kinds you never thought of.</li><li>A test that always passes is worth nothing. Check that your tests can fail: break something on purpose and see the gate say no.</li><li>The numbers here are examples. Your own risk decides how low the failure rate must be.</li></ul>
<h2>Words explained</h2>
<ul><li><strong>Critical test:</strong> a test for something that must never go wrong. One failure stops the release.</li><li><strong>Release gate:</strong> a rule that decides whether a change may go live.</li><li><strong>Pass mark:</strong> the score needed to pass the everyday tests, chosen before testing.</li><li><strong>Rule of three:</strong> if n tests all passed, the real failure rate is probably below about 3 divided by n.</li><li><strong>Grader (judge):</strong> an AI or a program that marks an answer right or wrong.</li><li><strong>Regression:</strong> something that used to work and now does not.</li></ul>
<h2>For engineers</h2>
<p>This section has the exact details. Everything above is the simple version of it.</p>
<ul><li><strong>The bound.</strong> With zero failures in n independent trials, the one-sided 95% upper confidence limit on the failure rate p solves (1 - p)^n = 0.05, so p = 1 - 0.05^(1/n), which is close to 3/n. For n = 10, 50, 100 and 500 that gives 25.9%, 5.8%, 3.0% and 0.6%. Pick the confidence level and the allowed failure rate for each risk tier, and solve for n.</li><li><strong>Gate logic.</strong> A critical failure blocks regardless of the mean. The pass threshold is fixed in the repository before the run. Report scores by category and risk tag, and gate on the worst category, not the average.</li><li><strong>Outcome over transcript.</strong> Grade the end state (the record changed, the payment exists), and use the transcript to explain a failure, not to excuse it. Anthropic&#39;s write-up on agent evals draws the same line and separates capability evals from regression evals.</li><li><strong>Cost order.</strong> Deterministic checks on every change (approval binding, budget stops, schema), targeted model-based checks next, the full end-to-end run with a judge once per release. Fail fast on the first critical failure.</li><li><strong>Judge calibration.</strong> Compare judge scores with human labels on a sample of about 50, track agreement over time, rotate answer order, and score against a rubric. Re-run the comparison after any judge-model change.</li><li><strong>Test the tests.</strong> Mutation-check the gate: introduce a known fault and confirm the gate fails. The example harness for this series does exactly that: https://github.com/kapilgupta86/agent-controls-harness</li><li><strong>Frameworks.</strong> NIST AI RMF 1.0 (voluntary, Jan 2023) and NIST AI 600-1 (Jul 2024) are the usual references for risk-based testing. They do not prescribe sample sizes.</li><li><strong>Where it fits.</strong> The book extends Chapter 12 with this material, and Appendices D and E carry the test-case template and sixteen edge cases. Autonomy levels are in the article on earned autonomy.</li></ul>]]></content:encoded>
    </item>
    <item>
      <title>AI caching, explained simply: three ways an AI avoids doing the same work twice</title>
      <link>https://keshavaai.in/journal/llm-caching-untangled</link>
      <guid isPermaLink="true">https://keshavaai.in/journal/llm-caching-untangled</guid>
      <pubDate>Wed, 14 Oct 2026 00:00:00 GMT</pubDate>
      <description>An AI can save time and money by remembering work it has already done. Learn the three kinds of memory (notes, a bookmark and an answer notebook), when each one helps, and try a simulator.</description>
      <content:encoded><![CDATA[<div class="note-box"><strong>In one sentence:</strong> An AI can save time and money by remembering work it has already done. There are three kinds of memory, and each one helps at a different moment.</div>
<h2>The big idea: do not do the same work twice</h2>
<p>Imagine doing homework with a huge textbook. If you re-read the whole book for every question, you would be there all night. Smart students keep notes, use bookmarks, and remember the answers to questions they have met before.</p>
<p>AI systems do the same. Keeping something you already worked out, so you can use it again, is called <strong>caching</strong> (say &quot;cashing&quot;).</p>
<h2>First: how an AI writes an answer</h2>
<p>An AI does not write a whole answer at once. It reads first. Then it writes one small piece at a time. A small piece is called a <strong>token</strong>. It is about three-quarters of a word.</p>
<figure class="art-fig"><img src="https://keshavaai.in/img/blog/reading-writing.png" alt="The AI reads your question, then writes the answer one small piece at a time." loading="lazy"></figure>
<ul><li><strong>The reading phase.</strong> The AI reads everything you sent it, all at once. How long this takes decides how long you wait for the first word.</li><li><strong>The writing phase.</strong> The AI writes the answer one token at a time, looking back at everything before. This decides how fast the words appear.</li></ul>
<p>Each kind of cache helps one of these phases, or skips both.</p>
<h2>Memory 1: notes on this answer (the KV cache)</h2>
<p>While writing, the AI keeps looking back at every earlier token. Instead of working it all out again for every new piece, it keeps notes about what it has already read. Think of keeping your finger on the page while you write a story.</p>
<p>These notes are called the <strong>KV cache</strong>. You do not have to switch them on. They last for one answer only. When the answer is finished, the notes are thrown away.</p>
<h2>Memory 2: a bookmark (the prompt cache)</h2>
<p>Many requests start the same way: the same rules, the same tools, the same long document. Why read them again every time? A <strong>prompt cache</strong> remembers that first part. Next time, the AI skips straight to the new part, like opening a book at your bookmark.</p>
<p>It has one big rule: the start must be exactly the same, letter for letter. If you put today&#39;s date at the very top, it changes every time, and the bookmark does not work. So put the things that never change first, and the things that change last.</p>
<pre><code>1. The rules the AI must follow      (never changes)
2. The tools it can use              (never changes)
3. The long guide document          (rarely changes)
4. The earlier chat messages        (grows slowly)
5. The new question                 (always new, so it goes last)</code></pre>
<p>A bookmark saves money and the waiting time before the first word. It does not make the words appear faster once writing has started. It usually lasts from a few minutes to a few hours.</p>
<h2>Memory 3: an answer notebook (the semantic cache)</h2>
<p>Sometimes people ask nearly the same question again. &quot;How do I reset my password?&quot; and &quot;I forgot my password, what now?&quot; use different words but mean the same thing. A <strong>semantic cache</strong> keeps a notebook of past questions and answers. If a new question means the same as an old one, the system hands back the old answer without asking the AI at all. That is the cheapest and fastest of all.</p>
<p>The risk is that the old answer may be out of date, like last year&#39;s school timetable. So give each saved answer an expiry date. And never save answers that are private or change fast, such as &quot;What is my account balance?&quot;</p>
<h2>Try it yourself</h2>
<p>Move the sliders in the simulator. Watch which requests reuse the bookmark, and how much money that saves. Then tick the box about the changing time at the top, to see how easily a bookmark gets lost.</p>
<p><a href="https://keshavaai.in/explainers/prompt-cache.html?embed=1">Interactive: Prompt cache simulator</a></p>
<h2>A worked example with numbers</h2>
<p>This example is made up, to show the idea. A helper has instructions and documents that are 8,000 tokens long. Each question adds about 400 tokens. Someone asks 6 questions, 2 minutes apart.</p>
<ul><li><strong>Without a bookmark,</strong> the AI reads 8,400 tokens, six times. That is 50,400 tokens of reading.</li><li><strong>With a bookmark,</strong> the first question costs a little extra, to set up the bookmark. After that, the long part is read at one-tenth of the price. The total comes to about 16,400 tokens of reading.</li></ul>
<p>That is about two-thirds cheaper. The exact prices depend on the company, but the idea is the same.</p>
<h2>Common mistakes</h2>
<ul><li>Putting something that changes, like the time, at the top of the prompt. The bookmark breaks every time.</li><li>Saving answers that go out of date, or that hold private information.</li><li>Expecting a bookmark to make writing faster. It only helps the reading.</li><li>Forgetting that a bookmark runs out. If nobody asks for a while, it is thrown away.</li></ul>
<h2>The short version</h2>
<ul><li>The notes help the AI write one answer. They are automatic.</li><li>A bookmark saves time and money when requests start the same way.</li><li>An answer notebook skips the AI completely, but the answer can get old.</li></ul>
<h2>The limits of this advice</h2>
<ul><li>Prices, time limits and minimum sizes differ by company and change often. Check the company&#39;s own page before you rely on a number.</li><li>The worked example is made up. Your savings depend on how often requests start the same way.</li><li>An answer notebook can return an old or wrong answer, so it needs expiry dates and careful choices about what to save.</li></ul>
<h2>Words explained</h2>
<ul><li><strong>Token:</strong> a small piece of text, about three-quarters of a word.</li><li><strong>Prompt:</strong> what you send to the AI: your question, plus any rules and documents.</li><li><strong>Cache / caching:</strong> keeping something you already worked out so you can use it again.</li><li><strong>Reading phase (prefill):</strong> the AI reads everything you sent.</li><li><strong>Writing phase (decode):</strong> the AI writes the answer one token at a time.</li><li><strong>KV cache:</strong> the notes the AI keeps while writing one answer.</li><li><strong>Prompt cache (also called prefix cache):</strong> the bookmark for a start that repeats.</li><li><strong>Semantic cache:</strong> the notebook of old questions and answers.</li><li><strong>Expiry time (TTL):</strong> how long a saved item may be used before it is thrown away.</li></ul>
<h2>For engineers</h2>
<p>This section has the exact details. Everything above is the simple version of it.</p>
<h3>The technical names</h3>
<p>Prefill reads the whole prompt in parallel and is compute-bound; it decides time-to-first-token. Decode generates tokens one at a time and is memory-bandwidth-bound; it decides tokens per second. The KV cache stores each token&#39;s key and value vectors so attention is not recomputed at every step. It grows with context length, which is why quantizing it (INT8 or INT4) is a lever at scale. A prompt (prefix) cache reuses the KV computation for an identical prefix across requests. In vLLM, for example, the cache is keyed on a hash of each block of tokens together with the tokens before it, so requests sharing a prefix share the stored blocks. A semantic cache sits in front of the model and matches on embedding similarity; it skips inference on a hit.</p>
<figure class="art-fig"><img src="https://keshavaai.in/img/blog/llm-caching-pipeline.png" alt="The technical pipeline: your prompt goes through prefill and decode. A semantic cache can skip both, the prompt cache feeds prefill, and the KV cache feeds decode." loading="lazy"></figure>
<h3>What the companies document (checked 14 October 2026)</h3>
<div class="tbl-wrap"><table><thead><tr><th>Provider</th><th>Cache lifetime</th><th>Minimum prompt</th><th>Cached input price</th></tr></thead><tbody><tr><td>Anthropic</td><td>5 minutes by default, refreshed on use; 1 hour optional</td><td>512 to 4,096 tokens, depending on model</td><td>Reads at 0.1x the base input price (0.05x or 0.025x on some newer models); writes at 1.25x (5 minutes) or 2x (1 hour)</td></tr><tr><td>OpenAI</td><td>Newest models: at least 30 minutes. Earlier models: in-memory, typically 5 to 10 minutes and up to 1 hour, or 24 hours</td><td>1,024 tokens on the newest models; varies on earlier ones</td><td>Cached input discounted up to 95%; on the newest models, writes at 1.25x and reads at 0.1x</td></tr><tr><td>Google Gemini</td><td>Implicit caching on by default for Gemini 2.5 and newer; lifetime not stated on the page</td><td>2,048 to 4,096 tokens, depending on model</td><td>Savings passed on automatically; no percentage stated</td></tr></tbody></table></div>
<p>Sources: <a class="inline-link" href="https://platform.claude.com/docs/en/build-with-claude/prompt-caching">Anthropic prompt caching</a>, <a class="inline-link" href="https://developers.openai.com/api/docs/guides/prompt-caching">OpenAI prompt caching</a>, <a class="inline-link" href="https://ai.google.dev/gemini-api/docs/caching">Google Gemini caching</a>, <a class="inline-link" href="https://docs.vllm.ai/en/v0.8.5/design/v1/prefix_caching.html">vLLM automatic prefix caching</a>. Prices and limits change often; check the provider&#39;s page before you rely on a number. Neither Anthropic&#39;s nor OpenAI&#39;s page gives a general latency percentage, so treat any quoted latency saving as workload-specific until you measure it.</p>
<h3>The write premium, as arithmetic</h3>
<p>Take a provider that charges 1.25x to write a 5-minute cache entry and 0.1x to read it (the Anthropic multipliers above), and count the cost of the shared prefix in units of its normal input price. Used once, caching costs 1.25 instead of 1.0, a small loss. Used twice, it costs 1.25 + 0.1 = 1.35 instead of 2.0. Used ten times within the window, it costs 1.25 + 9 x 0.1 = 2.15 instead of 10. This is arithmetic from the published multipliers, not a benchmark.</p>
<h3>Cheat sheet</h3>
<div class="tbl-wrap"><table><thead><tr><th>Technique</th><th>Phase it helps</th><th>What it saves</th><th>Turn it on when</th></tr></thead><tbody><tr><td>KV cache</td><td>Decode</td><td>Recomputing attention at every step</td><td>Always on; nothing to configure</td></tr><tr><td>Prompt / prefix caching</td><td>Prefill</td><td>Cost and time-to-first-token</td><td>Prefixes repeat across requests, within the cache window</td></tr><tr><td>Semantic caching</td><td>Both (skipped entirely)</td><td>Cost and total latency</td><td>Genuinely repeated questions, and some staleness is tolerable</td></tr><tr><td>Quantization (not a cache)</td><td>Both, through memory footprint</td><td>Memory, and some latency</td><td>Almost always worth evaluating at scale</td></tr><tr><td>FlashAttention (not a cache)</td><td>Both, through memory reads</td><td>Latency</td><td>Already standard in most modern serving stacks</td></tr><tr><td>Speculative decoding (not a cache)</td><td>Decode</td><td>Tokens per second</td><td>High-volume, decode-bound workloads</td></tr></tbody></table></div>
<h3>Keeping semantic caches honest</h3>
<p>A semantic cache lives until a TTL, an eviction rule or an invalidation event removes the entry, so you set the policy. Do not cache answers that contain personal data or change quickly. See <a class="inline-link" href="https://keshavaai.in/journal/cost-aware-testing">cost-aware testing</a> for measuring cache hit rate, cost per successful task and answer freshness.</p>]]></content:encoded>
    </item>
    <item>
      <title>Answers you can check: copy the dangerous part, don&#39;t reword it</title>
      <link>https://keshavaai.in/journal/answers-you-can-check</link>
      <guid isPermaLink="true">https://keshavaai.in/journal/answers-you-can-check</guid>
      <pubDate>Thu, 01 Oct 2026 00:00:00 GMT</pubDate>
      <description>When an AI explains something risky, let it copy the exact steps from the official guide and write only a short, friendly introduction.</description>
      <content:encoded><![CDATA[<div class="note-box"><strong>In one sentence:</strong> When an AI explains something risky, let it copy the exact steps from the official guide, and let it write only a short, friendly introduction.</div>
<h2>Think of a medicine label</h2>
<p>A pharmacist reads the dose from the label. Would you want them to say it &quot;in their own words&quot;? Of course not. One changed number could make you ill.</p>
<p>AI assistants have the same problem. They are brilliant at writing smooth sentences in their own words. But for risky steps, such as commands to type, numbers and the order of steps, &quot;in their own words&quot; is exactly what we do not want.</p>
<h2>A small example</h2>
<p>Someone asks: &quot;How do I upgrade this system?&quot; The official guide says:</p>
<pre><code>Step 1: Make a backup.
Step 2: Run upgrade --safe</code></pre>
<p>Now the AI rewords it: &quot;Just run the upgrade.&quot; It has quietly dropped the word <code>--safe</code>. The upgrade might now delete things. The answer sounded helpful, and it caused a big problem.</p>
<h2>The fix: two kinds of text</h2>
<ul><li><strong>Dangerous text</strong> (steps, numbers, commands) is copied word for word from the approved guide. The AI is not allowed to change it.</li><li><strong>Friendly text</strong> (a one or two sentence introduction) is written by the AI, using only the pages that were found.</li></ul>
<p>Nothing else on the page is written by the AI.</p>
<h2>Check the copy</h2>
<p>Even a copy can go wrong, like a smudged photocopy. So when the guide is loaded, the computer makes a &quot;fingerprint&quot; for each step. A fingerprint is a short code that changes if even one letter changes. Before showing a step, the computer checks its fingerprint. If it does not match, the step is hidden.</p>
<h2>Let people check too</h2>
<p>Every answer should link to the exact page of the guide, with the passage marked. Then a person can check in seconds instead of just trusting. And when the guide does not cover the question, the assistant should say so, or ask which version the person means. It should never guess.</p>
<h2>What to do</h2>
<ul><li>Mark which parts of an answer are dangerous.</li><li>Copy those parts exactly. Do not let the AI reword them.</li><li>Make a fingerprint for each step, and check it before showing the step.</li><li>Show where the answer came from.</li><li>Say &quot;I don&#39;t know&quot; when the guide is silent.</li></ul>
<h2>The limits of this advice</h2>
<ul><li>Copying exactly does not help if the guide itself is wrong or out of date. Keep the guide correct.</li><li>People still need to read the steps. A good answer makes checking easy. It does not replace good judgement.</li><li>Deciding which parts are &quot;dangerous&quot; takes care. When unsure, copy.</li></ul>
<h2>Words explained</h2>
<ul><li><strong>Assistant:</strong> an AI helper you ask questions.</li><li><strong>Approved guide:</strong> the official document that people have checked.</li><li><strong>Command:</strong> a line you type to tell a computer what to do.</li><li><strong>Fingerprint:</strong> a short code that changes if even one letter of the text changes.</li><li><strong>Word for word:</strong> exactly the same, with nothing changed.</li></ul>
<h2>For engineers</h2>
<p>This section has the exact details. Everything above is the simple version of it.</p>
<ul><li><strong>Assemble, don&#39;t generate.</strong> Build the answer from source blocks. The model writes only a short lead-in, constrained to the retrieved passages. Steps, numbers and commands come from the document.</li><li><strong>Integrity check.</strong> Store a hash (for example SHA-256) of each step block at ingestion. Recompute it before rendering. Withhold the block on a mismatch.</li><li><strong>Provenance.</strong> Cite document, page and passage. When the corpus does not cover the query, abstain, or ask a clarifying question about the version or variant.</li><li><strong>Where it fits.</strong> This is the grounding and citation pattern (Chapter 11) combined with approval for risky actions (Chapter 13).</li></ul>]]></content:encoded>
    </item>
    <item>
      <title>Two kinds of questions need two kinds of helpers</title>
      <link>https://keshavaai.in/journal/two-kinds-of-questions</link>
      <guid isPermaLink="true">https://keshavaai.in/journal/two-kinds-of-questions</guid>
      <pubDate>Thu, 01 Oct 2026 00:00:00 GMT</pubDate>
      <description>&quot;How do I...?&quot; is a question for a book of instructions. &quot;What is connected to what?&quot; is a question for a map. A good AI assistant sorts the question first, then sends it to the right helper.</description>
      <content:encoded><![CDATA[<div class="note-box"><strong>In one sentence:</strong> Some questions are answered by a book of instructions, and others by a map of connections, so a good assistant first works out which kind it was asked.</div>
<h2>Think of a school library</h2>
<p>If you ask &quot;How do I do this science experiment?&quot;, the librarian points you to a book. If you ask &quot;Which bus does each child in my class take?&quot;, you need a chart of connections: who goes with which bus.</p>
<p>People ask AI assistants both kinds of questions in the same chat. The assistant has to notice the difference. In AI, the part that decides this is called a <strong>router</strong>. We will call it the sorter.</p>
<h2>Book questions: &quot;how&quot; and &quot;what does it mean&quot;</h2>
<p>Examples: &quot;How do I reset my password?&quot; or &quot;What changed in the new version?&quot; The answer is written down in a guide. So the assistant searches the approved guides, finds the best pages, and shows the exact lines with the page they came from.</p>
<h2>Map questions: &quot;what is connected to what&quot;</h2>
<p>Examples: &quot;Which computers are in Room 5, and how many are there?&quot; This is a question about connections, like a map of a school. The answer is not in one page of a book. It comes from a database that holds the connections.</p>
<p>For these questions, use a ready-made, checked question to ask the database. Then let ordinary computer code write the answer. The AI may introduce the table, but it must never write a number or a name that came from the database. If the database says 14 computers, the AI must not say 12.</p>
<h2>The sorter is the hard part</h2>
<p>Knowing which kind of question was asked is the hardest step. A good sorter does four things:</p>
<ul><li>It makes one quick AI call to decide which kind of question it is.</li><li>It has a simple back-up, a list of key words, for when the AI is not reachable.</li><li>When a name could mean several things, it shows the real choices and lets the person click. Like asking &quot;Which Sam: Sam from class 5 or Sam from class 6?&quot;, instead of guessing.</li><li>When a question has two parts, it splits them and sends each part to the right helper.</li></ul>
<h2>What to do</h2>
<ul><li>Decide which questions your assistant must answer from documents, and which from a database of connections.</li><li>Build a sorter that picks the right helper, and asks the person when unsure.</li><li>Let code write every number and name that comes from a database.</li></ul>
<h2>The limits of this advice</h2>
<ul><li>Some questions need both helpers. Splitting them well takes testing.</li><li>A sorter can be wrong. That is why it must ask the person when it is unsure, and why you should test it with real questions.</li><li>A graph database is only worth building if you really have many connection questions. Many assistants only need documents.</li></ul>
<h2>Words explained</h2>
<ul><li><strong>Router (the sorter):</strong> the part that decides which helper should answer.</li><li><strong>Database:</strong> an organised store of facts, such as lists and tables.</li><li><strong>Graph:</strong> a way to store connections, like a map of who is linked to what.</li><li><strong>Retrieval:</strong> finding the right pages for a question.</li><li><strong>Citation:</strong> showing where an answer came from.</li></ul>
<h2>For engineers</h2>
<p>This section has the exact details. Everything above is the simple version of it.</p>
<ul><li><strong>Document questions.</strong> Combine meaning-based (dense) and word-based (sparse) search, re-rank the candidates, and answer with quotations and citations.</li><li><strong>Relationship questions.</strong> Use fixed, reviewed, parameterised graph queries. Let code format the result. The model never writes a value that came from the database.</li><li><strong>Router.</strong> One cheap classification call extracts the intent and any names, with a keyword fallback when the model is unreachable. Ambiguous names return real candidates for a click. Compound questions are split, one part per source.</li><li><strong>Where it fits.</strong> This is the hybrid pattern from Chapters 10 and 16.</li></ul>]]></content:encoded>
    </item>
    <item>
      <title>Don&#39;t patch the question: fix the step that broke</title>
      <link>https://keshavaai.in/journal/no-keyword-patches</link>
      <guid isPermaLink="true">https://keshavaai.in/journal/no-keyword-patches</guid>
      <pubDate>Thu, 01 Oct 2026 00:00:00 GMT</pubDate>
      <description>When an assistant gets a question wrong, adding a rule for that one question feels fast and slowly ruins the system. A better habit: find the step that broke, and fix that.</description>
      <content:encoded><![CDATA[<div class="note-box"><strong>In one sentence:</strong> When an assistant gets a question wrong, do not add a special rule for that question. Find which step broke, and fix that step.</div>
<h2>Think of a spelling test</h2>
<p>A teacher marks one wrong word. You could memorise just that word. But the next test has new words, and you get those wrong too. The better plan is to learn the spelling rule.</p>
<p>AI teams make the same mistake. A test question fails. Someone adds a rule that mentions a word from that question. The test now passes. Ten rules later, nobody understands the system, and the next ten questions fail anyway.</p>
<h2>A small example</h2>
<p>Someone asks: &quot;How do I reset the printer?&quot; The assistant gets it wrong. A bad fix: &quot;If the question has the word printer, show page 12.&quot; Tomorrow someone asks about the scanner, and it fails. So you add another rule. And another.</p>
<p>A good fix starts with a question: why did it fail? Maybe the right page calls it a &quot;power cycle&quot;, not a &quot;reset&quot;, so the search never found it. Teach the search about that, and printer, scanner and many other questions start working at once.</p>
<h2>Ask which step broke</h2>
<p>An assistant answers in steps. Each step can fail in its own way:</p>
<ul><li><strong>Step 1, find the pages.</strong> It never found the right page.</li><li><strong>Step 2, put the best first.</strong> It found the right page, but ranked it too low.</li><li><strong>Step 3, pick the right part.</strong> It looked at the wrong part of the page.</li><li><strong>Step 4, check the answer.</strong> It never checked the answer against the page.</li></ul>
<p>Each step has its own proper fix, a fix to the design of that step, not to one question.</p>
<h2>A rule of thumb</h2>
<p>A fix should never name a special word or a special question. If you catch yourself writing one, stop. Ask: what could the system use instead? And after the third patch in the same place, change the design.</p>
<h2>Keep a notebook of what you tried</h2>
<p>Keep a simple table: what you tried, what did not work and why, and which ideas work together. Put the ideas that give the most gain for the least cost at the top. A notebook like this teaches a team faster than any meeting. It also stops the same failed idea from coming back.</p>
<h2>The limits of this advice</h2>
<ul><li>Sometimes a quick patch is the right choice, for example during an urgent problem. Mark it as temporary, and plan the real fix.</li><li>Finding the broken step takes some detective work and good test questions.</li><li>A fix to one step can change the others, so run all your tests again after each change.</li></ul>
<h2>Words explained</h2>
<ul><li><strong>Assistant:</strong> an AI helper you ask questions.</li><li><strong>Patch:</strong> a quick fix that covers one problem without fixing its cause.</li><li><strong>Ranking:</strong> putting the best answers at the top.</li><li><strong>Keyword:</strong> a special word the system looks for.</li><li><strong>Test question:</strong> a question with a known right answer, used to check the system.</li></ul>
<h2>For engineers</h2>
<p>This section has the exact details. Everything above is the simple version of it.</p>
<ul><li><strong>Failure layers.</strong> A wrong answer comes from one of a few causes: the right passage was never retrieved (recall), it was retrieved but ranked too low (ranking), the wrong part of the passage was chosen, or the answer was not verified against the evidence.</li><li><strong>Structural fixes.</strong> Examples are where a term is first introduced, what kind of section it is, and how scores are blended. A fix must not name a term or a question.</li><li><strong>Trade-off table.</strong> Record the levers tried, what did not work and why, and which combinations do work, ordered by gain per cost.</li><li><strong>Where it fits.</strong> See evaluation engineering in Chapter 12.</li></ul>]]></content:encoded>
    </item>
    <item>
      <title>Test the cheap things first: why your AI budget alert came from your tests</title>
      <link>https://keshavaai.in/journal/cost-aware-testing</link>
      <guid isPermaLink="true">https://keshavaai.in/journal/cost-aware-testing</guid>
      <pubDate>Thu, 01 Oct 2026 00:00:00 GMT</pubDate>
      <description>Every AI test costs money, because the AI has to work on each question. Run the quick, free checks every time, a few tests when you change something, and the full big test once at the end.</description>
      <content:encoded><![CDATA[<div class="note-box"><strong>In one sentence:</strong> Every AI test costs money, so run the quick, free checks every time, and the big expensive test only once at the end.</div>
<h2>Think of a long bike trip</h2>
<p>Before a long trip you check the tires and the brakes. That takes a minute and costs nothing. If you fix the brakes, you take a short ride to try them. You do not ride the whole day just to test one brake pad. The full-day ride happens once, when everything is ready.</p>
<p>Testing an AI works the same way.</p>
<h2>Why AI tests cost real money</h2>
<p>Normal tests are almost free. AI tests are not. Every test question makes the AI work, often several times: it searches, it sorts the results, it writes an answer, and another AI may even grade the answer. Run the full set of tests after every small change, and the budget alert goes off long before real users arrive.</p>
<h2>Three levels of testing</h2>
<ul><li><strong>Level 1: quick, free checks, every time.</strong> These need no AI at all. Does the code run? Is the answer in the right shape? Are the links real?</li><li><strong>Level 2: only the tests for what you changed.</strong> If you changed how dates are handled, run the date tests, not everything.</li><li><strong>Level 3: the full big test, once at the end.</strong> Run it after a batch of changes, as the final gate.</li></ul>
<h2>Habits that save money</h2>
<ul><li><strong>Remember repeated work.</strong> If the same question was asked before, reuse the answer, so a re-run costs nothing.</li><li><strong>Label test spending.</strong> Give test traffic its own label, so it never hides inside the real bill.</li><li><strong>Compare the bill before and after a big run.</strong> And decide in advance when a small change does not deserve a full run.</li></ul>
<h2>Do not fool yourself about quality</h2>
<p>Imagine you practise with last year&#39;s exam paper until you get every answer right. That does not prove you know the subject. You need a new paper that you have never seen. In testing, this new paper is called a <strong>held-out set</strong>. You never tune on it.</p>
<p>Keep two settings: one for the best quality and one for the lowest cost. Judge every change on both the main test set and the held-out set. Keep a change only if neither one gets worse. And put every experiment behind a switch, so a bad change can be undone in seconds.</p>
<h2>What to do</h2>
<ul><li>Put your tests into three levels, cheapest first.</li><li>Cache repeated calls and label test spending.</li><li>Keep a held-out set that you never tune on.</li><li>Put experiments behind a switch.</li></ul>
<h2>The limits of this advice</h2>
<ul><li>Cheap tests can miss problems that only the full test finds, so the full test still has to run.</li><li>Which tests are &quot;affected&quot; by a change is a judgement call. When unsure, run more.</li><li>Saving money must never mean skipping safety tests that matter.</li></ul>
<h2>Words explained</h2>
<ul><li><strong>Test set:</strong> a list of questions with known right answers, used to check the AI.</li><li><strong>Held-out set:</strong> a second list that you keep secret and never practise on.</li><li><strong>Cache:</strong> remembering an answer so you do not have to work it out again.</li><li><strong>Budget label:</strong> a tag that shows which spending belongs to which job.</li><li><strong>Grader (judge):</strong> an AI or a program that marks an answer right or wrong.</li></ul>
<h2>For engineers</h2>
<p>This section has the exact details. Everything above is the simple version of it.</p>
<ul><li><strong>Cost drivers.</strong> Each test question can trigger retrieval, re-ranking, generation and a judge call. Run the cheap deterministic checks first (does the code run, is the output shaped correctly, are the citations valid).</li><li><strong>Tiers.</strong> Affected categories after each focused change; the full set once per batch as the final gate.</li><li><strong>Controls.</strong> Cache repeated calls, tag test traffic with its own budget, and look at spend before and after big runs.</li><li><strong>Accuracy hygiene.</strong> Two named profiles (best accuracy, lowest cost); judge changes on the main set and a held-out set that is never tuned on; keep every experiment behind a switch.</li><li><strong>Where it fits.</strong> See evaluation engineering (Chapter 12) and the two dashboards (Chapter 22). The article on AI caching explains one way to make repeated calls cheaper.</li></ul>]]></content:encoded>
    </item>
    <item>
      <title>Always say how old the information is</title>
      <link>https://keshavaai.in/journal/say-how-old-the-data-is</link>
      <guid isPermaLink="true">https://keshavaai.in/journal/say-how-old-the-data-is</guid>
      <pubDate>Thu, 01 Oct 2026 00:00:00 GMT</pubDate>
      <description>A screen that shows last month&#39;s data looks exactly like one showing this minute&#39;s. Put the date on every screen and in every answer, and start with helpers that can only look, not touch.</description>
      <content:encoded><![CDATA[<div class="note-box"><strong>In one sentence:</strong> Always put the date on information, so nobody mistakes old information for fresh information.</div>
<h2>Think of the date on a milk carton</h2>
<p>A milk carton without a date is a gamble. Old milk and fresh milk look the same until you taste it. The date on the carton lets you decide before you pour.</p>
<p>Screens and AI assistants often show old information in the same confident style as fresh information. This is a quiet way of lying.</p>
<h2>A small example</h2>
<p>A screen says &quot;All printers: OK&quot;, with a big green tick. Someone reads it and decides not to check the broken printer in Room 5. But the screen is a copy from three weeks ago. The printer broke last Tuesday. Nobody knew, because nothing on the screen said how old it was.</p>
<h2>Label the information, not just the page</h2>
<p>If any part of your system shows a saved copy (a <strong>snapshot</strong>), say so. Put the date:</p>
<ul><li>on the screen,</li><li>in the AI&#39;s answer,</li><li>and in anything you export or send.</li></ul>
<p>A good label says both the time and how long ago: &quot;As of 3 Oct, 10:00 (21 days ago).&quot; It costs one line, and it saves a lot of arguments.</p>
<h2>When the information is too old</h2>
<p>Decide in advance how old is too old. Then make the system say so: &quot;This information is 21 days old. Do you want me to refresh it?&quot; Do not hide it, and do not guess.</p>
<h2>A second habit: start by only looking</h2>
<p>Start with a helper that can only look, never touch. Anything that could change a device or a record should be built switched off, and switched on only behind a person&#39;s approval. That is the same idea as in the article &quot;Autonomy is earned&quot;: freedom comes one step at a time.</p>
<h2>What to do</h2>
<ul><li>Save the time when each piece of information was collected.</li><li>Show the date and the age on screens, in answers and in exports.</li><li>Decide how old is too old, and say so when it is.</li><li>Start read-only. Add actions later, behind approval.</li></ul>
<h2>The limits of this advice</h2>
<ul><li>Even a fresh label can be wrong if the clock or the source is wrong. Check the source too.</li><li>Too many labels can clutter a screen. Put them where a decision is made.</li><li>A date does not make old information right. It only lets people judge it.</li></ul>
<h2>Words explained</h2>
<ul><li><strong>Snapshot:</strong> a saved copy of information at one moment in time.</li><li><strong>Dashboard:</strong> a screen that shows the state of many things at once.</li><li><strong>Read-only:</strong> able to look, but not able to change anything.</li><li><strong>Approval:</strong> a yes from a person before something happens.</li></ul>
<h2>For engineers</h2>
<p>This section has the exact details. Everything above is the simple version of it.</p>
<ul><li><strong>Carry the timestamp.</strong> Store an as-of time with every data point, and pass it through APIs, answers and exports. Show both the absolute time and the relative age.</li><li><strong>Freshness rules.</strong> Define a staleness threshold per data type, and have the system say when it is exceeded and offer a refresh.</li><li><strong>Read-only first.</strong> Build write actions switched off, and enable them only behind an approval step.</li><li><strong>Where it fits.</strong> See human-in-the-loop (Chapter 13) and observability (Chapter 18).</li></ul>]]></content:encoded>
    </item>
  </channel>
</rss>
