# Technical, Context, and Evaluation Debt by [kirupa](https://www.kirupa.com/me/index.htm) | filed under [AI Fundamentals](https://www.kirupa.com/ai_fundamentals/index.htm) **TL;DR:** A shortcut that saves time today but costs a little extra every time we touch that part later is called technical debt. AI products add two more kinds: stale prompts, instructions, and docs that agents trust, called context debt, and behavior nothing tests, called evaluation debt. All three charge interest until we pay them down. - Ward Cunningham's 1992 metaphor: the shortcut is the loan, and time spent on not-quite-right code is the interest. Pinwheel's 4pm cutoff, typed into four files, cost Wren a full day. - Biscuit's bakery facts still described only our two shops, so it told a customer a Rolling Pin shop was open until 6pm, and our coding agent wired new code to a retired service. - Only 6 of Biscuit's 22 behaviors had tests, so 9 prompt changes meant 144 chats checked by hand, and switching to a cheaper model felt too risky. - Keep one list for all three kinds, write down the interest each item charges, and pay down what we touch most often first. Crumb & Co. just bought Rolling Pin Bakeries, and our owner has what sounds like a small request. Could Biscuit, our help desk bot, answer questions about Rolling Pin's six shops too? Wren, our web developer, looked it over and said two days, maybe three. It took three weeks. Nobody was slacking, and nothing was on fire. We kept paying for shortcuts that were taken months or years earlier, some of them in code and some in places most of us do not think of as code at all. In this article, we are going to find where those costs hide in an AI product, and we will figure out how to stop paying them on every change we make. Onwards! ## A Two-Day Job That Took Three Weeks Here is how Wren's estimate compares with what actually happened, in working days: ![Two bars measured in working days. The estimate bar is 2 days long. The actual bar is 15 days long: 2 days of the planned work, then 5 days untangling Pinwheel's code, 4 days fixing stale instructions, and 4 days hand-checking Biscuit.](https://www.kirupa.com/ai_fundamentals/images/three_kinds_of_debt_estimate.png) Only the first slice of the bottom bar is the work we planned. The other three slices went into problems that were already sitting in our systems before the job started. (Douglas Hofstadter has a famous law about this: a job always takes longer than we expect, even when we take his law into account. Our job had a more specific reason, though.) The first extra slice went into Pinwheel, Rolling Pin's 15-year-old ordering system. The next one went into fixing the written instructions that Biscuit and our coding agent read before they do anything. The last one went into checking, by hand, that Biscuit still answered old questions correctly after every change. These are three flavors of the same problem, and we are going to look at each one, starting with the oldest. ## Borrowing Time Pinwheel was built in 2011, and Yara, who leads Rolling Pin's two-person ordering team, has kept it taking orders ever since. Along the way, there were plenty of evenings where a quick fix was the right call. One of those quick fixes is the 4pm order cutoff. Instead of living in one place, the number **16** (4pm on a 24-hour clock) is typed directly into four different files: ![Four Pinwheel files shown as cards: order_form.php, confirm_email.php, admin_orders.php, and nightly_report.php. Each one has its own highlighted line with the number 16 in it, and a handwritten note says same rule, four copies!](https://www.kirupa.com/ai_fundamentals/images/three_kinds_of_debt_pinwheel_cutoff.png) Typing **16** four times was faster than building a settings page, and for years that shortcut cost nothing. Then we needed Biscuit to know the cutoff. Wren had to find all four copies, check whether any of them disagreed, and work out which one Pinwheel actually obeys. That took a whole day, and it will take a whole day again the next time anyone touches the cutoff. In a 1992 report about the WyCash portfolio software his team built, a programmer named Ward Cunningham described this kind of problem with a comparison to money: > Shipping first time code is like going into debt. A little debt speeds development so long as it is paid back promptly with a rewrite. > > [Ward Cunningham, The WyCash Portfolio Management System (OOPSLA '92)](http://c2.com/doc/oopsla92.html) That comparison stuck, and shortcuts like Pinwheel's are now called **technical debt**. The shortcut is the loan. The time we saved is the cash we got up front. The extra time we spend working around the shortcut, every single time, is the interest. Cunningham put that last part very plainly: ***"Every minute spent on not-quite-right code counts as interest on that debt."*** Here is Pinwheel's loan, paid back one change at a time: ![A timeline of Pinwheel's cutoff shortcut. On the left, typing 16 into four files saves about a day. To the right, each later change to the cutoff costs extra time: 3 hours in 2015, 5 hours in 2019, and a full day in Wren's job. A handwritten note points at the growing costs: the interest!](https://www.kirupa.com/ai_fundamentals/images/three_kinds_of_debt_loan.png) What makes the debt comparison so useful is that it does not say shortcuts are bad. Back in 2011, those four copies of **16** got Rolling Pin's orders flowing sooner, and that was a fine trade. The trouble starts when nobody keeps track of what we owe. The interest keeps piling up, and one day a two-day job turns into a three-week one. ## The Model Is the Small Box Pinwheel's debt lives in code, so at least we know where to go looking for it. In 2015, a team of Google engineers published a paper called [Hidden Technical Debt in Machine Learning Systems](https://papers.nips.cc/paper_files/paper/2015/hash/86df7dcfd896fcaf2674f757a2463eba-Abstract.html). One of their main points was that the model is a small part of a machine learning product, and most of the debt piles up in everything around the model. Their famous diagram shows the model code as a tiny box surrounded by much bigger ones. Here is that same idea, redrawn for Biscuit: ![A small dark box labeled model call sits in the middle of a much larger arrangement of boxes, all things the bakery wrote: the system prompt, the bakery facts, the search index, the tool code, the Pinwheel sync, AGENTS.md, guardrails, logs, and test questions.](https://www.kirupa.com/ai_fundamentals/images/three_kinds_of_debt_small_box.png) Our model call is one small box. Everything around that box is stuff we wrote and keep running, and every one of those boxes can drift out of date or stop being checked. The same team's earlier [2014 paper](https://research.google/pubs/machine-learning-the-high-interest-credit-card-of-technical-debt/) on the subject had an even blunter title: Machine Learning: The High-Interest Credit Card of Technical Debt. For Biscuit, two of those surrounding boxes had been running up balances of their own. ## Card Two: Context Debt Biscuit does not know anything about our bakery on its own. Every request we send includes a page of bakery facts that describes our shop, our hours, and our menu (the setup we built in [Context Engineering](https://www.kirupa.com/ai_fundamentals/context_engineering.htm)). Our coding agent works the same way. Before the agent touches the website's code, it reads an instructions file called `AGENTS.md`. Here is what those two files said when Wren started, next to what is true now: ![Two columns. Under What our files say: the bakery facts say We have two shops, on Elm Street and Main Street, and Pickup runs until 6pm, and AGENTS.md says Orders live in orders-v1. Under What's true now: eight shops, and Rolling Pin's six shops close at 4pm, and orders-v1 was retired in March in favor of orders-v2. Each old line is crossed out in red.](https://www.kirupa.com/ai_fundamentals/images/three_kinds_of_debt_stale_context.png) Neither file is wrong in a way that throws an error. Both files describe the bakery as it was, and both get read with total trust. Here is what that trust looks like when a customer asks Biscuit about one of the new shops: ![Biscuit's chat window. A customer asks, Can I pick up my order at the Rolling Pin shop at 5pm? Biscuit replies, Sure! Pickup runs until 6pm at all of our shops. A handwritten note points at the reply: they close at 4!](https://www.kirupa.com/ai_fundamentals/images/three_kinds_of_debt_chat_pickup.png) Our coding agent made the same kind of mistake in code. `AGENTS.md` said orders live in `orders-v1`, and here is what the agent reported back when Wren asked it to load Rolling Pin's orders: ![A terminal where the coding agent reports Done! It updated 4 files to load Rolling Pin orders from orders-v1, listing shop_page.js, order_status.js, pickup.js, and biscuit_tools.js, with all tests passing. A handwritten note points at orders-v1: turned off in March!](https://www.kirupa.com/ai_fundamentals/images/three_kinds_of_debt_agent_diff.png) The agent did exactly what its instructions said, and it was pretty cheerful about the whole thing. Our tests passed because none of them called the real service. When written-down context goes stale, every agent and every new teammate who reads that context picks up the mistake. The gap between what our prompts, instruction files, docs, and search indexes say and what is true today is what we will call **context debt**. The interest on context debt is sneaky. Context debt does not make our work slower in a way anybody notices. Instead, our agents end up wrong in a way that looks right, and someone pays for that later, one correction at a time. Our search index can carry context debt too, which is the whole problem [Keeping the Index Fresh](https://www.kirupa.com/ai_fundamentals/keeping_the_index_fresh.htm) solves. ## Card Three: Evaluation Debt The last four days of the job went into something even harder to see. When Wren first built Biscuit, she wrote six test questions with known right answers (an [eval](https://www.kirupa.com/ai_fundamentals/what_are_llm_evals.htm)), and we ran them after every change. Since then, Biscuit has learned to do a whole lot more: ![A grid of Biscuit's 22 behaviors, such as pickup times, nut allergies, gluten-free list, deposit refunds, order status, and catering orders. Six tiles have a green check for has a test. The other 16 tiles are gray and dashed with a question mark, and a handwritten note says nobody checks these!](https://www.kirupa.com/ai_fundamentals/images/three_kinds_of_debt_eval_coverage.png) Six of Biscuit's **22** behaviors have a test. The other **16** work today, as far as we know. Every time we changed Biscuit's prompt to add the Rolling Pin shops, the only way to know whether the allergy answers still worked was to open a chat and ask. Here is how that added up over the job: ![A tally of hand checks. We changed Biscuit's prompt 9 times during the job, and after each change Wren typed a chat for each of the 16 untested behaviors: 9 changes times 16 chats is 144 chats typed by hand.](https://www.kirupa.com/ai_fundamentals/images/three_kinds_of_debt_hand_checks.png) That is **144** chats, typed and read by hand, and every one of them will need typing again after our next prompt change. Behavior that we depend on, but that nothing checks automatically, is what we will call **evaluation debt**. Evaluation debt charges interest in two ways. The first is all of that hand-checking. The second is fear. When a newer, cheaper model comes out, how do we know Biscuit will still get the allergy questions right? A team with good evals can find out in an afternoon, and a team without them has to guess: ![Two lanes for trying a newer model. With evals: run 120 test questions, 3 fail, fix the prompt, and switch on Friday. Without evals: hand-check a few chats, still unsure, and stay on the old, pricier model.](https://www.kirupa.com/ai_fundamentals/images/three_kinds_of_debt_upgrade.png) The team in the bottom lane isn't being lazy. Without tests, switching models is a gamble with customers' allergy questions, so staying put feels safer, and that team will keep paying for the old model month after month. Google engineers made the same connection between tests and debt in [The ML Test Score](https://research.google/pubs/the-ml-test-score-a-rubric-for-ml-production-readiness-and-technical-debt-reduction/), a 2017 checklist that treats tests and monitoring as a way to pay technical debt down. Our version of that habit is pretty simple. Every behavior we would be upset to lose deserves at least one test question, and [Golden Datasets](https://www.kirupa.com/ai_fundamentals/golden_datasets.htm) shows how we build them. ## Three Cards, One Wallet We now have three kinds of debt sitting side by side. A good way to picture them is as three credit cards in the same wallet: ![Three credit cards. Technical debt: the balance is shortcuts in code, like Pinwheel's four copies of 16, and the interest is slower changes. Context debt: the balance is stale prompts, instruction files, and docs, and the interest is confident wrong answers. Evaluation debt: the balance is behavior with no test, and the interest is hand-checking and fear of change.](https://www.kirupa.com/ai_fundamentals/images/three_kinds_of_debt_three_cards.png) Our three cards are tied to different parts of our product, but they all work the same way. We pay a little extra every time we touch the part a card is tied to, and we keep paying until somebody pays the balance down. What makes this worse with AI in the picture is that the cards feed each other. Here is how they did that on our three-week job: ![A loop of four steps. A stale AGENTS.md points at orders-v1. The coding agent copies that old pattern into four new files. No test notices, so the change ships. A customer finds the bug, and the rushed fix adds another shortcut, which brings us back to the start.](https://www.kirupa.com/ai_fundamentals/images/three_kinds_of_debt_feedback.png) Our coding agent reads whatever context we give it, and the agent copies whatever patterns it finds in our code. If the context is stale and the code has a shortcut in it, the agent will repeat both, very quickly. If there is no eval, nothing stops the result from shipping. Agents do not invent these debts, but they can run up the balance a lot faster than any of us could by hand. ## Paying It Down The first step is boring and important. We write all of our debt down in one place, all three kinds together. Next to each item, we note where the debt lives, the interest it charges, and what paying it off would take. Here is our list after the Rolling Pin job: | Card | What we owe | Interest we pay | Paying it off | |---|---|---|---| | Technical | The 4pm cutoff typed into four Pinwheel files | A day of hunting whenever the cutoff changes | One cutoff setting that all four files read | | Context | Bakery facts describe only our two shops | Wrong pickup answers for six shops | Facts for each shop, updated when a shop changes | | Context | `AGENTS.md` points at `orders-v1` | Agents wire new code to a dead service | Fix the file, and give it an owner and a last-checked date | | Evaluation | 16 of Biscuit's 22 behaviors have no test | Hand-checking chats after every prompt change | One test question per behavior, allergies first | So, which item do we pay first? The rule is the same one we would use for real credit cards: the highest interest goes first. In a product, the interest is highest on the parts we touch most often, so Wren estimated what each item costs her in a typical month: ![Bars showing the hours each debt costs Wren in a typical month, longest first: Biscuit's missing tests, 10 hours; stale bakery facts, 4 hours; the stale AGENTS.md, 3 hours; Pinwheel's four copies of 16, under 1 hour. A handwritten note points at the longest bar: pay this first!](https://www.kirupa.com/ai_fundamentals/images/three_kinds_of_debt_interest_ranking.png) Biscuit's prompt changes every week, so its missing tests cost us something every week. Pinwheel's cutoff changes about once a year, so those four copies of **16** can wait a little, even though they were the most annoying part of the job. Once the balances come down, a few habits keep them from creeping back up: - Every bug Biscuit ships becomes a new test question before the fix goes in. - Every context file gets an owner and a last-checked date. A change to the bakery, like a new shop or new hours, comes with a change to the files that describe the bakery. - When we take a shortcut on purpose, the shortcut goes on the list that same day, along with the interest we expect to pay. None of this needs a special tool. A shared doc with four columns works fine, as long as we actually look at it when we plan the week. ## Try It This Week Let's find one balance on each card in our own product: 1. Pick the part of your product that changed the most last month. 2. Write down one shortcut in its code, one prompt, instruction file, or doc about it that is out of date, and one behavior that nothing tests. 3. Next to each one, write its interest: what it costs every time someone touches that part. 4. Pay down the item with the highest interest before Friday, and put the other two on a list your team can see. ## Frequently Asked Questions **What Is Technical Debt?** Technical debt is a shortcut in code that saves time now and costs extra time every time we change that code later. Ward Cunningham introduced the metaphor in 1992: the shortcut is the loan, and the extra time we spend working around it is the interest. A little debt is fine as long as we pay it back. **What Is Context Debt?** Context debt is the gap between what our prompts, instruction files like AGENTS.md, docs, and search indexes say and what is true today. Agents and new teammates read that context with total trust, so stale context makes them confidently wrong. Giving each context file an owner and a last-checked date helps keep it current. **What Is Evaluation Debt?** Evaluation debt is behavior we depend on that nothing checks automatically. Its interest is the hand-checking we do after every change, plus the fear of upgrading a model or editing a prompt. Adding at least one test question for every behavior we’d be upset to lose pays it down. **Is Technical Debt Always Bad?** No. Like a loan, a little debt can speed things up, and Cunningham’s point was that it’s fine as long as it gets paid back promptly. The trouble starts when nobody writes the debt down, so the interest keeps growing until a small job takes weeks. ## Conclusion Ok! It is time to wrap things up. Our two-day job took three weeks because we were paying interest on three cards at once. Technical debt is the oldest card, the one Ward Cunningham named back in 1992: shortcuts in code that cost us a little extra every time we change that code. AI products add two more. Context debt is the stale prompts, instruction files, docs, and indexes that our agents read with total trust. Evaluation debt is the behavior we rely on that nothing checks. All three are fine to carry for a while, and all three get expensive when nobody writes them down. The fix is a bit unglamorous. We keep one list for all three kinds, note the interest each item charges, and pay down the highest interest first. Pinwheel's four copies of **16** are one setting now, by the way. That change took Wren about 40 minutes, which is a lot less time than she spent hunting for them the first time...and nobody will have to hunt for them again. Before you go, here are a few things you can do: 1. Test your knowledge by taking the quiz below. 2. Read the next article in the series, [Normal Accidents](https://www.kirupa.com/ai_fundamentals/normal_accidents.htm), or check out some related content: - [Context Engineering](https://www.kirupa.com/ai_fundamentals/context_engineering.htm). Decide what goes into an agent’s context window on every turn. - [Golden Datasets](https://www.kirupa.com/ai_fundamentals/golden_datasets.htm). A fixed set of test cases with known-good expectations for every change. - [Regression Tests on Every Prompt Change](https://www.kirupa.com/ai_fundamentals/prompt_regression_tests.htm). Catch behavior that a small prompt edit quietly breaks. 3. Stuck on something, or curious about a detail we skipped? [Ask on the forums](https://forum.kirupa.com/), and we’ll help you out. ## Test your knowledge! [Take the Technical, Context, and Evaluation Debt Quiz](https://www.kirupa.com/quizzes/three_kinds_of_debt.htm). Practice with 6 multiple-choice questions and an explanation after every answer.