This is the written version of my talk at AI Grunn 2026. It builds on LLM is not chat, your LLM shouldn’t be in production and running autoresearch.

Every project I work on right now is somehow tied to an LLM. Every single one. It’s on every company’s website, there’s a little chat bubble in the corner, and so on. But the question that kept bugging me for a long time is, how do you actually design an application where one of the components is an LLM? What do you give it, what do you keep for yourself, and how do you know it did its job? It’s a kind of component that didn’t exist before, and all of us are basically figuring this out at the same time, right now.

I’ve been building LLM apps for about five years now, since the GPT-3 days, so I got quite a lot of experience with it. And also quite a lot of frustration. At some point I went through what I can only call a phase of AI psychosis. Every time I built something with an LLM, I would compare it to ChatGPT, or to Cursor, and mine was just never as good. What is it that they do that I’m not doing? Is there some secret prompt? Some framework I haven’t tried? So I read every guide and every blog post I could find, trying to reverse engineer what I was missing. This is where that took me.

the naive build

Let’s do it with an example. It’s based on real projects I worked on, with the details changed.

An accounting firm comes to us and says, we want an AI tax assistant. The business owners they do the books for should be able to chat with it, upload their receipts and invoices, and ask things like, should I deduct this? Can I claim the VAT on this dinner? Sounds reasonable. Sounds like exactly the kind of thing LLMs are made for.

So how would you build this? I think most of us would do something like this, and I definitely did. First you get all the tax law. You scrape it, all the regulations, the guidance documents, everything. And it’s a lot. The Dutch income tax law alone is about a hundred thousand words, the VAT law is another forty thousand, and then the EU VAT directive on top of that. And it keeps moving, the income tax law gets amended something like ten to fifteen times a year.

Anyway, you chunk it, you embed it, you put it in a vector database. Maybe you’re a bit fancy so you also do keyword search next to the embeddings, and you combine them with reciprocal rank fusion, because you read that somewhere and it sounded smart. Then on top of that you put an agent. It runs in a loop, it has tools, it can search the law, read the uploaded files, maybe do some calculations. And then you wrap it all in a chat interface, because, well, that’s what AI looks like.

And you make a demo. And the demo works great. You upload a receipt, you ask, can I deduct this, and it gives you a nice answer with a reference to the law. Everyone is happy.

where it breaks

And then it goes to real users, and of course something goes wrong.

Take that one receipt. A business dinner, a hundred and thirty euros. The system says, yes, business meals are 80 percent deductible, and you can reclaim the VAT, and it even cites the law. Except the 80 percent is the income tax answer. For VAT the answer is zero. Food and drink at a restaurant, you never get the VAT back. And the funny thing is, that rule sits in the same article that says VAT is deductible. Paragraph one says yes, paragraph five takes it back for restaurants. So if those two end up in different chunks, the retriever brings back the yes, the model reads the yes, and the business owner reclaims VAT they’re not allowed to.

And this is not just me building it badly. When the Washington Post tested the AI assistants of TurboTax and H&R Block in 2024, tax professionals judged more than half of TurboTax’s answers wrong, and H&R Block’s were wrong more than thirty percent of the time. These are companies whose whole business is taxes.

Okay, fine, you fix the retrieval. You try a sliding window for the chunks, so paragraph one and paragraph five end up together. You add a reranker on top. You filter by year, because now it’s also mixing up last year’s thresholds with this year’s. Your retriever just keeps growing. And now that rule works, but somewhere else some other answers got worse, and you don’t really know why. So you take a bigger model. That fixes some things, breaks some other things, and now it’s also slower and more expensive. So you set the temperature to zero, so at least it’s consistent.

So then you think, okay, I need to measure this properly. You add some evaluation platform, and now you have numbers. You have precision and you have recall. And honestly, if you’re like me, you have to google again which one is which, because the last time you really thought about it was at university. And even when you know which is which, you’re not sure what the number is actually measuring in this whole system.

Then you open Claude and ask it, can you fix this. Can you make it work. Can you fix this please. Maybe the agent just doesn’t have enough tools, so you give it access to everything. That also doesn’t really work.

And there’s a worse problem hiding underneath all of this. You’re not a tax expert. I’m definitely not. So when the system gives you an answer, you can’t even tell if it’s right. And you can’t write a better prompt either, because to write that prompt you’d need to know every rule and every exception yourself. So you’re stuck in three ways at once. You can’t diagnose it, you can’t fix it, and you can’t check it.

I’m pretty sure a lot of people had exactly this as their first real encounter with building on LLMs. I know I did, more than once.

two models, stacked

This pain is not new. It was written down already in 2015, way before any of this LLM hype, in Hidden Technical Debt in Machine Learning Systems by Sculley et al. Think about what we actually built. The retriever is a machine learning model, it ranks chunks by some similarity it learned. And on top of it we put another machine learning model, the LLM, which has to understand whatever the first one handed it. Two models stacked on each other, each one depending on the quirks of the other.

The paper has a name for this: CACE, changing anything changes everything. You tune the retriever, the LLM sees different text and behaves differently. You swap the LLM, it reads the same chunks differently. You can’t improve any one piece on its own.

So how do you get out of this? Not with a better retriever, and not with a bigger model. You have to step back and ask two much more boring questions. What are we actually trying to produce? And what do we actually need the LLM for?

start from the output

There’s an old book on problem solving, How To Solve It by George Polya, and the first question it asks about any problem is, what is the unknown? What are you actually trying to find?

So imagine the system is already built and working. The accountant at the firm opens it at the end of the quarter. What do they see? Not a chat. Nobody wants to have a conversation with a hundred and forty receipts. They want a table. One row per receipt, a yes or a no for every decision, and when it’s a no, the reason. And for the ones the system isn’t sure about, a flag that says a human should look at this one.

So the unknown was never a good paragraph of text. You can’t write that down. The unknown is a few decisions per receipt. Is this a valid invoice. Is it a business expense. Can I get the VAT back. How much can I deduct as a cost. And the business owner doesn’t need to chat either, they upload the receipt and get their row back, with the reason. The firm asked for a chatbot, but what they actually needed was an automation. I think that’s true for most of the “we want an AI agent” requests I get.

what the LLM is actually for

Now the second question. Why did we want an LLM here in the first place? Not because tax law needs some kind of intelligence. It’s because the data is unstructured. A crumpled photo of a receipt, a line item that just says “Kindle Paperwhite”. That’s the part that actually needed a language model.

And if you strip away the chat and the agents, an LLM really only does a few things. It can parse: take something messy and fill in a form. It can decide: answer a yes or no, or pick one out of a few options, with some confidence, which is also how you route. And it can explain: write a short piece of text. An agent is just these blocks running in a loop. Everything else is code.

So use them one at a time. For our receipt, the parse block reads the photo and fills in a handful of fields. Who is the supplier, what’s the total, is there an invoice number, is the buyer’s name on it, is it food and drink at a restaurant. And one thing that isn’t on the receipt at all: is the business owner a sole trader or a company. Remember the demo saying 80 percent? That’s only true for a sole trader. For a company it’s 73.5. No retriever was ever going to find that. It’s in the firm’s own records.

And then the rules. Not the whole tax law, just the handful of rules a receipt actually runs into. When you look at those, most of them are just if else statements. If it’s food and drink at a restaurant, no VAT back. If it’s over a hundred euros and there’s no full invoice, no VAT back. If it’s a sole trader, 80 percent, otherwise 73.5. And if it’s if else, then it’s code. And code I can read, and code I can test.

Dijkstra wrote an essay about how foolish it is to want to program in natural language, and says that instead of seeing formal symbols as a burden, we should see them as a privilege. I think that’s exactly it. When the rule is a prompt, it can be ignored, forgotten halfway through a long conversation, read differently by the next model. When it’s code, it just runs.

A small trick for the parse block, because it changed how I write these forms. When you force the LLM into a very rigid format, it will sometimes get the format wrong, and in a rigid system a wrong format means an error, and an error means pain. So I do kind of the opposite. I let the model write the date however it wants, the country however it wants, the VAT rate as “9 procent” if it feels like it. Then Pydantic validators on my side turn that into the strict thing my code needs: a real date, a country code, a decimal. The model gets to speak almost natural language, and the formal part happens in my code, where I can test it.

Some questions are genuinely fuzzy, though. Is a Kindle a business expense? There’s no clean rule for that. That’s where the decide block comes in. Not the big decision, just one small question with a confidence, and when the confidence is low, it goes to the accountant. And the reason under each no in the table is the explain block. The rule already decided. The LLM just turns that into one friendly sentence. It’s not deciding anything, it’s writing.

So look where the LLM is now. It reads the receipt, it answers a couple of fuzzy yes or no questions, and it writes the explanation. The blast radius of the LLM shrinks down to a few small boxes, and every one of them is small enough to check. Everything else is just normal code.

the architecture falls out

Now walk backwards from the table. Every cell is one decision. Every decision is either a rule or a small decide block. Every rule needs a few fields. Every field comes from the parse block. And that’s the whole architecture. Every box is small, and every box has one job.

Cyan is where the model does something, white is code. And every box can be checked on its own. Did it read the receipt right? Did it call this a business expense when the accountant said it wasn’t? Did the rule fire correctly?

Remember the three ways we were stuck. I can diagnose it now, because when a row is wrong I can see which box was wrong. I can fix it, because the rule is code and not a prompt. And I can check it, because every box is a decision with a right answer that I can write down, a thousand times, and score. Precision and recall finally mean something, because they’re about one box, not the whole system.

And for the right answers I don’t need to be the expert either. The firm has been doing this for years. Every receipt they ever processed, somebody decided whether the VAT was deductible. Those are my labels. Nobody collected them as training data, but that’s what they are. And that’s true for a lot of businesses. Any process that has to justify its decisions keeps a record of them.

letting the model write the rules

There’s one thing left. I wrote those few rules by hand. A real firm runs into hundreds of them, and I’m still not a tax expert. So where do all the rules come from?

There are two ways. The first one is almost boring. The law still exists, it’s written down. So you give a coding agent the law and ask it to turn it into rules. Not at runtime, once, offline, into code you can read. When the accountant spots a mistake, they flag it, you fix that one rule, and it stays fixed. Unlike a prompt, it won’t quietly come back next week. And every mistake they flag is also a new label, which brings me to the second way.

The firm has thousands of receipts they already decided. That’s inputs, and the right outputs. And when you have inputs, right outputs and a way to score, you can let a coding agent write the rules against them, and keep improving them on its own. Karpathy has a name for this loop, autoresearch.

You take a coding agent, Claude Code or whatever you like. Yes, the same Claude I was begging to fix things earlier. But this time you give it a very small box to play in, and a score. One file, rules.py. The input is fixed, a parsed receipt. The output is fixed, a decision. One command runs the whole eval and prints a number. Then you let it go. It writes some rules, runs the eval, looks at the receipts it got wrong, changes the rules, runs it again. Every run gets committed together with its score, so you can always go back. I usually leave it running for an evening.

And it’s not only if else. Where the language is fuzzy, say figuring out from a line item whether something is a business expense, it can write a few regexes, turn them into features, and train a small classical model on top, gradient boosting or whatever works best. You’re not training a big model, you’re not fine-tuning anything. The AI is just the one editing the code until the numbers go up. That’s how some of the model boxes slowly turn into code.

Of course, if you let it, it will learn to pass every single case. It overfits. So you do what you’d do in any ML project: hold out part of the labels that the agent never gets to see, and that’s the number you trust. And the nice thing about overfitting in code is that you can read it. If you open rules.py and see if receipt.supplier == "Restaurant Noord", you know exactly what happened.

What you get at the end is code. The rules run in milliseconds, with no API calls, and the accountant can read them. When the law changes on the first of January, you add a few labeled examples of the new rule and run it again.

so where does the LLM go?

If you put everything above on one line, it looks like this.

On the left, the agent decides and acts. That’s where we started, the tax assistant. Then retrieval and prompt tweaking, which is honestly where most of us spend our time, fixing chunks and adding rules to the prompt. Then the LLM decides which way to go and code does the rest. Then the LLM parses and answers a few small questions, and code makes the decision, that’s where our receipts ended up. And on the far right, the LLM doesn’t make the decision in production at all, it just wrote the rules, offline.

Every step to the right, you hand more of the decision to code. And what you get back for it is something you can score. It’s also cheaper. Every time the model reasons, it costs time, tokens and money. On the left, an agent loop takes seconds per receipt and burns thousands of tokens, for every receipt, every quarter. On the right, the rules run in milliseconds and cost nothing.

I’m not saying everything should be on the far right. Some things really are open ended. If a business owner wants advice on how to plan their taxes for next year, there aren’t a thousand right answers to write down, and an agent might be fine there. But it’s a question I ask every time now. Where on this line does my system sit, and can I move it one step to the right?

About the AI psychosis I started with, why ChatGPT and Cursor always felt so much better than anything I built. Honestly, I still don’t really have an answer. They just feel nice to use. And when it’s you using them, you find a way to make them work within whatever you need. But that’s a different thing from building a system that has to be right for someone else.

When people talk about putting LLMs in production, the word I hear the most is deterministic. So we set the temperature to zero. But even if that made it perfectly deterministic, it would still be unverifiable. It would just give you the same wrong answer every time. What you actually want is to be able to write down the right answer for a thousand cases, and check it.

So, what do you give the LLM, what do you keep, and how do you know it did its job? You give it the messy input and the small fuzzy questions. You keep the decision. And you know it did its job because you wrote down the right answer a thousand times, and checked.

To be clear, I’m not against AI agents. I use them every day, I used one to help me prepare this talk. I’m just saying that for what you’re trying to achieve, maybe you don’t need one.

So, do you really need an LLM in production? For reading the messy receipt, probably yes. For making the decision, probably not.

takeaways

  • Before you add an LLM, think about why you actually need it. Most of the time it’s because the input is messy, like a photo or some free text, so scope it to that.
  • Ask what the client wants to see at the end. A lot of the time it’s just a table with the answers.
  • Try to break the problem into small questions that have a right answer, so you can check each one.
  • Put the rules in code, so you can actually read them and test them.
  • If fixing one thing keeps breaking something else, things are probably too tangled together.
  • You probably already have the right answers somewhere, in what people decided before. Use that to check your system.
  • What you really want is to be able to check if it’s right, on a lot of examples.