<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Sara Zan</title><link>https://www.zansara.dev/</link><description>Recent content on Sara Zan</description><generator>Custom Script</generator><language>en</language><lastBuildDate>Tue, 27 Oct 2026 00:00:00 +0000</lastBuildDate><item><title>ODSC AI West - From RAG to AI Agent: A Step By Step Build</title><link>https://www.zansara.dev/talks/2026-10-27-odsc-west-from-rag-to-ai-agent/</link><pubDate>Tue, 27 Oct 2026 00:00:00 +0000</pubDate><guid>https://www.zansara.dev/talks/2026-10-27-odsc-west-from-rag-to-ai-agent/</guid><description>&lt;p&gt;&lt;a href="https://odsc.ai/speakers-portfolio/from-rag-pipeline-to-ai-agent-a-step-by-step-build/" target="_blank" rel="noopener noreferrer"&gt;Announcement&lt;/a&gt;, &lt;a href="https://colab.research.google.com/drive/1NDY8HT3xmPvMjy5gDJFL7alHPMtzzG8X" target="_blank" rel="noopener noreferrer"&gt;Colab Notebook&lt;/a&gt;, &lt;a href="https://drive.google.com/drive/folders/1omMboeYTz_lh7IYyjGsNAxxJYWdktGYQ?usp=drive_link" target="_blank" rel="noopener noreferrer"&gt;archive folder&lt;/a&gt;.&lt;/p&gt;
&lt;hr /&gt;
&lt;p&gt;At &lt;a href="https://odsc.ai/" target="_blank" rel="noopener noreferrer"&gt;ODSC AI West&lt;/a&gt; I show how you can take your RAG pipeline and, step by step, convert it into an AI agent. The talk is based on an earlier &lt;a href="https://www.zansara.dev/posts/2026-01-07-from-rag-to-ai-agent/"&gt;blog article&lt;/a&gt; and goes through &lt;a href="https://colab.research.google.com/drive/1NDY8HT3xmPvMjy5gDJFL7alHPMtzzG8X" target="_blank" rel="noopener noreferrer"&gt;this Colab notebook&lt;/a&gt; where in under an hour we build from scratch a chatbot, a RAG pipeline, and then we progressively upgrade it to an AI Agent. Every step of the way is hand-on and you can take the notebook and adapt it to your stack for a more realistic example.&lt;/p&gt;</description></item><item><title>Python Summit - Is Python the favorite language of LLMs?</title><link>https://www.zansara.dev/talks/2026-10-19-python-summit-is-python-the-favorite-language-of-llms/</link><pubDate>Mon, 19 Oct 2026 00:00:00 +0000</pubDate><guid>https://www.zansara.dev/talks/2026-10-19-python-summit-is-python-the-favorite-language-of-llms/</guid><description>&lt;p&gt;&lt;a href="https://pythonsummit.org/#agenda" target="_blank" rel="noopener noreferrer"&gt;Announcement&lt;/a&gt;, &lt;a href="https://docs.google.com/presentation/d/1guThJksc_Kangbtfsqr2OIYafaDSXgS6mBg2xeOVvag/edit?usp=sharing" target="_blank" rel="noopener noreferrer"&gt;slides&lt;/a&gt;, and &lt;a href="https://drive.google.com/file/d/1lBXTSokGDR2b97IrJrsJg67uhfwaOga-/view?usp=drive_link" target="_blank" rel="noopener noreferrer"&gt;recording&lt;/a&gt;. You can also find my writeup of the talk &lt;a href="/posts/2026-10-19-is-python-the-favorite-language-of-llms/"&gt;here&lt;/a&gt;. All resources can also be found in &lt;a href="https://drive.google.com/drive/folders/1SfpHzcIlFbOoScaW7iG-i7qZ2I4XRhn3?usp=sharing" target="_blank" rel="noopener noreferrer"&gt;my archive&lt;/a&gt;.&lt;/p&gt;
&lt;hr /&gt;
&lt;iframe src="https://drive.google.com/file/d/1lBXTSokGDR2b97IrJrsJg67uhfwaOga-/preview" width="800" height="500"&gt;&lt;/iframe&gt;
&lt;hr /&gt;
&lt;p&gt;At the &lt;a href="https://pythonsummit.org/" target="_blank" rel="noopener noreferrer"&gt;Python Summit&lt;/a&gt; I dug into a little known research area: LLM's biases for programming languages. Is it true that your LLM will choose Python no matter the task you give it, or that it's more proficient at coding in Python than in any other language? Should you be concerned about this issue, or is it just a harmless preference? And where did this "problem" come from in the first place?&lt;/p&gt;
&lt;p&gt;Turns out there is a decent amount of published research on this topic, and various benchmarks that track the current situation.&lt;/p&gt;</description></item><item><title>Is Python the favorite language of LLMs?</title><link>https://www.zansara.dev/posts/2026-10-19-is-python-the-favorite-language-of-llms/</link><pubDate>Mon, 19 Oct 2026 00:00:00 +0000</pubDate><guid>https://www.zansara.dev/posts/2026-10-19-is-python-the-favorite-language-of-llms/</guid><description>&lt;hr /&gt;
&lt;p&gt;&lt;em&gt;This a writeup of my talk at the &lt;a href="https://pythonsummit.org/" target="_blank" rel="noopener noreferrer"&gt;Python Summit&lt;/a&gt; on October 19th, 2026. See the talk recording &lt;a href="/talks/2026-10-19-python-summit-is-python-the-favorite-language-of-llms/"&gt;here&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;
&lt;hr /&gt;
&lt;p&gt;Do LLMs have preferences regarding programming languages? Why would they have any, and how would you notice it?&lt;/p&gt;
&lt;p&gt;Online, you might occasionally have come across the statement that LLMs are better with Python, or that they really prefer to use Python even when they shouldn't. Many of us are very skeptical about this: LLMs shouldn't have preferences regarding programming languages. Or do they?&lt;/p&gt;
&lt;p&gt;It turns out, this is a real research question, and some answers exist. In this post we will see what the research says about whether there is any preference from the LLM side regarding programming languages, what does that mean for your projects, and potentially for Python itself. Where might a bias like this be coming from? Was it just a thing of the past, or it's still a factor to keep in mind when starting a new project?&lt;/p&gt;
&lt;h2&gt;What does “favorite” mean?&lt;/h2&gt;
&lt;p&gt;I'm going to focus on two different interpretations of this term: &lt;strong&gt;preference&lt;/strong&gt; and &lt;strong&gt;performance&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;On one side, let's try to understand whether LLMs are choosing a specific programming language above others, especially when you don't specify one. If you're asking an LLM to solve a programming task and you don't tell it which language to use, which one will it pick? Will it be Bash, TypeScript, or Python?&lt;/p&gt;
&lt;p&gt;On the other hand, there is the question of performance. Are LLMs actually better at using Python than at using other languages? Could an LLM, given a programming task, have an easier time solving that task in Python versus another language? Or maybe do they write better idiomatic Python than idiomatic Rust? Is there any measurable difference between their capabilities with one language or another in terms of actual coding performance?&lt;/p&gt;
&lt;p&gt;We're going to see both. But first, I want to understand a little bit about the history of this entire issue.&lt;/p&gt;
&lt;h2&gt;Some history&lt;/h2&gt;
&lt;p&gt;The whole thing starts very early in the history of LLMs. Early models, like GPT-2 and GPT-3, were not trained to code at all. The idea of LLMs originally was to make them able to write text.&lt;/p&gt;
&lt;p&gt;However, the researchers studying the emergent capabilities of these LLMs figured out that some code was included in the training set and, even without specific training for coding, if you give an LLM the name and the docstring of a function, the LLM was actually able to fill up the body of the function with some (usually) correct code. By learning how to speak, the LLMs somehow also learned how to do some basic programming, which was super exciting at the time (around 2020-2021).&lt;/p&gt;
&lt;p&gt;&lt;img alt="" src="/posts/2026-10-19-is-python-the-favorite-language-of-llms/autocompleting-python-inv.png"  class="invertible" /&gt;&lt;/p&gt;
&lt;p&gt;&lt;em&gt;From "&lt;a href="https://arxiv.org/pdf/2107.03374" target="_blank" rel="noopener noreferrer"&gt;Evaluating Large Language Models Trained on Code&lt;/a&gt;", Chen et al., 2021&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;One of the first papers that described these capabilities &lt;strong&gt;evaluated the LLMs on Python coding&lt;/strong&gt;. We don't really know why the researchers picked Python. They just picked this language and decided to go with it. In the paper they don't tell us why, whether they considered any other language, or whether they tried anything else. They probably stumbled upon this capability and kept digging into it, choosing Python kind of as an accident. So the early focus of investigation into these capabilities was focused on Python for completely accidental reasons.&lt;/p&gt;
&lt;p&gt;Maybe the LLM was actually only able to write Python. Maybe the original researchers know about this, but we have no clue because this was just not part of the published paper. We are left wondering whether GPT-2 was able to do anything like this in any other language or not.&lt;/p&gt;
&lt;p&gt;But clearly the research started from the emerging capabilities of LLMs to write &lt;em&gt;Python&lt;/em&gt; specifically, which may have had an impact later on.&lt;/p&gt;
&lt;h2&gt;The preference gap&lt;/h2&gt;
&lt;p&gt;Now let's go back to our first question. Do LLMs pick Python more frequently than they would pick another language?&lt;/p&gt;
&lt;p&gt;It definitely seems like this is the case, at least until quite recently. In a study of 2024–2025 models (GPT-3.5 Turbo, GPT-4, etc), the authors found that, when left unspecified, the programming language of choice of all (at the time) modern LLM was Python.&lt;/p&gt;
&lt;p&gt;&lt;img alt="" src="/posts/2026-10-19-is-python-the-favorite-language-of-llms/preference-gap-1-inv.png"  class="invertible" /&gt;&lt;/p&gt;
&lt;p&gt;&lt;em&gt;From "&lt;a href="https://arxiv.org/pdf/2503.17181v4" target="_blank" rel="noopener noreferrer"&gt;A Study of LLMs’ Preferences for Libraries and Programming Languages&lt;/a&gt;", Twist et al., 2026&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;The results are quite impressive because the preference for Python is &lt;em&gt;stark&lt;/em&gt;. When not specified, more than 90% of the time, for all of the models in this list, it was Python. Even when this was probably not a good choice to make!&lt;/p&gt;
&lt;p&gt;In the paper, the researchers specify that in 58% of the projects where Python was clearly &lt;em&gt;not&lt;/em&gt; the right choice, the LLM would still pick Python for the implementation. And even if the LLM, when asked verbally “What would you choose for this project?” would pick another language, when actually tasked to implement it, it would still switch back to Python.&lt;/p&gt;
&lt;p&gt;Again, it is not exactly clear where this came from. The paper offers no explanation apart from a few clues, and the conclusion is that this is just something that emerged accidentally. The LLM simply may have an easier time understanding Python code, maybe saw more Python in the training set. We don't really know. What we know is that the preference was there, and it was very strong.&lt;/p&gt;
&lt;p&gt;To track the issue, the same authors recently made an update to their paper with a specific benchmark meant to measure this sort of programming language preference. They figured out that even for models as recent as GPT-5.4 or DeepSeek V4 Pro, even if the benchmark was designed to &lt;strong&gt;contain only problems for which Python was clearly not the right choice&lt;/strong&gt;, still, in 35% of the cases, the LLM just switched back to using Python for the implementation. Anything else would have fit better, but not Python.&lt;/p&gt;
&lt;p&gt;&lt;img alt="" src="/posts/2026-10-19-is-python-the-favorite-language-of-llms/preference-gap-2-inv.png"  class="invertible" /&gt;&lt;/p&gt;
&lt;p&gt;&lt;em&gt;From "&lt;a href="https://arxiv.org/pdf/2608.06041v1" target="_blank" rel="noopener noreferrer"&gt;LANGCHOICEBENCH: Measuring and Explaining Programming-Language Choice in LLMs&lt;/a&gt;", Twist et al., 2026&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;If the LLM would have no bias and would choose among all the languages available on their merits, this number should have been zero. However, a good third of the problems are still solved with Python!&lt;/p&gt;
&lt;p&gt;This clearly says that even though we don't know where this comes from, &lt;strong&gt;the preference is still there&lt;/strong&gt;, and it's still strong. We can wait for the next paper to see if the preference is still there with the even more recent models, or you can try to replicate their results yourself, but all clues point to the fact that this bias is definitely not a thing of the past.&lt;/p&gt;
&lt;h2&gt;The performance gap&lt;/h2&gt;
&lt;p&gt;But how about performance? Do LLMs actually perform better with Python over other programming languages?&lt;/p&gt;
&lt;p&gt;There are benchmarks out there that measure the difference in capabilities for solving programming problems in different languages. The &lt;strong&gt;Multi-LCB benchmark&lt;/strong&gt; for example specifically shows that most models not only prefer Python, but are also &lt;strong&gt;noticeably better at coding in Python&lt;/strong&gt; than in any other language.&lt;/p&gt;
&lt;p&gt;The benchmark is composed of language-agnostic problems that the LLM is asked to solve several times in different languages: the once in Python, once in Java, once in C++, and so on. Then the researchers measured the success rate per language.&lt;/p&gt;
&lt;p&gt;&lt;img alt="" src="/posts/2026-10-19-is-python-the-favorite-language-of-llms/performance-gap-inv.png"  class="invertible" /&gt;&lt;/p&gt;
&lt;p&gt;&lt;em&gt;From "&lt;a href="https://arxiv.org/pdf/2608.06041v1" target="_blank" rel="noopener noreferrer"&gt;Multi-LCB: Extending LiveCodeBench to Multiple Programming Languages&lt;/a&gt;", Ivanova et al., 2026&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;You can see that there is a significant, although not huge, higher success rate with Python.&lt;/p&gt;
&lt;p&gt;The researchers called this phenomenon &lt;strong&gt;“Python overfitting”&lt;/strong&gt; because it looks like the LLM is more capable of coding when it's writing Python than in other languages. It looks like the performance degrades significantly when you're using a language that the LLM, for some reason, seems to be less familiar or less proficient with. As if the LLM is overfitting around the syntax of Python or the way Python functions, and then tries to translate into other languages with varying success.&lt;/p&gt;
&lt;p&gt;However, an interesting caveat of this paper is that they noticed some possible &lt;strong&gt;test-data leakage&lt;/strong&gt;. This would mean that some of the test data maybe was included in the training of the LLMs that were tested, which would also clearly explain the advantage of the LLMs solving Python problems. However, taking the result at face value, we still see an advantage here.&lt;/p&gt;
&lt;p&gt;In this paper the authors tested recent open-source models only, for example GPT-OSS-120B, Qwen Thinking, and DeepSeek R1. We don't know if this performance advantage translates to closed-source models, especially to more cutting-edge ones.&lt;/p&gt;
&lt;h2&gt;Why does this happen?&lt;/h2&gt;
&lt;p&gt;Why do LLMs clearly show both a preference and a performance advantage when writing in Python?&lt;/p&gt;
&lt;p&gt;There is not a clear explanation. Most of these properties are sort of emergent, and they were never designed to be this way. The teams who built the LLMs clearly never wanted it to be better at Python than Rust. This preference is somehow emergent from some other characteristic, either of the language or of the training data.&lt;/p&gt;
&lt;p&gt;Let's see some hypothesis.&lt;/p&gt;
&lt;h3&gt;Training data and Python's syntax&lt;/h3&gt;
&lt;p&gt;One of the strongest suspects here is the &lt;strong&gt;training data&lt;/strong&gt;. Probably Python is just so overrepresented that LLMs learn better how to code in Python because they see so much more of it than anything else.&lt;/p&gt;
&lt;p&gt;Also, Python has the advantage of its &lt;strong&gt;syntax&lt;/strong&gt;. Python is very easy to parse for LLMs that are optimized for natural language. LLMs are designed to be able to read natural-language text, and Python really looks like one. If you think about Java or C++, they don't really look like English, while Python more or less does. It's possible that one of the advantages comes from the specific pseudocode-like nature of the language.&lt;/p&gt;
&lt;p&gt;Another plus is that it's relatively easy for Python code to be right if it looks right. There is a relatively &lt;strong&gt;low number of footguns&lt;/strong&gt;. If you think about C, it's much easier to write code look ok while still having very deep and complicated bugs. With Python, of course, it can happen as well, but it's less likely. It's designed to be a little bit more foolproof, which definitely helps the LLM learn to code in Python faster.&lt;/p&gt;
&lt;p&gt;For comparison let's think about &lt;strong&gt;Java&lt;/strong&gt;, which is often second in these preference and performance benchmarks. That makes sense because it's very popular, so plenty of it in the training set. It's also relatively easy to code with, so there aren't that many footguns. But if you think about the way you write it, the syntax is not as natural-language-like. It's more verbose and less natural-looking. The LLM probably has more difficulty writing it and parsing it than it has with Python.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;C and C++&lt;/strong&gt; have kind of the same problem. Again, very popular, with a lot of examples on the internet, but it's much more difficult to write correct code, and the syntax is also quite weird with respect to natural language.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Go&lt;/strong&gt; and other easy-to-write languages, for example Lua, Julia, or other languages like these, were simply not popular enough at the time when the training was happening.&lt;/p&gt;
&lt;p&gt;An interesting outlier, however, are &lt;strong&gt;JavaScript and TypeScript&lt;/strong&gt;. It should have scored a bit better: it's hugely popular, probably even more popular even than Java and C++. There should be an incredible amount of examples on the internet, and the syntax is not dramatically more complex than Java. Why does it usually score so poorly? It's not clear. It should have been at least on par, if not more popular, and therefore easier for the LLM to learn. Somehow this lack of proficiency is even less explainable than the Python preference.&lt;/p&gt;
&lt;h2&gt;Can the gap be closed?&lt;/h2&gt;
&lt;p&gt;Given that these are the potential explanations, can the gap between Python and the other languages be closed?&lt;/p&gt;
&lt;p&gt;It seems like the answer is &lt;strong&gt;yes&lt;/strong&gt;. Already in 2023 it was shown that if you train an LLM on a more balanced training set, the discrepancy kind of disappears.&lt;/p&gt;
&lt;p&gt;&lt;img alt="" src="/posts/2026-10-19-is-python-the-favorite-language-of-llms/balanced-training-inv.png"  class="invertible" /&gt;&lt;/p&gt;
&lt;p&gt;&lt;em&gt;From "&lt;a href="https://proceedings.mlr.press/v202/orlanski23a/orlanski23a.pdf" target="_blank" rel="noopener noreferrer"&gt;Measuring the Impact of Programming Language Distribution&lt;/a&gt;", Orlanski et al., 2023&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;In the paper detailing this result, the evaluation benchmark was run on an LLM that was trained on a &lt;strong&gt;balanced set&lt;/strong&gt; of programming material. Instead of taking a natural distribution from the internet, where clearly some languages are overrepresented, these researchers trained an LLM by removing most of the Java, Python, and C++ examples and adding many more examples of lower-frequency languages, like Rust, C#, Julia, or Haskell.&lt;/p&gt;
&lt;p&gt;They could clearly see that, by rebalancing the training set, the advantage that LLMs had with Java, Python, and C++ was decreasing sharply, while the fluency of the LLMs in smaller and more niche languages increased dramatically. You can see this specifically for &lt;strong&gt;Julia&lt;/strong&gt;, a niche programming language with a Python-like syntax. Just by adding a few more training samples, the performance in this language increased dramatically. Clearly, rebalancing datasets would help close the gap.&lt;/p&gt;
&lt;h2&gt;A look at the frontier&lt;/h2&gt;
&lt;p&gt;So, is the performance gap still there at all? We've seen that some of the models tested were pretty recent, but there are always more recent models we can look at. And maybe more modern, more advanced benchmarks that we can check out.&lt;/p&gt;
&lt;h3&gt;Cybersecurity&lt;/h3&gt;
&lt;p&gt;&lt;strong&gt;&lt;a href="https://cwe-bench.com/" target="_blank" rel="noopener noreferrer"&gt;CWE-Bench&lt;/a&gt;&lt;/strong&gt; is a benchmark focused on cybersecurity tasks which also provides programming language breakdowns. It's a live benchmark, so it's constantly updated with the very latest models that are available today.&lt;/p&gt;
&lt;p&gt;&lt;img alt="" src="/posts/2026-10-19-is-python-the-favorite-language-of-llms/cwe-bench-inv.png"  class="invertible" /&gt;&lt;/p&gt;
&lt;p&gt;&lt;em&gt;From &lt;a href="https://cwe-bench.com/" target="_blank" rel="noopener noreferrer"&gt;CWE-Bench&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;You can see that the picture is flipping already. Python is not the first language here: the first one now is C++, then there is Go, then Java, then JavaScript, and only in fifth position is Python.&lt;/p&gt;
&lt;p&gt;This kind of makes sense: Python is not the most important language for cybersecurity, and most of the cybersecurity capabilities of LLMs are in languages that are more low-level, like C and C++, or compiled languages. So this performance gap is no longer such a clear-cut difference as we've seen before: in some niches, and definitely at the very cutting edge of the models available today, the advantage is not stark anymore.&lt;/p&gt;
&lt;h3&gt;Bug rate&lt;/h3&gt;
&lt;p&gt;&lt;strong&gt;&lt;a href=""&gt;Cubic&lt;/a&gt;&lt;/strong&gt;, the PR review tool, also publishes bug-rate statistics by language for the models that generate the code it's reviewing. Let's look at the stats for two cutting edge models, GPT-6 Astra and Claude Opus 5.5.&lt;/p&gt;
&lt;p&gt;&lt;img alt="" src="/posts/2026-10-19-is-python-the-favorite-language-of-llms/bug-rate-inv.png"  class="invertible" /&gt;&lt;/p&gt;
&lt;p&gt;&lt;em&gt;From the Cubic bug rate stats of &lt;a href="https://www.cubic.dev/bugbench/models/gpt-6-astra" target="_blank" rel="noopener noreferrer"&gt;GPT 6 Astra&lt;/a&gt; and &lt;a href="https://www.cubic.dev/bugbench/models/claude-opus-5-5" target="_blank" rel="noopener noreferrer"&gt;Claude Opus 5.5&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;You can see that Python, interestingly, is in third position for both. The problem is that this is a benchmark where the &lt;strong&gt;lower score is better&lt;/strong&gt;. Having Python in third position, just below JavaScript, means that this is &lt;strong&gt;the third-worst&lt;/strong&gt; programming language, at least in terms of bug rate. Clearly it's not a good look for Python to be that high on this benchmark to begin with. It means that these newer models make a lot of mistakes with Python, more than they make, for example, with Go or Rust. &lt;/p&gt;
&lt;p&gt;This is another example of a benchmark where Python is not shining for models that are very modern. It seems like the difference is disappearing a bit.&lt;/p&gt;
&lt;h2&gt;Is the gap fully gone?&lt;/h2&gt;
&lt;p&gt;This is much harder to say, because the data is just not there yet.&lt;/p&gt;
&lt;p&gt;Most system cards simply &lt;strong&gt;don't publish coding performance statistics broken down by programming language&lt;/strong&gt;. They just show general programming ability on benchmarks that are usually made of a balanced set of programming languages. This means that is really hard to tell whether these numbers are pushed up by string Python abilities or whether this gap is just not there anymore.&lt;/p&gt;
&lt;p&gt;In general it seems that &lt;strong&gt;the gap is decreasing&lt;/strong&gt;, because it's not difficult now to find benchmarks where Python is not scoring great. But it's not necessarily a good idea to extrapolate general performance judgements on benchmarks like these, and there is simply not a lot of focused research on this specific question. To have our answer, we might just need to wait for some more research to be published.&lt;/p&gt;
&lt;p&gt;So, even today, it's always good to keep in mind that your LLM may be picking Python not exactly for its merits, but just because it really likes it.&lt;/p&gt;</description></item><item><title>19th PyData Lisbon Meetup - Special on AI Infrastructure</title><link>https://www.zansara.dev/talks/2026-09-22-19th-pydata-lisbon/</link><pubDate>Tue, 22 Sep 2026 00:00:00 +0000</pubDate><guid>https://www.zansara.dev/talks/2026-09-22-19th-pydata-lisbon/</guid><description>&lt;p&gt;&lt;a href="https://www.meetup.com/pydata-lisbon/events/316579913/" target="_blank" rel="noopener noreferrer"&gt;Announcement&lt;/a&gt;, &lt;a href="https://drive.google.com/drive/folders/1OrxwE3UjQet0-ge8Exz9oY6qmtEW8gvo?usp=drive_link" target="_blank" rel="noopener noreferrer"&gt;event pictures&lt;/a&gt;.&lt;/p&gt;
&lt;hr /&gt;
&lt;p&gt;The 19th PyData Lisbon Meetup (part of the 2026 &lt;a href="https://lisbonaiweek.com" target="_blank" rel="noopener noreferrer"&gt;Lisbon AI Week&lt;/a&gt;) was a special edition about AI infrastructure, with a panel titled "The LLM Stack: Inference, Accelerators, Open Models and Beyond". &lt;/p&gt;
&lt;p&gt;During the panel we touched several points about LLM inference infrastructure: we debunked some common misconceptions, discussed tradeoffs between pay-as-you-go hosted models, rented GPUs, all the way down to edge computing and distributed inference, we talked about the different decisions you may have to take depending on your industry's specific requirements, from small startups to highly regulated industries, weighted the pros and cons of model fine-tuning, but also talked about determinism in LLMs and how far you can reasonably bring it for real production use-cases.&lt;/p&gt;
&lt;p&gt;&lt;img alt="" src="/talks/2026-09-22-19th-pydata-lisbon/picture.jpeg" /&gt;&lt;/p&gt;</description></item><item><title>AMTA - AI and the Future of Low-Resource Languages</title><link>https://www.zansara.dev/talks/2026-08-19-amta-low-resource-languages/</link><pubDate>Wed, 19 Aug 2026 00:00:00 +0000</pubDate><guid>https://www.zansara.dev/talks/2026-08-19-amta-low-resource-languages/</guid><description>&lt;p&gt;&lt;a href="https://amtaweb.org/amta-2026/" target="_blank" rel="noopener noreferrer"&gt;Announcement&lt;/a&gt;, &lt;a href="https://colab.research.google.com/drive/1CxdDwmg7Q8ehYmKmoHmleKdaqPRu6aH4?usp=sharing" target="_blank" rel="noopener noreferrer"&gt;Colab&lt;/a&gt;.&lt;/p&gt;
&lt;hr /&gt;
&lt;p&gt;At &lt;a href="https://amtaweb.org/amta-2026/" target="_blank" rel="noopener noreferrer"&gt;AMTA 2026&lt;/a&gt; me and &lt;a href="https://www.linkedin.com/in/vera-senderowicz-guerra/" target="_blank" rel="noopener noreferrer"&gt;Vera Senderowicz Guerra&lt;/a&gt; gave an overview of the state of the art of LLM usage to translate English into a selection of languages, from low-frequency ones such as Yoruba, Basque and Quechua, to lower-frequency variants of popular languages, such as the regional Latina American dialects of Spanish.&lt;/p&gt;
&lt;p&gt;Each language and dialect has its own characteristics that brings different challenges to LLM translation pipelines. During the presentation we demoed a few approaches that can be adopted to try improving the fluency of the LLM of your choice in your target language, from raising the reasoning budget to translation reviews, full-blown finetunes, backtranslations, and glossary injection, highlighting the specific issue that each method addresses most effectively.&lt;/p&gt;
&lt;p&gt;All code is made available in Colab &lt;a href="https://colab.research.google.com/drive/1CxdDwmg7Q8ehYmKmoHmleKdaqPRu6aH4?usp=sharing" target="_blank" rel="noopener noreferrer"&gt;here&lt;/a&gt;, and can be run with a T4 GPU environment and an &lt;a href="https://openrouter.ai/" target="_blank" rel="noopener noreferrer"&gt;Openrouter&lt;/a&gt; API key.&lt;/p&gt;</description></item><item><title>A Sycophantic Model Can't Be AGI</title><link>https://www.zansara.dev/posts/2026-08-04-sycophancy-and-agi/</link><pubDate>Tue, 04 Aug 2026 00:00:00 +0000</pubDate><guid>https://www.zansara.dev/posts/2026-08-04-sycophancy-and-agi/</guid><description>&lt;hr /&gt;
&lt;p&gt;&lt;em&gt;This is a piece I wrote for The Byte, the &lt;a href="https://www.aicollective.com/" target="_blank" rel="noopener noreferrer"&gt;AI Collective&lt;/a&gt;'s Tuesday &lt;a href="https://newsletter.aicollective.com/" target="_blank" rel="noopener noreferrer"&gt;newsletter&lt;/a&gt;. You can read it &lt;a href="https://newsletter.aicollective.com/p/a-sycophantic-model-can-t-be-agi" target="_blank" rel="noopener noreferrer"&gt;here&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;
&lt;hr /&gt;
&lt;p&gt;There is no generally accepted definition of AGI, but most of us can agree that, in broad strokes, AGI is a label for any LLM that is smarter than most (or all) humans in most (or all) fields. Sycophancy, by contrast, is the tendency of models to agree with, flatter, or defer to users even when doing so requires abandoning correctness.[1][4]&lt;br /&gt;
In some cases, sycophancy is not a significant problem and may even be useful: flattery can help LLMs be more persuasive and, in some cases, make them easier to talk to and open up to.[9] A bit of sycophancy may be the right tool for achieving specific goals.&lt;/p&gt;
&lt;p&gt;What we see in today’s models, however, is not intentional behaviour but a symptom of a deeper problem, and it is one of the main roadblocks that may prevent us from reaching true AGI.&lt;/p&gt;
&lt;h2&gt;Reward Hacking&lt;/h2&gt;
&lt;p&gt;Sycophancy is not an inherent feature of large language models. During pre-training, LLMs learn to communicate in all registers without any particular tendency to be flattering. In fact, they are not good conversation partners at all and do not have much control over their own tone.&lt;/p&gt;
&lt;p&gt;During post-training, LLMs are taught how to hold a conversation, and that is when this behaviour first appears. Instead of becoming smarter, they start finding subtler and subtler ways to agree with whoever is scoring them rather than giving the correct answer. They learn to read the subtext of a question to anticipate the answer, extract hints and clues from its structure, guess what the user wants to hear, and respond accordingly.[1][2][5] But why would they learn to do all of that instead of learning how to answer correctly?&lt;/p&gt;
&lt;p&gt;This problem is not new to LLMs. In machine learning, it is called reward hacking.[3] LLMs, like all other deep-learning systems, learn from feedback:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;They receive some input, such as a question.&lt;/li&gt;
&lt;li&gt;They generate some output, such as an answer, clarification, or follow-up.&lt;/li&gt;
&lt;li&gt;The output is scored against the expected result, which was usually written by a human.&lt;/li&gt;
&lt;li&gt;The score, which describes the differences between the model’s response and the expected result, is then given back to the model to learn from.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The loop then continues until the difference between the model’s response and the expected response stops decreasing from one iteration to the next. This signals that the model has learned all it can from the feedback it is receiving.&lt;/p&gt;
&lt;p&gt;This process does not give the model any indication of what it should learn; rather, it assumes that the model should learn everything it possibly can. The problem is that some things are easier to learn than others. The model, whether it is a small neural network or a huge LLM, will naturally learn those simple things first. If the simpler rules have already enabled it to predict the output accurately enough, it will stop learning. For example: if you train it to spot something rare, like spelling mistakes in published books, the model may simply learn that replying “there are no typos in this text” is the easiest way to achieve 99% accuracy, and will not make any effort to actually try to spot the mistakes.[6]&lt;/p&gt;
&lt;p&gt;This problem, however simple it may seem, appears everywhere in machine learning, and it occurs in LLMs as well. In RLHF-style training (Reinforcement Learning from Human Feedback) the LLM goes through a training phase in which its answers are scored by a preference model. This is a simpler neural network trained to simulate human feedback and score responses based on correctness, fluency, politeness, confidence, clarity, and other qualities.[2] If the preference model is not sophisticated enough, or if the users who trained it were not experts in the relevant field, the feedback the LLM receives is not “Give truthful, useful, and calibrated answers,” but rather “Produce answers that your evaluator rates highly.”[1][3]&lt;/p&gt;
&lt;p&gt;If users or preference models reward agreement, confidence, politeness, reassurance, or deference over correctness, a model will learn that agreeing with the user is a high-reward strategy and will stick with it. This is how an LLM becomes sycophantic. Sycophancy is one behavioural manifestation of reward hacking in preference-trained LLMs.[1][3][5]&lt;/p&gt;
&lt;p&gt;&lt;img alt="" src="/posts/2026-08-04-sycophancy-and-agi/learning-from-feedback-inv.png"  class="invertible" /&gt;&lt;/p&gt;
&lt;p&gt;&lt;em&gt;How LLMs and other deep neural networks learn from feedback&lt;/em&gt;&lt;/p&gt;
&lt;h2&gt;The Cost of Feedback&lt;/h2&gt;
&lt;p&gt;Seen in this light, reward hacking in LLMs does not appear insurmountable. Surely better reward models can be built, allowing us to counter this misaligned behaviour effectively.&lt;/p&gt;
&lt;p&gt;In some areas, that is definitely the case. Reward models can be made strictly deterministic in fields such as mathematics, coding, physics, and chemistry. In these fields, an answer is either correct or incorrect, with very little room for error or interpretation. Feedback on these questions can be provided at scale and with high quality, and in some cases it is relatively inexpensive to obtain. The results speak for themselves: in these fields, LLMs are improving rapidly, becoming better with every generation and advancing beyond many human experts.[7]&lt;/p&gt;
&lt;p&gt;The problem lies in every other field. An LLM can certainly draft legal briefs, interpret complex clinical presentations, or evaluate research proposals against one another, but how can we score its outputs reliably?[8] While some answers are obviously incorrect, many answers may be correct but may also not be. Different human evaluators could provide completely different or even opposing assessments, and both may be correct in some respects and wrong in others. How is an LLM supposed to be scored in such cases?&lt;/p&gt;
&lt;p&gt;Here lies the crux of the problem: we cannot teach an LLM to be smarter than us if we cannot agree among ourselves on what “smarter” even looks or sounds like. What sounds brilliant to one person may sound foolish and incorrect to another, even when both have the same level of expertise and similarly deep knowledge of the field. LLMs are therefore learning to compromise. They learn to read between the lines of a question, infer how the user is likely to respond from the way the question is written, and become increasingly effective at second-guessing the user’s intentions and answering in the expected way. Lacking consistent and predictable feedback, LLMs resort to sycophancy in an attempt to meet their targets.[1][5]&lt;/p&gt;
&lt;p&gt;As you can imagine, this quickly becomes a cat-and-mouse game. As soon as this behaviour is identified, researchers usually try to improve their preference models by making them more likely to penalize flattery, and more rigorous. However, the inherently subjective nature of the topic may just force the LLM to improve its second-guessing abilities. An actual AGI that stated its answer confidently, as a human expert would, might not score as highly as an LLM that simply agrees with the tester. Consequently, that is not what the LLM eventually becomes at the end of training.[1][3]&lt;/p&gt;
&lt;p&gt;&lt;img alt="" src="/posts/2026-08-04-sycophancy-and-agi/preferences-graph-inv.png"  class="invertible" /&gt;&lt;/p&gt;
&lt;p&gt;&lt;em&gt;From Sharma, M., Tong, M., Korbak, T., et al. &lt;a href="[https://arxiv.org/abs/2310.13548]"&gt;“Towards Understanding Sycophancy in Language Models”&lt;/a&gt;, 2023. (Figure 5)&lt;/em&gt;&lt;/p&gt;
&lt;h2&gt;Loaded Questions&lt;/h2&gt;
&lt;p&gt;This behaviour appears particularly strongly when users are unaware of the sycophantic tendencies of LLMs and accidentally load their questions towards a specific answer, such as “Why is this true?”. LLMs, especially general-purpose ones such as GPT and Claude, will answer to a question like that by finding reasons to validate the user’s assumption rather than questioning the premise. They may struggle to do so even when explicitly asked.[1][4][7]&lt;/p&gt;
&lt;p&gt;Many of these problems can be addressed with lightweight guardrails, such as detailed system prompts that encourage the model to challenge assumptions actively, avoid flattering responses, answer rigorously, and so on.[5][7] However, developers who measure the impact of their AI systems based on the fluency and confidence of their answers rather than their actual correctness often overlook this issue. In some cases, this is completely acceptable – for example, for chatbots designed for sales or customer service. For more rigorous applications, however, it is essential to be aware of this trap and ensure that the LLM is clearly instructed not to behave this way. In many cases, it is also useful to teach users how to identify failures to follow these instructions (which are unavoidable given the current state of the art) and retry their requests with a different wording  to compare the responses.&lt;/p&gt;
&lt;h2&gt;The Future&lt;/h2&gt;
&lt;p&gt;Failing to acknowledge and address the problem of sycophancy in LLMs could become a major obstacle to improving LLM capabilities in fields where human feedback is expensive and unclear. It is becoming increasingly evident that preference-style reinforcement learning may be approaching its limits outside STEM.&lt;br /&gt;
LLMs may become as capable as human experts, but with the current state of the art, they cannot become any smarter—at least not yet. Until we find a scalable, inexpensive, and effective way around the bottleneck of human evaluation, we will continue to produce LLMs that are exceptionally good at second-guessing the answers users expect but not at producing answers rated at the same level as those of the best human experts.&lt;/p&gt;
&lt;p&gt;Progress in this field may involve using LLMs to improve themselves. Could a council of flagship LLMs provide unbiased feedback to the next generation of models if prompted correctly? Or would they simply transfer their tendency to flatter one another to the new model?&lt;/p&gt;
&lt;p&gt;We do not yet know, but watch for breakthroughs.&lt;/p&gt;
&lt;h2&gt;Sources&lt;/h2&gt;
&lt;p&gt;[1] Sharma, M., Tong, M., Korbak, T., et al. “Towards Understanding Sycophancy in Language Models.” 2023. &lt;a href="https://arxiv.org/abs/2310.13548" target="_blank" rel="noopener noreferrer"&gt;https://arxiv.org/abs/2310.13548&lt;/a&gt;&lt;br /&gt;
[2] Ouyang, L., Wu, J., Jiang, X., et al. “Training Language Models to Follow Instructions with Human Feedback.” Advances in Neural Information Processing Systems, 2022.&lt;a href="https://arxiv.org/abs/2203.02155" target="_blank" rel="noopener noreferrer"&gt;https://arxiv.org/abs/2203.02155&lt;/a&gt;&lt;br /&gt;
[3] Denison, C., MacDiarmid, M., Barez, F., et al. “Sycophancy to Subterfuge: Investigating Reward-Tampering in Large Language Models.” 2024. &lt;a href="https://arxiv.org/abs/2406.10162" target="_blank" rel="noopener noreferrer"&gt;https://arxiv.org/abs/2406.10162&lt;/a&gt;&lt;br /&gt;
[4] Fanous, A., Goldberg, J., Agarwal, A. A., et al. “SycEval: Evaluating LLM Sycophancy.” Proceedings of the AAAI/ACM Conference on AI, Ethics, and Society, 2025. &lt;a href="https://ojs.aaai.org/index.php/AIES/article/view/36598" target="_blank" rel="noopener noreferrer"&gt;https://ojs.aaai.org/index.php/AIES/article/view/36598&lt;/a&gt;&lt;br /&gt;
[5] OpenAI. “Expanding on What We Missed with Sycophancy.” 2025. &lt;a href="https://openai.com/index/expanding-on-sycophancy/" target="_blank" rel="noopener noreferrer"&gt;https://openai.com/index/expanding-on-sycophancy/&lt;/a&gt;&lt;br /&gt;
[6] Kalai, A. T., Nachum, O., Vempala, S. S., and Zhang, E. “Why Language Models Hallucinate.” 2025. &lt;a href="https://arxiv.org/abs/2509.04664" target="_blank" rel="noopener noreferrer"&gt;https://arxiv.org/abs/2509.04664&lt;/a&gt;&lt;br /&gt;
[7] Petrov, I., Dekoninck, J., and Vechev, M. “BrokenMath: A Benchmark for Sycophancy in Theorem Proving with LLMs.” 2025. &lt;a href="https://arxiv.org/abs/2510.04721" target="_blank" rel="noopener noreferrer"&gt;https://arxiv.org/abs/2510.04721&lt;/a&gt;&lt;br /&gt;
[8] Dahl, M., Magesh, V., Suzgun, M., and Ho, D. E. “Large Legal Fictions: Profiling Legal Hallucinations in Large Language Models.” Journal of Legal Analysis, 2024. &lt;a href="https://academic.oup.com/jla/article/16/1/64/7699227" target="_blank" rel="noopener noreferrer"&gt;https://academic.oup.com/jla/article/16/1/64/7699227&lt;/a&gt;&lt;br /&gt;
[9] Cheng, M., Lee, C., Khadpe, P., Yu, S., Han, D., and Jurafsky, D. “Sycophantic AI Decreases Prosocial Intentions and Promotes Dependence.” Science, 2026. &lt;a href="https://www.science.org/doi/10.1126/science.aec8352" target="_blank" rel="noopener noreferrer"&gt;https://www.science.org/doi/10.1126/science.aec8352&lt;/a&gt;&lt;/p&gt;</description></item><item><title>Reasoning makes translations worse</title><link>https://www.zansara.dev/posts/2026-07-05-reasoning-makes-translations-worse/</link><pubDate>Sun, 05 Jul 2026 00:00:00 +0000</pubDate><guid>https://www.zansara.dev/posts/2026-07-05-reasoning-makes-translations-worse/</guid><description>&lt;p&gt;LLM reasoning has a simple appeal: give the model more room to think, and the answer should improve. That intuition works well enough in domains like math, coding, and planning that it is tempting to apply it everywhere.&lt;/p&gt;
&lt;p&gt;Machine translation seems like an obvious candidate. Translation is not just word substitution: a good translator resolves ambiguity, preserves tone, chooses between literal and idiomatic phrasing, and revises awkward drafts. Surely a model that “reasons” before translating should do better.&lt;/p&gt;
&lt;p&gt;The recent evidence says that's not always the case.&lt;/p&gt;
&lt;h2&gt;Thinking damages the translation quality&lt;/h2&gt;
&lt;p&gt;The most evident proof of this effect comes from Rajaee et al., &lt;a href="https://arxiv.org/pdf/2602.14763" target="_blank" rel="noopener noreferrer"&gt;&lt;em&gt;Unlocking Reasoning Capability on Machine Translation in Large Language Models&lt;/em&gt;&lt;/a&gt;. They compare several reasoning-oriented LLMs on translation tasks with and without explicit reasoning.&lt;/p&gt;
&lt;p&gt;The result is counterintuitive: the models generally do &lt;strong&gt;better without reasoning&lt;/strong&gt;. In their WMT24++ evaluation, every tested reasoning model has a higher average quality score when reasoning is disabled. DeepSeek-R1 shows the most dramatic gap: &lt;strong&gt;78.7 without reasoning&lt;/strong&gt; versus &lt;strong&gt;74.9 with reasoning&lt;/strong&gt;. Command-A-Reasoning, Claude-4-Opus, and Gemini-2.5-Flash show the same direction, although with smaller gaps.&lt;/p&gt;
&lt;p&gt;&lt;img alt="" src="/posts/2026-07-05-reasoning-makes-translations-worse/reasoning-noreasoning-scores-inv.png"  class="invertible" /&gt;&lt;/p&gt;
&lt;p&gt;&lt;em&gt;Table 1 from Rajaee et al, showing the inverse gap between reasoning and non-reasoning translation quality.&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;This is a useful counterpoint to a common assumption about LLMs. Reasoning doesn't always improve outcomes. Reasoning should be seen as a behavior, and it can be badly matched to the task while being a perfect fit for another.&lt;/p&gt;
&lt;p&gt;But why reasoning is unfit for this task? The problem is that generic LLM don't reason like a translator would. The authors find that the reasoning traces are mostly linear: the model walks through the sentence, translates pieces in order, and rarely revisits earlier decisions or considers alternatives. That is not how difficult translation usually works. A translator may try one phrasing, reject it as too literal, adjust the tone, change the sentence structure, then re-check whether the meaning survived. The important part is the constant revision of past translation choices, something that the LLM doesn't ever seem to do while reasoning about a piece. Their reasoning process was not trained for translation, so it doesn't not apply well to it.&lt;/p&gt;
&lt;p&gt;&lt;img alt="" src="/posts/2026-07-05-reasoning-makes-translations-worse/reasoning-paths-inv.png"  class="invertible" /&gt;&lt;/p&gt;
&lt;p&gt;&lt;em&gt;Table 2 shows the number of reasoning paths taken, which is remarkably low in comparison to the process of a human translator.&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;The same paper also tests whether stronger models can donate better reasoning traces to weaker ones. This sounds plausible: let a strong model think, then let another model use that reasoning to translate. However, the results are still inconsistent: better reasoning traces do not reliably produce better translations.&lt;/p&gt;
&lt;p&gt;&lt;img alt="" src="/posts/2026-07-05-reasoning-makes-translations-worse/trace-donation-inv.png"  class="invertible" /&gt;&lt;/p&gt;
&lt;p&gt;&lt;em&gt;Figure 1 From Reajaee et al. shows the performance of open-weights models when their reasoning traces are generated and injected from other models. The dash-line represents the baseline performance of the receiving models, and the injecting models are presented at the top. This figure shows how the strength of the injecting model used to generate reasoning traces does not always correlate with final translation quality across different injecting and receiving models.&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;That failure suggests that the issue is not merely the quality of the reasoning text. The issue is the &lt;em&gt;shape&lt;/em&gt; of the reasoning process itself, regardless of the intelligence or size of the model in question.&lt;/p&gt;
&lt;h2&gt;The revision step&lt;/h2&gt;
&lt;p&gt;A second line of work points in the same direction from another angle. In &lt;a href="https://aclanthology.org/2025.emnlp-main.1031.pdf" target="_blank" rel="noopener noreferrer"&gt;&lt;em&gt;Please Translate Again&lt;/em&gt;&lt;/a&gt;, Wu et al. ask whether elaborate step-by-step translation prompts are really helping because of their human-like decomposition.&lt;/p&gt;
&lt;p&gt;Their answer is skeptical. Simple refinement (essentially just asking the model to translate again) can &lt;strong&gt;match or outperform more elaborate step-by-step prompting&lt;/strong&gt;, but it's highly inconsistent across models. That does not mean the richer prompt is useless, but it weakens the idea that explicit pre-translation reasoning is the key ingredient.&lt;/p&gt;
&lt;p&gt;&lt;img alt="" src="/posts/2026-07-05-reasoning-makes-translations-worse/step-by-step-or-translate-again-inv.png"  class="invertible" /&gt;&lt;/p&gt;
&lt;p&gt;This is an important distinction for LLM users in general. A multi-step prompt may work not because the model has produced a faithful mental plan, but because the prompt gives it another chance to revise. In translation, that second pass is often more valuable than the explanation around it.&lt;/p&gt;
&lt;p&gt;Li et al make a related point in their work on test-time scaling for reasoning models in translation. Giving models more reasoning budget does not reliably improve first-pass translation. In some cases, forcing a model to keep reasoning after it would naturally stop makes the output worse. But extra compute is more useful for &lt;strong&gt;post-editing&lt;/strong&gt;: give the model an existing translation to improve, and the token budget that would be otherwise wasted on aimless reasoning on the first draft can be used productively for review.&lt;/p&gt;
&lt;p&gt;Overall, it seems that LLM's translation quality is not helped by free-form thought, but by feedback loops: draft, inspect, revise.&lt;/p&gt;
&lt;h2&gt;Lesson learned&lt;/h2&gt;
&lt;p&gt;This lesson is not specific to machine translation.&lt;/p&gt;
&lt;p&gt;Many LLM workflows assume that adding chain-of-thought reasoning creates a better system. Translation is a useful counterexample because quality depends heavily on the final surface form and more intermediate text can introduce drift, overthinking, literalism, or unnecessary changes. A fluent final answer is much more important than a verbose internal explanation.&lt;/p&gt;
&lt;p&gt;This is especially important when applying LLMs to domains where assessing the quality of the final output is not cheap and would usually require a human. By letting the model review, or by structuring its thinking in a more explicit way to match human processes, the output quality should become much easier to interpret and trust, and therefore more valuable.&lt;/p&gt;</description></item><item><title>What's an agent harness?</title><link>https://www.zansara.dev/posts/2026-06-12-agent-harness/</link><pubDate>Fri, 12 Jun 2026 00:00:00 +0000</pubDate><guid>https://www.zansara.dev/posts/2026-06-12-agent-harness/</guid><description>&lt;hr /&gt;
&lt;p&gt;&lt;em&gt;This is episode 9 of a series of shorter blog posts answering questions I received during the course of my work. They discuss common misconceptions and doubts about various generative AI technologies. You can find the whole series here: &lt;a href="/series/practical-questions"&gt;Practical Questions&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;
&lt;hr /&gt;
&lt;p&gt;The term "agent harness", or even simply "harness", seemingly appeared out of nowhere at some point at the start of this year, and everybody immediately started using it as if it had always had an obvious and commonly understood definition. If this caught you off guard, you're not alone: the term has existed since before LLMs, but it was a rather niche AI research term that only went mainstream in early 2026.&lt;/p&gt;
&lt;h2&gt;Definition&lt;/h2&gt;
&lt;p&gt;In short, an agent harness is &lt;strong&gt;all the software scaffolding that sits around an LLM&lt;/strong&gt;. The harness is the software that manages how the LLM uses tools, remembers context, stays within its guardrails, etc. To use a simple metaphor, the LLM is the brain of the AI agent: it understands, reasons, makes decisions, etc. The harness is its body: it takes actions, receives feedback from the environment, etc. Without its harness, the LLM can talk about a solution and explain it, but cannot put it into practice. That part is the harness's task.&lt;/p&gt;
&lt;p&gt;In fact, the LLM and its harness have such orthogonal roles that they are not tied to each other: nearly any LLM can be used with any harness, depending on the end goal. Harnesses are LLM-agnostic and can work with any LLM, which makes it easier to upgrade the LLM without rebuilding the harness, and vice versa.&lt;/p&gt;
&lt;p&gt;&lt;img alt="" src="/posts/2026-06-12-agent-harness/agent-harness-inv.png"  class="invertible" /&gt;&lt;/p&gt;
&lt;p&gt;In more practical terms, the primary component of an agent harness is &lt;strong&gt;tools&lt;/strong&gt;. LLMs on their own are not able to run tools: they &lt;em&gt;request&lt;/em&gt; a tool execution from their harness, the harness executes the tool, whether directly or through an MCP, collects the outputs, then invokes the LLM again with the outputs of the tool. This machinery is one of the most basic forms of harness.&lt;/p&gt;
&lt;p&gt;Another example is &lt;strong&gt;long-term memory&lt;/strong&gt;. There are plenty of &lt;a href="/posts/2026-02-04-how-does-llm-memory-work/"&gt;implementations of memory&lt;/a&gt;, but none of them is a native capability of the LLM: they are all part of the harness, and must be implemented in the scaffolding around the model for the model to acquire this capability. For example, one simple form of memory is the "scratchpad" approach, where the LLM can take notes about what it should remember long-term. This scratchpad is external to the LLM, just like a notebook is external to your head: the LLM writes into its scratchpad using a tool, and the harness makes sure to register the edits, store its content, inject it into the chat history at every new chat, etc.&lt;/p&gt;
&lt;p&gt;Some forms of &lt;strong&gt;guardrails&lt;/strong&gt; are also implemented in the harness. One common and simple implementation of a guardrail is to make each prompt go through two LLMs instead of one: the first to actually answer the question, and the second to review the answer, to make sure it addresses the prompt without breaking any guardrails in the process. Again, this workflow is not native to any LLM: it must be implemented around the LLM call.&lt;/p&gt;
&lt;p&gt;In addition, the harness is the perfect place to introduce &lt;strong&gt;observability&lt;/strong&gt;: monitoring, logging, error handling, and other scaffolding that's essential for production-grade systems.&lt;/p&gt;
&lt;h2&gt;Why a term for this?&lt;/h2&gt;
&lt;p&gt;These sorts of scaffolds are not new. They've been around for a very long time: in fact, the term seems to come from 2020, long before LLMs, when researchers started to study the relationship that an AI system could develop with external software. However, the term definitely gained a ton of popularity and escaped the research domain some time at the end of 2025.&lt;/p&gt;
&lt;p&gt;Late 2025 was also the time when agentic coding started to really take off. Coincidence?&lt;/p&gt;
&lt;p&gt;It is now generally understood that coding agents require two parts to be effective: an excellent LLM that is able to invoke tools effectively, and an excellent harness that gives the LLM exactly what it needs to do its work, nothing more and nothing less. A state-of-the-art LLM in a poor harness will perform well below its potential, while a rather poor LLM placed in a great harness will punch above its weight. &lt;/p&gt;
&lt;p&gt;While agent harnesses are an essential part of every type of AI agent, they're usually called like this in the context of coding agents. For example, Claude Code is an agent harness, and Claude is its LLM. Cursor is a harness which can use several different LLMs under the hood. But OpenClaw is also a harness, which can also be powered by different LLMs.&lt;/p&gt;
&lt;h2&gt;In conclusion&lt;/h2&gt;
&lt;p&gt;There are two situations where it's important to understand the concept of harness:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;You use coding agents. Understanding the distinction between the LLM's own capabilities and the role of the surrounding harness is very useful to debug situations where the agent performs unexpectedly poorly. For example, the LLM has no idea whether it's running on Windows, Linux, or a Mac: the harness has to tell the LLM this, so the LLM can issue the correct CLI commands.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;You are building AI agents. In this case, it's essential to know what kind of features and failure modes are due to the harness and what kind are due to the model. It's also crucial to be able to evaluate the LLM and the harness components in isolation and as a complete system, keeping in mind how the two parts influence each other's abilities.&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Either way, as the word becomes more and more popular, it's now an essential term to keep in mind when reasoning about AI agents.&lt;/p&gt;</description></item><item><title>Reasoning effort defaults across the GPT-5.x family</title><link>https://www.zansara.dev/posts/2026-05-26-reasoning-effort-across-gpt-5.x/</link><pubDate>Tue, 26 May 2026 00:00:00 +0000</pubDate><guid>https://www.zansara.dev/posts/2026-05-26-reasoning-effort-across-gpt-5.x/</guid><description>&lt;p&gt;GPT-5.x models are &lt;a href="https://magazine.sebastianraschka.com/p/understanding-reasoning-llms" target="_blank" rel="noopener noreferrer"&gt;reasoning models&lt;/a&gt;, and as such, you can set the reasoning effort that they should make when addressing your prompts.&lt;/p&gt;
&lt;p&gt;Reasoning is a big part of what makes LLMs smarter or faster, and the reasoning effort is a huge lever to improve benchmark results and latency figures. However, unless you've been monitoring your LLM applications closely, you may not have found a reason to play too much with the reasoning effort, trusting that the default would be good enough for now.&lt;/p&gt;
&lt;p&gt;Unfortunately, for some of us this is not a safe assumption to make.&lt;/p&gt;
&lt;h2&gt;The default keeps changing&lt;/h2&gt;
&lt;p&gt;The problem is that OpenAI is &lt;strong&gt;not keeping the default stable&lt;/strong&gt;. Reasoning itself have been turned on and off a few times across gpt-5.x releases:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;GPT-5: &lt;code&gt;medium&lt;/code&gt; (&lt;a href="https://developers.openai.com/api/reference/java/resources/%24shared#(resource)%20%24shared%20%3E%20(model)%20reasoning_effort%20%3E%20(schema)" target="_blank" rel="noopener noreferrer"&gt;source&lt;/a&gt;)&lt;/li&gt;
&lt;li&gt;GPT-5.1: &lt;code&gt;none&lt;/code&gt; (&lt;a href="https://developers.openai.com/api/docs/models/gpt-5.1" target="_blank" rel="noopener noreferrer"&gt;source&lt;/a&gt;)&lt;/li&gt;
&lt;li&gt;GPT-5.2: &lt;code&gt;none&lt;/code&gt;(&lt;a href="https://developers.openai.com/api/docs/models/gpt-5.2" target="_blank" rel="noopener noreferrer"&gt;source&lt;/a&gt;)&lt;/li&gt;
&lt;li&gt;GPT-5.4: &lt;code&gt;none&lt;/code&gt; (&lt;a href="https://developers.openai.com/api/docs/models/gpt-5.4" target="_blank" rel="noopener noreferrer"&gt;source&lt;/a&gt;)&lt;/li&gt;
&lt;li&gt;GPT-5.5: &lt;code&gt;medium&lt;/code&gt; (&lt;a href="https://developers.openai.com/api/docs/models/gpt-5.5" target="_blank" rel="noopener noreferrer"&gt;source&lt;/a&gt;)&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;This means that, unless you manually set the reasoning effort, you lost reasoning when upgrading from GPT-5 to GPT-5.1, sacrificing some output quality for faster responses. On the opposite, when upgrading from GPT-5.4 to GPT-5.5, the opposite happened: you traded off latency for some additional intelligence. &lt;/p&gt;
&lt;p&gt;If you're building simple chatbots, this distinction may not matter at all; but if you're building voice applications and other apps that require low-latency responses, this upgrade might have thrown a wrench in your numbers unexpectedly. GPT-5.5 is not necessarily this slow: you can make it run as fast as its predecessor, and keep the improved intelligence, by setting back the reasoning to where you want it to be.&lt;/p&gt;
&lt;h2&gt;Picking the right reasoning effort&lt;/h2&gt;
&lt;p&gt;Choosing the right reasoning effort depends entirely on your preference for intelligence vs speed. This is what the official &lt;a href="https://developers.openai.com/api/docs/guides/reasoning" target="_blank" rel="noopener noreferrer"&gt;OpenAI guidelines&lt;/a&gt; report on the matter:&lt;/p&gt;
&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Reasoning effort&lt;/th&gt;
&lt;th&gt;Intended use&lt;/th&gt;
&lt;th&gt;Typical tradeoff&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;none&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Latency-critical tasks that do not benefit from reasoning or multi-step tool calls. Examples: voice, fast retrieval, classification.&lt;/td&gt;
&lt;td&gt;Fastest, lowest reasoning overhead, weaker for planning/tool-heavy work.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;minimal&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Fast responses on GPT-5 models that support it.&lt;/td&gt;
&lt;td&gt;Very low reasoning overhead; availability is model-dependent.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;low&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Efficient reasoning for tool use, planning, search, multi-step decisions, drafting, data analysis, execution-oriented coding, support/chat workflows.&lt;/td&gt;
&lt;td&gt;Modest latency/token increase. Often a safer floor than &lt;code&gt;none&lt;/code&gt;.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;medium&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;General default for quality/reliability, planning, judgement, agentic coding, research, spreadsheets/slides, longer delegated tasks.&lt;/td&gt;
&lt;td&gt;Balanced quality, latency, and cost. &lt;code&gt;gpt-5.5&lt;/code&gt; defaults to this.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;high&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Hard reasoning, complex debugging, deep planning, high-value agentic tasks.&lt;/td&gt;
&lt;td&gt;Better quality on difficult tasks, higher latency/cost.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;xhigh&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Deep research, long rollouts, challenging coding/security/code-review workflows where evals prove value.&lt;/td&gt;
&lt;td&gt;Highest latency/cost; should be justified by evals.&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;In many cases the reasoning effort should be raised, at the expense of latency, on very tough tasks that require thinking. Agentic coding is a typical example. For all other scenarios you can save money and reduce latency by keeping the reasoning effort low, and setting up an eval framework to check whether your benchmarks are still healthy.&lt;/p&gt;</description></item><item><title>The Economist's Impact 2nd AI Compute Summit - Smarter systems, leaner models: reducing compute costs without sacrificing quality</title><link>https://www.zansara.dev/talks/2026-05-19-ai-compute-summit/</link><pubDate>Tue, 19 May 2026 00:00:00 +0000</pubDate><guid>https://www.zansara.dev/talks/2026-05-19-ai-compute-summit/</guid><description>&lt;p&gt;&lt;a href="https://events.economist.com/ai-compute/programme/#day1+cat-10+smarter-systems-leaner-models-reducing-compute-costs-without-sacrificing-quality" target="_blank" rel="noopener noreferrer"&gt;Announcement&lt;/a&gt;, &lt;a href="https://docs.google.com/presentation/d/1v-tqJ-Pr32xQxwgWAZsERuivfc-BLWqwcmi1M2F0Ciw/edit?usp=sharing" target="_blank" rel="noopener noreferrer"&gt;slides&lt;/a&gt;.&lt;/p&gt;
&lt;hr /&gt;
&lt;p&gt;At &lt;a href="https://events.economist.com/ai-compute/programme/#day1+cat-10+smarter-systems-leaner-models-reducing-compute-costs-without-sacrificing-quality" target="_blank" rel="noopener noreferrer"&gt;The Economist's Impact 2nd AI Compute Summit&lt;/a&gt; the conversation revolved about AI's most pressing issues: scarcity. Be it power, hardware, cost, speed, or know-how, the explosion of LLM's applications is vacuuming up resources on all fronts.&lt;/p&gt;
&lt;p&gt;So how can companies get the most out of what they have? Is exponentially increasing spending necessary to keep up with the state of the art?&lt;/p&gt;
&lt;p&gt;In my talk I explored the art of building smarter systems with leaner models: how to use efficiently the resources you have while getting cutting-edge performance out of them. The talk is very practical and highlights four levels for optimization, from context engineering down to your silicon strategy, and defines clearly the steps to take to go from a simple, inefficient prototype to a scalable product.&lt;/p&gt;</description></item><item><title>Smarter Systems with Leaner Models</title><link>https://www.zansara.dev/posts/2026-05-18-smarter-systems-with-leaner-models/</link><pubDate>Mon, 18 May 2026 00:00:00 +0000</pubDate><guid>https://www.zansara.dev/posts/2026-05-18-smarter-systems-with-leaner-models/</guid><description>&lt;hr /&gt;
&lt;p&gt;&lt;em&gt;This post is a write-up of my talk at &lt;a href="https://events.economist.com/ai-compute/programme/#day1+cat-10+smarter-systems-leaner-models-reducing-compute-costs-without-sacrificing-quality" target="_blank" rel="noopener noreferrer"&gt;The Economist's Impact 2nd AI Compute Summit&lt;/a&gt;. You can find the slides &lt;a href="/talks/2026-05-19-ai-compute-summit"&gt;here&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;
&lt;hr /&gt;
&lt;p&gt;LLMs keep getting smarter, month by month. But they also get bigger, more hardware- and resource-intensive, and more difficult to run efficiently, and even if token costs keep getting slashed, the AI bills of most companies just go up.&lt;/p&gt;
&lt;p&gt;Is it still possible to build state-of-the-art AI applications while keeping costs under control?&lt;/p&gt;
&lt;p&gt;Let's have a closer look at what's happening here, and dive deeper into a few approaches to limit your spending without affecting the performance of your AI applications.&lt;/p&gt;
&lt;h2&gt;The fundamental problem&lt;/h2&gt;
&lt;p&gt;AI economics have moved past the simple question of whether a model is "big enough." The more useful question is whether each workflow is buying the right amount of intelligence, context, latency, and reliability for the job. In other words: the relevant unit is no longer raw model size. It is &lt;strong&gt;cost per quality outcome&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;That distinction is becoming essential, because the two headline trends in AI economics now point in opposite directions. On one side, there's a famous figure: the Stanford AI Index reports that the inference cost for a system performing at GPT-3.5 level dropped more than &lt;strong&gt;280-fold&lt;/strong&gt; between November 2022 and October 2024.&lt;sup id="fnref:stanford-2025"&gt;&lt;a class="footnote-ref" href="#fn:stanford-2025"&gt;1&lt;/a&gt;&lt;/sup&gt; And while GPT-3.5 may seem a thing of the past, Gartner also forecasts that by 2030 the price of a 1T-sized model (what most flagship LLMs are estimated at) will fall by more than 90%&lt;sup id="fnref:gartner-2030"&gt;&lt;a class="footnote-ref" href="#fn:gartner-2030"&gt;4&lt;/a&gt;&lt;/sup&gt;. On the other, Gartner forecasts worldwide GenAI spending of roughly $644 billion in 2025, up 76.4% from 2024&lt;sup id="fnref:gartner-genai-spend-2025"&gt;&lt;a class="footnote-ref" href="#fn:gartner-genai-spend-2025"&gt;3&lt;/a&gt;&lt;/sup&gt;, and Stanford also reports corporate AI investment of $252.3 billion in 2024, with private investment up 44.5%.&lt;sup id="fnref:stanford-2025-economy"&gt;&lt;a class="footnote-ref" href="#fn:stanford-2025-economy"&gt;2&lt;/a&gt;&lt;/sup&gt; The lesson here is that unit costs can fall while total usage expands even faster.&lt;/p&gt;
&lt;p&gt;That's only natural, once we zoom out a little: increased intelligence unlocks use cases that were not possible with earlier models, therefore increasing usage. GPT-3.5 could not be used for agentic coding; GPT-5.5 can do most of the coding that software engineers used to do just last year.&lt;/p&gt;
&lt;p&gt;This doesn't mean that we should let costs and resource utilization go out of control. A little architecture discipline and governance can keep broader deployment from outrunning token-price deflation.&lt;/p&gt;
&lt;h2&gt;AI overspending is a system design issue&lt;/h2&gt;
&lt;p&gt;Right now, overwhelmed by hype and FOMO, a lot of developer teams simply default to a set of common, safe assumptions, that are sure to work with all LLMs. That was understandable while teams were still learning what generative AI could do, but it is increasingly hard to justify at scale. The lack of understanding of the capabilities and requirements of modern LLMs is one of the key drivers of overspending on AI workflows.&lt;/p&gt;
&lt;p&gt;Spotting them is not always easy, but some are much easier to address than others. My recommendation is to look for them in this order:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;Context Engineering&lt;/strong&gt;: are you sending too many tokens to your LLM, when half or less would do?&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Right-Sizing&lt;/strong&gt;: are you using the smallest LLM that can carry out your specific workflow as well as a flagship model? &lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Inference Engineering&lt;/strong&gt;: are you getting the most out of your hardware, or at least as much as a commercial provider would?&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Silicon Strategy&lt;/strong&gt;: are you really at a point where GPUs are not enough for your use case?&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Let's unpack them.&lt;/p&gt;
&lt;h2&gt;1. Context Engineering&lt;/h2&gt;
&lt;p&gt;Anthropic defines context engineering as the work of curating and maintaining the optimal set of tokens available to the model across system instructions, tools, external data, message history, and other context state.&lt;sup id="fnref:anthropic-context-2025"&gt;&lt;a class="footnote-ref" href="#fn:anthropic-context-2025"&gt;5&lt;/a&gt;&lt;/sup&gt;&lt;/p&gt;
&lt;p&gt;This is because no input is free when it comes to an LLM. &lt;/p&gt;
&lt;p&gt;This is often underestimated by AI builders. Every additional instruction and example, every additional corner case, every new document, image, or tool added to the LLM context raises the cost of &lt;strong&gt;each&lt;/strong&gt; of the prompts and responses of your AI. When the LLM context is stuffed with thousands of PDFs, even a three-question answer will cause the LLM to reread everything, costing you several dollars, if not tens of dollars, for each back-and-forth.&lt;/p&gt;
&lt;p&gt;Unnecessary input is not only damaging your wallet. It also adds latency and cost, and dilutes the model's attention. In short, this means: try to identify the &lt;strong&gt;shortest context that preserves answer quality&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;This is where retrieval-augmented generation, prompt caching, and compression come in. &lt;/p&gt;
&lt;p&gt;&lt;strong&gt;RAG&lt;/strong&gt; is often essential to lead the LLM to the answer without dumping millions of tokens at it. Microsoft describes token constraints as a core RAG challenge: RAG pipelines should return concise, highly relevant chunks rather than exhaustive document dumps.&lt;sup id="fnref:ms-rag-2026"&gt;&lt;a class="footnote-ref" href="#fn:ms-rag-2026"&gt;7&lt;/a&gt;&lt;/sup&gt; &lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Caching&lt;/strong&gt; can also help noticeably. Anthropic's prompt-caching documentation positions caching as a way to reduce processing time and cost for repetitive prefixes, with cache-read tokens priced at 0.1x base input tokens in the cited Claude pricing table.&lt;sup id="fnref:claude-prompt-caching-docs"&gt;&lt;a class="footnote-ref" href="#fn:claude-prompt-caching-docs"&gt;6&lt;/a&gt;&lt;/sup&gt;&lt;/p&gt;
&lt;p&gt;Applications where there are lengthy back-and-forth interactions with users, such as agentic coding, also benefit from &lt;strong&gt;chat history compression&lt;/strong&gt;, where older conversation turns, RAG snippets, tool outputs, etc., are summarized instead of stored verbatim to occupy less space in the context window.&lt;/p&gt;
&lt;p&gt;To leverage these context engineering techniques, every major AI workflow should have a context budget. Track input tokens, output tokens, cached tokens, retrieval hit rate, cache hit rate, against output quality. If a customer-service workflow needs a policy excerpt and the last three turns, do not send the whole knowledge base and the entire conversation every time.&lt;/p&gt;
&lt;h2&gt;2. Right-sizing&lt;/h2&gt;
&lt;p&gt;Right-sizing does not mean simply choosing the smallest model. It means choosing the cheapest model that meets the workflow's service-level agreement for quality, latency, risk, and trust. &lt;/p&gt;
&lt;p&gt;Flagship models such as GPT-5.5, Claude Opus 4.7, etc., are not always the right answer for your use case. They are increasingly benchmarked against problems that are not within the realm of what most businesses use them for, such as PhD-level math, complex algorithmic challenges, advanced physics, and scientific discovery, rather than simple question answering against a company's knowledge base, chatting in real time with a person on the phone, or planning a business trip. There are other, leaner models, much better suited for such tasks.&lt;/p&gt;
&lt;p&gt;In fact, choosing a smaller model is not only a cost-saving technique. Smaller models occasionally display better stats at crucial skills, such as lower hallucination rates, than flagships.&lt;sup id="fnref:vectara-hallucination-blog"&gt;&lt;a class="footnote-ref" href="#fn:vectara-hallucination-blog"&gt;17&lt;/a&gt;&lt;/sup&gt;&lt;sup id="fnref:vectara-hallucination-github"&gt;&lt;a class="footnote-ref" href="#fn:vectara-hallucination-github"&gt;18&lt;/a&gt;&lt;/sup&gt; This is because flagships, being trained for the highest intelligence, tend to guess and infer from the data they have available, while smaller models are trained to admit ignorance. This makes them &lt;em&gt;better&lt;/em&gt; suited for many industry applications while costing 5 to 10 times less than their smarter counterparts.&lt;sup id="fnref:openai-pricing-2026"&gt;&lt;a class="footnote-ref" href="#fn:openai-pricing-2026"&gt;8&lt;/a&gt;&lt;/sup&gt;&lt;sup id="fnref:google-pricing-2026"&gt;&lt;a class="footnote-ref" href="#fn:google-pricing-2026"&gt;9&lt;/a&gt;&lt;/sup&gt;&lt;sup id="fnref:anthropic-pricing-2026"&gt;&lt;a class="footnote-ref" href="#fn:anthropic-pricing-2026"&gt;10&lt;/a&gt;&lt;/sup&gt;&lt;/p&gt;
&lt;p&gt;&lt;img alt="Right-sizing economics: list-price token cost compared with Vectara hallucination rates." src="/posts/2026-05-18-smarter-systems-with-leaner-models/right-sizing-inv.png"  class="invertible" /&gt;&lt;/p&gt;
&lt;p&gt;&lt;em&gt;A comparison of the cost for a million tokens versus the hallucination rates of three popular flagship LLMs and their smaller counterparts.&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;That does not prove a small model is better for every workflow. It proves the opposite of the old default: you cannot infer the right model from size alone.&lt;/p&gt;
&lt;p&gt;The research trend supports this. For example, Microsoft Research reports that fine-tuned small language models can act as enterprise search relevance labelers with human-judgment agreement on par with or better than a teacher LLM, while improving throughput by 17x and cost-effectiveness by 19x in their experiment.&lt;sup id="fnref:ms-slm-labelers-2026"&gt;&lt;a class="footnote-ref" href="#fn:ms-slm-labelers-2026"&gt;11&lt;/a&gt;&lt;/sup&gt;&lt;/p&gt;
&lt;p&gt;To right-size your applications, you should benchmark one or two smaller candidates against your own business KPIs. Do not trust generic leaderboards: measure against your own, real usage patterns. Check containment, false positives, deflection quality, escalation rate, p95 latency, cost per successful task, customer satisfaction, and any other metric that might matter for your use case.&lt;/p&gt;
&lt;h3&gt;An example: flagships as managers of smaller workers&lt;/h3&gt;
&lt;p&gt;Routing and cascading can turn a rigid model selection choice into a more flexible, dynamic architecture that self-selects the best model for each task. &lt;/p&gt;
&lt;p&gt;A router (which may be an LLM as well) sends easy or known intents to cheap specialists, escalates uncertain work to stronger models, and reserves frontier models or humans for high-stakes cases. Research on routing and cascading shows that model-selection strategies can improve the cost-performance trade-off by choosing a single model per query or sequentially escalating until a satisfactory answer is found.&lt;sup id="fnref:routing-cascading-2024"&gt;&lt;a class="footnote-ref" href="#fn:routing-cascading-2024"&gt;12&lt;/a&gt;&lt;/sup&gt;&lt;/p&gt;
&lt;p&gt;The question is therefore not "AI or humans?" It is: &lt;strong&gt;What escalation tree gives the best unit economics without damaging trust?&lt;/strong&gt; A good routing system should include explicit thresholds for uncertainty, regulatory sensitivity, customer emotion, financial impact, and human override. The router itself should be measured as a product: containment is not success if escalations arrive too late.&lt;/p&gt;
&lt;h2&gt;3. Inference engineering&lt;/h2&gt;
&lt;p&gt;Once context and routing are under control, the next savings come from inference engineering. This is an active research area that needs to be followed closely if competition is a threat, and it requires a non-negligible level of dedication to be done right. While most techniques are now available to everyone with limited effort, whoever manages to implement the latest, most complex optimizations will end up having an edge in terms of either cost or latency.&lt;/p&gt;
&lt;p&gt;When talking about inference engineering, it is always worth framing it as a build-or-buy decision. Is it better to invest in an inference stack, with dedicated hardware, a dedicated team, a dedicated budget, etc., or to buy compute from a commercial provider such as OpenRouter, Nebius, Fireworks, etc.? The choice is not always trivial and may be influenced by other factors, such as data protection constraints and governance rules. &lt;/p&gt;
&lt;p&gt;For some of us, keeping inference in-house is not negotiable, and therefore the realm of inference engineering is highly relevant. In these cases, start from the most basic optimizations such as prompt caching and batching, then move up the complexity scale with cache and model quantization, up to cutting edge techniques such as speculative decoding and more, keeping a constant eye on the state of the art as it progresses.&lt;/p&gt;
&lt;p&gt;&lt;img alt="Inference engineering quadrant: quick wins first, strategic bets second." src="/posts/2026-05-18-smarter-systems-with-leaner-models/inference-inv.png"  class="invertible" /&gt;&lt;/p&gt;
&lt;p&gt;&lt;em&gt;A simplified map of some inference optimization techniques that can help your organization get the most out of hardware, classified by their complexity versus their impact.&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;In short, provider choice, serving stack, and model choice are intertwined. The same open model can feel very different across inference providers and stacks because the serving path differs. That is why mature AI companies benchmark latency, cost, and quality together on different stacks before settling on an inference strategy.&lt;/p&gt;
&lt;h2&gt;4. Silicon Strategy&lt;/h2&gt;
&lt;p&gt;More GPUs will only bring you so far, and the industry is actively looking for alternatives. Specialized inference hardware is still an immature but hot research area: new chips could change the economics of AI if they manage to move from prototype to production, especially for predictable workloads, but evidence quality varies widely. Some numbers are vendor-reported, some come from early demonstrations, and many compare different models, sequence lengths, or serving configurations.&lt;/p&gt;
&lt;p&gt;&lt;img alt="Silicon throughput landscape using mixed vendor and benchmark sources." src="/posts/2026-05-18-smarter-systems-with-leaner-models/silicon-inv.png"  class="invertible" /&gt;&lt;/p&gt;
&lt;p&gt;&lt;em&gt;A simplified comparison of a crucial claim for custom LLM chips: tokens per second on selected LLMs (usually Llama models).&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;Taalas positions its approach as turning models into custom silicon and claims that its "Hardcore Models" are 1000x more efficient than software counterparts.&lt;sup id="fnref:taalas-home"&gt;&lt;a class="footnote-ref" href="#fn:taalas-home"&gt;13&lt;/a&gt;&lt;/sup&gt; Its HC1 product page says the demonstrator runs Llama 3.1 8B and delivers 17k tokens per second per user, while also making clear that the comparison chart combines Taalas measurements with NVIDIA baseline and Artificial Analysis sources.&lt;sup id="fnref:taalas-products"&gt;&lt;a class="footnote-ref" href="#fn:taalas-products"&gt;14&lt;/a&gt;&lt;/sup&gt; Forbes/Cambrian-AI coverage amplified the HC1 performance narrative, but this remains a case where procurement teams should treat claims as directional until they are independently reproduced on their own workloads.&lt;sup id="fnref:forbes-taalas-2026"&gt;&lt;a class="footnote-ref" href="#fn:forbes-taalas-2026"&gt;15&lt;/a&gt;&lt;/sup&gt;&lt;/p&gt;
&lt;p&gt;Cerebras provides a more concrete example of high-throughput inference at large scale: it reported Llama 3.1 405B running at 969 output tokens per second on Cerebras Inference, with 240 ms time to first token, in a result it says was measured by Artificial Analysis.&lt;sup id="fnref:cerebras-405b-2025"&gt;&lt;a class="footnote-ref" href="#fn:cerebras-405b-2025"&gt;16&lt;/a&gt;&lt;/sup&gt; Etched's Sohu is another example of the specialization trade-off: The Register reported Etched's claim of 500,000 tokens per second for an eight-chip Sohu server running Llama 70B, while also noting that the chip had not taped out at the time of that report.&lt;sup id="fnref:etched-register"&gt;&lt;a class="footnote-ref" href="#fn:etched-register"&gt;19&lt;/a&gt;&lt;/sup&gt;&lt;/p&gt;
&lt;p&gt;This is why specialized silicon is still a rather hypothetical concern for most organizations. First, capture context, routing, and serving savings. Then use silicon options as negotiation leverage and roadmap planning. &lt;/p&gt;
&lt;h2&gt;Prototype fast, ship lean&lt;/h2&gt;
&lt;p&gt;The winning pattern is two-speed. Use frontier models for discovery, then industrialize with smaller, routed, cached, and optimized systems.&lt;/p&gt;
&lt;p&gt;In the &lt;strong&gt;exploratory&lt;/strong&gt; stage, use frontier or generalist models to learn what the product should do. This de-risks interaction design, customer value, and task fit quickly. In the &lt;strong&gt;refinement&lt;/strong&gt; stage, freeze the task taxonomy, right-size models, enforce context budgets, and deploy routing and caching. In the &lt;strong&gt;scale&lt;/strong&gt; stage, reassess your inference options now that all other variables are under control and overall cost is more predictable. Evaluate specialized hardware only when the economics justify it.&lt;/p&gt;
&lt;h2&gt;Where to start?&lt;/h2&gt;
&lt;p&gt;Most organizations can start from these three simple actions.&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;Measure token usage.&lt;/strong&gt; Instrument token telemetry; identify top cost drivers before changing models.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Benchmark small models.&lt;/strong&gt; Don't rely on generic benchmarks, measure them against your business KPIs.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Optimize serving layer.&lt;/strong&gt; Make sure you're getting the most out of your hardware or inference provider.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Stop buying intelligence by habit. Stop treating the model as the system. Preserve user trust while lowering the cost of each successful outcome.&lt;/p&gt;
&lt;p&gt;The next phase of AI competition will not be won by the company that uses the largest model most often. It will be won by the company that knows where intelligence is truly needed and designs the system around that fact.&lt;/p&gt;
&lt;h2&gt;References&lt;/h2&gt;
&lt;div class="footnote"&gt;
&lt;hr /&gt;
&lt;ol&gt;
&lt;li id="fn:stanford-2025"&gt;
&lt;p&gt;Stanford HAI, "The 2025 AI Index Report" (2025). https://hai.stanford.edu/ai-index/2025-ai-index-report&amp;#160;&lt;a class="footnote-backref" href="#fnref:stanford-2025" title="Jump back to footnote 1 in the text"&gt;&amp;#8617;&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li id="fn:stanford-2025-economy"&gt;
&lt;p&gt;Stanford HAI, "Economy | The 2025 AI Index Report" (2025), including corporate investment, private investment growth, and organizational AI use figures. https://hai.stanford.edu/ai-index/2025-ai-index-report/economy&amp;#160;&lt;a class="footnote-backref" href="#fnref:stanford-2025-economy" title="Jump back to footnote 2 in the text"&gt;&amp;#8617;&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li id="fn:gartner-genai-spend-2025"&gt;
&lt;p&gt;Gartner, "Gartner Forecasts Worldwide GenAI Spending to Reach $644 Billion in 2025" (Mar. 31, 2025). https://www.gartner.com/en/newsroom/press-releases/2025-03-31-gartner-forecasts-worldwide-genai-spending-to-reach-644-billion-in-2025&amp;#160;&lt;a class="footnote-backref" href="#fnref:gartner-genai-spend-2025" title="Jump back to footnote 3 in the text"&gt;&amp;#8617;&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li id="fn:gartner-2030"&gt;
&lt;p&gt;Gartner, "Gartner Predicts That by 2030, Performing Inference on an LLM With 1 Trillion Parameters Will Cost GenAI Providers Over 90% Less Than in 2025" (Mar. 25, 2026). https://www.gartner.com/en/newsroom/press-releases/2026-03-25-gartner-predicts-that-by-2030-performing-inference-on-an-llm-with-1-trillion-parameters-will-cost-genai-providers-over-90-percent-less-than-in-2025&amp;#160;&lt;a class="footnote-backref" href="#fnref:gartner-2030" title="Jump back to footnote 4 in the text"&gt;&amp;#8617;&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li id="fn:anthropic-context-2025"&gt;
&lt;p&gt;Anthropic Engineering, "Effective context engineering for AI agents" (Sep. 29, 2025). https://www.anthropic.com/engineering/effective-context-engineering-for-ai-agents&amp;#160;&lt;a class="footnote-backref" href="#fnref:anthropic-context-2025" title="Jump back to footnote 5 in the text"&gt;&amp;#8617;&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li id="fn:claude-prompt-caching-docs"&gt;
&lt;p&gt;Anthropic Docs, "Prompt caching." https://docs.claude.com/en/docs/build-with-claude/prompt-caching&amp;#160;&lt;a class="footnote-backref" href="#fnref:claude-prompt-caching-docs" title="Jump back to footnote 6 in the text"&gt;&amp;#8617;&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li id="fn:ms-rag-2026"&gt;
&lt;p&gt;Microsoft Learn, "Retrieval-augmented generation (RAG) in Azure AI Search." https://learn.microsoft.com/en-us/azure/search/retrieval-augmented-generation-overview&amp;#160;&lt;a class="footnote-backref" href="#fnref:ms-rag-2026" title="Jump back to footnote 7 in the text"&gt;&amp;#8617;&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li id="fn:openai-pricing-2026"&gt;
&lt;p&gt;OpenAI, "API Pricing." https://openai.com/api/pricing/&amp;#160;&lt;a class="footnote-backref" href="#fnref:openai-pricing-2026" title="Jump back to footnote 8 in the text"&gt;&amp;#8617;&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li id="fn:google-pricing-2026"&gt;
&lt;p&gt;Google AI for Developers, "Gemini API Pricing." https://ai.google.dev/gemini-api/docs/pricing&amp;#160;&lt;a class="footnote-backref" href="#fnref:google-pricing-2026" title="Jump back to footnote 9 in the text"&gt;&amp;#8617;&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li id="fn:anthropic-pricing-2026"&gt;
&lt;p&gt;Anthropic, "Plans &amp;amp; Pricing." https://www.anthropic.com/pricing&amp;#160;&lt;a class="footnote-backref" href="#fnref:anthropic-pricing-2026" title="Jump back to footnote 10 in the text"&gt;&amp;#8617;&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li id="fn:ms-slm-labelers-2026"&gt;
&lt;p&gt;Microsoft Research, "Fine-tuning Small Language Models as Efficient Enterprise Search Relevance Labelers" (arXiv abs/2601.03211, 2026). https://www.microsoft.com/en-us/research/publication/fine-tuning-small-language-models-as-efficient-enterprise-search-relevance-labelers/&amp;#160;&lt;a class="footnote-backref" href="#fnref:ms-slm-labelers-2026" title="Jump back to footnote 11 in the text"&gt;&amp;#8617;&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li id="fn:routing-cascading-2024"&gt;
&lt;p&gt;arXiv, "A Unified Approach to Routing and Cascading for LLMs" (2024/2025). https://arxiv.org/abs/2410.10347&amp;#160;&lt;a class="footnote-backref" href="#fnref:routing-cascading-2024" title="Jump back to footnote 12 in the text"&gt;&amp;#8617;&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li id="fn:taalas-home"&gt;
&lt;p&gt;Taalas, company site and product positioning. https://taalas.com/&amp;#160;&lt;a class="footnote-backref" href="#fnref:taalas-home" title="Jump back to footnote 13 in the text"&gt;&amp;#8617;&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li id="fn:taalas-products"&gt;
&lt;p&gt;Taalas, "Products" / HC1 technology demonstrator. https://taalas.com/products/&amp;#160;&lt;a class="footnote-backref" href="#fnref:taalas-products" title="Jump back to footnote 14 in the text"&gt;&amp;#8617;&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li id="fn:forbes-taalas-2026"&gt;
&lt;p&gt;Forbes / Cambrian-AI, Karl Freund, "Taalas Launches Hardcore Chip With 'Insane' AI Inference Performance" (Feb. 19, 2026). https://www.forbes.com/sites/karlfreund/2026/02/19/taalas-launches-hardcore-chip-with-insane-ai-inference-performance/&amp;#160;&lt;a class="footnote-backref" href="#fnref:forbes-taalas-2026" title="Jump back to footnote 15 in the text"&gt;&amp;#8617;&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li id="fn:cerebras-405b-2025"&gt;
&lt;p&gt;Cerebras, "Llama 3.1 405B now runs at 969 tokens/s on Cerebras Inference." https://www.cerebras.ai/blog/llama-405b-inference&amp;#160;&lt;a class="footnote-backref" href="#fnref:cerebras-405b-2025" title="Jump back to footnote 16 in the text"&gt;&amp;#8617;&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li id="fn:vectara-hallucination-blog"&gt;
&lt;p&gt;Vectara, "Introducing the Next Generation of Vectara's Hallucination Leaderboard." https://www.vectara.com/blog/introducing-the-next-generation-of-vectaras-hallucination-leaderboard&amp;#160;&lt;a class="footnote-backref" href="#fnref:vectara-hallucination-blog" title="Jump back to footnote 17 in the text"&gt;&amp;#8617;&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li id="fn:vectara-hallucination-github"&gt;
&lt;p&gt;Vectara, "Hallucination Leaderboard" GitHub repository. https://github.com/vectara/hallucination-leaderboard/&amp;#160;&lt;a class="footnote-backref" href="#fnref:vectara-hallucination-github" title="Jump back to footnote 18 in the text"&gt;&amp;#8617;&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li id="fn:etched-register"&gt;
&lt;p&gt;The Register, "Etched scores $120M for an ASIC built for transformer models" (Jun. 26, 2024). https://www.theregister.com/software/2024/06/26/etched-scores-120m-for-an-asic-built-for-transformer-models/679326&amp;#160;&lt;a class="footnote-backref" href="#fnref:etched-register" title="Jump back to footnote 19 in the text"&gt;&amp;#8617;&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;/div&gt;</description></item><item><title>ODSC AI East - From RAG to AI Agent</title><link>https://www.zansara.dev/talks/2026-04-29-odsc-ai-east-from-rag-to-ai-agents/</link><pubDate>Wed, 29 Apr 2026 00:00:00 +0000</pubDate><guid>https://www.zansara.dev/talks/2026-04-29-odsc-ai-east-from-rag-to-ai-agents/</guid><description>&lt;p&gt;&lt;a href="https://schedule.odsc.ai/" target="_blank" rel="noopener noreferrer"&gt;Announcement&lt;/a&gt;, &lt;a href="https://colab.research.google.com/drive/1ozI626XTyG9WBWip1uOQuP3E1MNFnr7x?usp=sharing" target="_blank" rel="noopener noreferrer"&gt;Colab Notebook&lt;/a&gt;, &lt;a href="https://drive.google.com/drive/folders/1GDUxb3Hg_acUYPgyJGCp8HZ5bOtgpE_S?usp=sharing" target="_blank" rel="noopener noreferrer"&gt;archive folder&lt;/a&gt;.&lt;/p&gt;
&lt;hr /&gt;
&lt;p&gt;At &lt;a href="https://odsc.ai/" target="_blank" rel="noopener noreferrer"&gt;ODSC AI East&lt;/a&gt; I show how you can take your RAG pipeline and, step by step, convert it into an AI agent. The talk is based on an earlier &lt;a href="https://www.zansara.dev/posts/2026-01-07-from-rag-to-ai-agent/"&gt;blog article&lt;/a&gt; and goes through &lt;a href="https://colab.research.google.com/drive/1ozI626XTyG9WBWip1uOQuP3E1MNFnr7x?usp=sharing" target="_blank" rel="noopener noreferrer"&gt;this Colab notebook&lt;/a&gt; where in under an hour we build from scratch a chatbot, a RAG pipeline, and then we progressively upgrade it to an AI Agent. Every step of the way is hand-on and you can take the notebook and adapt it to your stack for a more realistic example.&lt;/p&gt;</description></item><item><title>Women in Data Science Geneva - From RAG to AI Agent</title><link>https://www.zansara.dev/talks/2026-04-23-wids-geneva-from-rag-to-ai-agents/</link><pubDate>Thu, 23 Apr 2026 00:00:00 +0000</pubDate><guid>https://www.zansara.dev/talks/2026-04-23-wids-geneva-from-rag-to-ai-agents/</guid><description>&lt;p&gt;&lt;a href="https://widsgeneva.ch/" target="_blank" rel="noopener noreferrer"&gt;Announcement&lt;/a&gt;, &lt;a href="https://colab.research.google.com/drive/114YiWKVmYU4QkPdgXFDipvsaknW1rPd3?usp=sharing" target="_blank" rel="noopener noreferrer"&gt;Colab Notebook&lt;/a&gt;, &lt;a href="https://drive.google.com/drive/folders/1qkFobxmaMS1WU_FnL9_6Y_qkk60prarN?usp=sharing" target="_blank" rel="noopener noreferrer"&gt;archive folder&lt;/a&gt;.&lt;/p&gt;
&lt;hr /&gt;
&lt;p&gt;At &lt;a href="https://widsgeneva.ch/" target="_blank" rel="noopener noreferrer"&gt;Women in Data Science Geneva 2026&lt;/a&gt; I show how you can take your RAG pipeline and, step by step, convert it into an AI agent. The talk is based on an earlier &lt;a href="https://www.zansara.dev/posts/2026-01-07-from-rag-to-ai-agent/"&gt;blog article&lt;/a&gt; and goes through &lt;a href="https://colab.research.google.com/drive/114YiWKVmYU4QkPdgXFDipvsaknW1rPd3?usp=sharing" target="_blank" rel="noopener noreferrer"&gt;this Colab notebook&lt;/a&gt; where in under an hour we build from scratch a chatbot, a RAG pipeline, and then we progressively upgrade it to an AI Agent. Every step of the way is hand-on and you can take the notebook and adapt it to your stack for a more realistic example.&lt;/p&gt;</description></item><item><title>Setting the temperature to zero will make an LLM deterministic?</title><link>https://www.zansara.dev/posts/2026-03-24-temp-0-llm/</link><pubDate>Tue, 24 Mar 2026 00:00:00 +0000</pubDate><guid>https://www.zansara.dev/posts/2026-03-24-temp-0-llm/</guid><description>&lt;hr /&gt;
&lt;p&gt;&lt;em&gt;This is episode 8 of a series of shorter blog posts answering questions I received during the course of my work. They discuss common misconceptions and doubts about various generative AI technologies. You can find the whole series here: &lt;a href="/series/practical-questions"&gt;Practical Questions&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;
&lt;hr /&gt;
&lt;p&gt;One common explanation of the "temperature" parameter of LLMs is that it represents the "randomness" of the answer. &lt;/p&gt;
&lt;p&gt;That's broadly correct. Temperature is a parameter of the LLM final decoding steps, and the only one in the whole Transformer architecture that truly incorporates some randomness by design. At this stage, once the model has calculated the logits of the next token candidates, it has to map those values to an actual token from a list. Normally, LLMs perform best when they’re allowed to pick not necessarily the single best token, but instead choose at random among the N best tokens: the size of N is, more or less, what the temperature parameter represents.&lt;/p&gt;
&lt;p&gt;Therefore, when we set the temperature to 0, the LLM must always choose the best next token, without making random choices. So, if the input is fixed and we have removed the only source of randomness in the architecture, the outputs should always be identical... right?&lt;/p&gt;
&lt;p&gt;And yet, in practice, they often are not. Run the same prompt twice, with the same model, the same parameters, and temperature 0, and sooner or later the output will be a bit different. Not by much, usually. It may start with just one word; then the sentence takes a slightly different spin, until eventually the rest of the completion drifts away.&lt;/p&gt;
&lt;p&gt;What's going on?&lt;/p&gt;
&lt;h2&gt;Imperfect computations&lt;/h2&gt;
&lt;p&gt;If we pretend an LLM is just a mathematical function, &lt;code&gt;temperature=0&lt;/code&gt; should indeed make decoding deterministic. At each step, the model emits logits, we take the argmax token, append it to the context, and repeat. The problem is that real inference is performed with &lt;strong&gt;floating-point arithmetic&lt;/strong&gt; on massively parallel hardware, usually on a server that is trying to be as fast as possible rather than mathematically pristine.&lt;/p&gt;
&lt;p&gt;Floating-point arithmetic is only an approximation of real-number arithmetic. In particular, it is &lt;strong&gt;not associative&lt;/strong&gt;: in ordinary math, &lt;code&gt;(a + b) + c = a + (b + c)&lt;/code&gt; always holds, but with floating-point numbers those two expressions can produce slightly different results because each intermediate step is rounded. The same applies to matrix multiplications, reductions, and accumulations throughout a neural network. Change the order of operations, and you can change the last few bits of the result.&lt;/p&gt;
&lt;p&gt;Usually, those differences are tiny and often irrelevant, but in this case they have an impact. If two candidate next tokens have very similar logits, a minute numerical difference can swap their order, and once one token changes, the next decoding step runs on a different prefix, so the divergence compounds. The sampling rule is deterministic, while the computation that produced the logits is not guaranteed to be identical across runs.&lt;/p&gt;
&lt;p&gt;You can think of it this way: &lt;strong&gt;sampling determinism&lt;/strong&gt; is not the same thing as &lt;strong&gt;system determinism&lt;/strong&gt;.&lt;/p&gt;
&lt;h2&gt;It gets worse&lt;/h2&gt;
&lt;p&gt;However, this is only part of the problem. You may already be objecting that running the same matrix multiplication on a GPU with the same data repeatedly will always provide bitwise-identical results. The computations are done in floating-point arithmetic, and there are surely other jobs running on the GPU while your computer is on. So why are these calculations deterministic, while LLM sampling with &lt;code&gt;temperature=0&lt;/code&gt; is not?&lt;/p&gt;
&lt;p&gt;In a recent post on Thinking Machines's blog, &lt;a href="https://thinkingmachines.ai/blog/defeating-nondeterminism-in-llm-inference/" target="_blank" rel="noopener noreferrer"&gt;&lt;em&gt;Defeating Nondeterminism in LLM Inference&lt;/em&gt;&lt;/a&gt;, Horace He's digs even deeper into the issue. It's not merely that floating-point arithmetic is imperfect. Modern inference systems also need to batch requests together, and the result for one request can depend on the batch context in which it was executed. For a given exact batch, the forward pass may be deterministic. But from the user's point of view, the system is still nondeterministic, because the batch itself is not stable from run to run. Your prompt may be identical, but the inputs that get batched together with yours are not.&lt;/p&gt;
&lt;p&gt;This is also why a prompt can look stable in local testing and then become flaky in production: the model did not suddenly become more creative, it's the system conditions that changed. &lt;code&gt;temperature=0&lt;/code&gt; makes only the token selection rule deterministic. It does not guarantee that the entire inference system will produce exactly the same logits every time.&lt;/p&gt;
&lt;h2&gt;Can it be fixed?&lt;/h2&gt;
&lt;p&gt;The way LLMs inference works today, especially at scale, doesn't leave us with many options to enforce the conditions that can guarantee deterministic outputs. There are only trade-offs, and they differ quite a lot between hosted APIs and self-hosted inference.&lt;/p&gt;
&lt;h3&gt;Fixed seeds&lt;/h3&gt;
&lt;p&gt;To reduce randomness and make LLM outputs reproducible, some people recommend using a fixed seed, and indeed some providers expose one. OpenAI, for example, &lt;a href="https://developers.openai.com/cookbook/examples/reproducible_outputs_with_the_seed_parameter" target="_blank" rel="noopener noreferrer"&gt;documents&lt;/a&gt; a &lt;code&gt;seed&lt;/code&gt; parameter and says it makes a best effort to sample deterministically, while explicitly warning that determinism is not guaranteed and that backend changes can still affect outputs. Their &lt;code&gt;system_fingerprint&lt;/code&gt; field exists precisely so you can notice when the underlying serving configuration has changed.&lt;/p&gt;
&lt;p&gt;The problem with fixed seeds is that they help reproduce results when the temperature is above zero, not when it's already zeroed out. That's because a fixed seed controls the randomness of the sampling step: by setting the temperature to zero, we are already removing that source of randomness, so the net result is identical with or without a fixed seed, while every other source of nondeterminism coming from the GPU and the rest of the stack is unaffected.&lt;/p&gt;
&lt;p&gt;So fixed seeds are worth using when you are trying to get the same results for a call with non-zero temperature, such as for tests, demos, and regression checks. But you must keep in mind that they affect only the sampler, and they won't help you when temperature is zero.&lt;/p&gt;
&lt;h3&gt;No parallel jobs&lt;/h3&gt;
&lt;p&gt;If you self-host, one option to drastically reduce randomness is to reduce or eliminate concurrency.&lt;/p&gt;
&lt;p&gt;This works for the simple reason that it stabilizes batching and scheduling. vLLM's &lt;a href="https://docs.vllm.ai/en/latest/usage/reproducibility" target="_blank" rel="noopener noreferrer"&gt;reproducibility guidance&lt;/a&gt; says that by default it does not guarantee reproducibility on its own. In offline mode, you should disable multiprocessing to make scheduling deterministic, while in online mode, you need batch invariance support if you want outputs that are insensitive to batching. vLLM also documents batch invariance as a distinct feature and notes that it currently depends on specific hardware support.&lt;/p&gt;
&lt;p&gt;This means that you can pick a few different configurations, depending on your needs:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;shared online serving with dynamic batching: fastest, cheapest, least reproducible&lt;/li&gt;
&lt;li&gt;isolated worker / no concurrent jobs: slower, more expensive, more reproducible&lt;/li&gt;
&lt;li&gt;specialized batch-invariant serving paths: better reproducibility, but with hardware and feature constraints&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The overall pattern is that the more you optimize for throughput, the more reproducibility suffers.&lt;/p&gt;
&lt;h3&gt;Cache responses&lt;/h3&gt;
&lt;p&gt;Caching doesn't exactly address the reproducibility issue per se, but in many applications it's the right level of abstraction if you want the same input to produce the same output. It's often not only the most viable option, but also the cheapest, simplest, and fastest, unless you're running a benchmark or an evaluation.&lt;/p&gt;
&lt;p&gt;In practice, if you just need the &lt;em&gt;same visible result&lt;/em&gt; for the same request, the most reliable method is not to regenerate it at all. Normalize the prompt, model ID, and relevant parameters into a cache key, store the first successful response, and serve that on subsequent identical requests. This does not make the model deterministic, of course, but it does make your &lt;em&gt;application&lt;/em&gt; deterministic at the interface boundary, which is usually what application builders need.&lt;/p&gt;
&lt;p&gt;Caching also has a very nice advantage over seeds and scheduler tricks: it does not depend on hidden implementation details inside the inference stack.&lt;/p&gt;
&lt;p&gt;Of course, caching has limits. It only helps when requests repeat, and it can become awkward if tool calls, timestamps, external retrieval, or hidden context make two apparently identical requests not truly identical. Still, it is usually far more convenient than any other solution to this problem, and the only practical one for most production systems.&lt;/p&gt;
&lt;h2&gt;Conclusion&lt;/h2&gt;
&lt;p&gt;When faced with LLM nondeterminism, there's often the reaction to treat it like a bug and to try to eliminate that. However, you should also keep in mind that LLMs were designed with a randomness factor built-in for a reason: because they perform much better when they are allowed a slight degree of nondeterminism.&lt;/p&gt;
&lt;p&gt;I get it: nobody likes having such a huge, random black box at the core of an application's business logic. But removing randomness from the outputs is not the right way to manage an LLM's behavior. If you need completely deterministic output, it is better to use the LLM to design a decision tree (or a more sophisticated model, if needed) and then use that in your application.&lt;/p&gt;
&lt;p&gt;Handling LLM outputs is rather matter of validation. Use schemas and validators so small textual drift does not break downstream code. Use evals instead of spot-checking. Cache where consistency matters, or where you need to save a few bucks. In other words, handle the randomness at the system boundary rather than trying to remove it from the model itself.&lt;/p&gt;</description></item><item><title>BGB Group - LLMs That Think: Demystifying Reasoning Models (in 5 minutes!)</title><link>https://www.zansara.dev/talks/2026-03-19-bgb-reasoning-models/</link><pubDate>Thu, 19 Mar 2026 00:00:00 +0000</pubDate><guid>https://www.zansara.dev/talks/2026-03-19-bgb-reasoning-models/</guid><description>&lt;p&gt;&lt;a href="https://docs.google.com/presentation/d/1v0p85jeqsh4sbqrqsAPtwfXdp62ynqGSxpY4jSxIw2E/edit?usp=sharing" target="_blank" rel="noopener noreferrer"&gt;Slides&lt;/a&gt;. All resources can also be found in &lt;a href="https://drive.google.com/drive/folders/1jaFh-EykLrPMEVBSqwo-VkGS-Gd1QXd_?usp=drive_link" target="_blank" rel="noopener noreferrer"&gt;my archive&lt;/a&gt;.&lt;/p&gt;
&lt;hr /&gt;
&lt;p&gt;For a &lt;a href="https://bgbgroup.com/" target="_blank" rel="noopener noreferrer"&gt;BGB Group&lt;/a&gt; internal showcase I talked about reasoning models: what they are, how they work and when to use them -- all in just five minutes!&lt;/p&gt;
&lt;p&gt;To answer these questions I classified LLMs into a small "taxonomy" based on the post-training steps they go through, in order to highlight how reasoning models differ qualitatively from their predecessors just like instruction-tuned models were not simple text-completion models with a better prompt. &lt;/p&gt;</description></item><item><title>Warsaw IT Days - From RAG to AI Agent &amp; LLMs That Think: Demystifying Reasoning Models</title><link>https://www.zansara.dev/talks/2026-03-19-warsaw-it-days-from-rag-to-ai-agent-and-reasoning-models/</link><pubDate>Thu, 19 Mar 2026 00:00:00 +0000</pubDate><guid>https://www.zansara.dev/talks/2026-03-19-warsaw-it-days-from-rag-to-ai-agent-and-reasoning-models/</guid><description>&lt;p&gt;&lt;a href="https://warszawskiedniinformatyki.pl/conference/en/#agenda" target="_blank" rel="noopener noreferrer"&gt;Announcement&lt;/a&gt;. For "From RAG to AI Agent": &lt;a href="https://drive.google.com/file/d/1QeqBqSiDZ0d55IzNQqxLmN_o6ZmuNfBq/preview" target="_blank" rel="noopener noreferrer"&gt;recording&lt;/a&gt;, &lt;a href="https://colab.research.google.com/drive/1ql8BoUZBG2TAeqiN1o65mwmDQLpK6_xY?usp=drive_link" target="_blank" rel="noopener noreferrer"&gt;Colab Notebook&lt;/a&gt;, &lt;a href="https://drive.google.com/drive/folders/14xhRHoYbx9JBPFSr6Y2STIBINqL0sA6t?usp=drive_link" target="_blank" rel="noopener noreferrer"&gt;archive folder&lt;/a&gt;. For "LLMs That Think": &lt;a href="https://drive.google.com/file/d/16XtEakj5iCkZDHsOwGVI63gsFtaf1ZmM/preview" target="_blank" rel="noopener noreferrer"&gt;recording&lt;/a&gt;, &lt;a href="https://drive.google.com/file/d/1MXfk78_vVA51_eCzDzfKxQZ7vKM4Mp3Q/view?usp=drive_link" target="_blank" rel="noopener noreferrer"&gt;slides&lt;/a&gt;, &lt;a href="https://drive.google.com/drive/folders/1RuNJNorTW7Usr7z7Nt6lxWV08n9QxUoU?usp=drive_link" target="_blank" rel="noopener noreferrer"&gt;archive folder&lt;/a&gt;. &lt;/p&gt;
&lt;hr /&gt;
&lt;p&gt;At the &lt;a href="https://warszawskiedniinformatyki.pl/" target="_blank" rel="noopener noreferrer"&gt;Warsaw IT Days&lt;/a&gt; I gave two talks.&lt;/p&gt;
&lt;p&gt;In the first, "From RAG to AI Agent", I show how you can take your RAG pipeline and, step by step, convert it into an AI agent. The talk is based on an earlier &lt;a href="https://www.zansara.dev/posts/2026-01-07-from-rag-to-ai-agent/"&gt;blog article&lt;/a&gt; and goes through &lt;a href="https://colab.research.google.com/drive/1ql8BoUZBG2TAeqiN1o65mwmDQLpK6_xY?usp=drive_link" target="_blank" rel="noopener noreferrer"&gt;this Colab notebook&lt;/a&gt; where in under half a hour we build from scratch a chatbot, a RAG pipeline, and then we progressively upgrade it to an AI Agent. Every step of the way is hand-on and you can take the notebook and adapt it to your stack for a more realistic example.&lt;/p&gt;
&lt;iframe src="https://drive.google.com/file/d/1QeqBqSiDZ0d55IzNQqxLmN_o6ZmuNfBq/preview" width="800" height="500"&gt;&lt;/iframe&gt;

&lt;p&gt;In the second, "LLMs that Think: Demystifying Reasoning Models", I talk about reasoning LLMs: what they are, what they aren't, how they work and when to use them. Is GPT-5 AGI? Is it an AI Agent? Or is it just a glorified chain-of-thought prompt under the hood? To answer these questions, I classify LLMs into a small "taxonomy" based on the post-training steps they go through, in order to highlight how reasoning models differ qualitatively from their predecessors just like instruction-tuned models were not simple text-completion models with a better prompt. I also cover the effect of increasing the reasoning effort of the model, clarifying when it's useful and when it can lead to overthinking.&lt;/p&gt;
&lt;iframe src="https://drive.google.com/file/d/16XtEakj5iCkZDHsOwGVI63gsFtaf1ZmM/preview" width="800" height="500"&gt;&lt;/iframe&gt;</description></item><item><title>Is grep really better than a vector DB?</title><link>https://www.zansara.dev/posts/2026-03-15-vector-dbs-vs-grep/</link><pubDate>Sun, 15 Mar 2026 00:00:00 +0000</pubDate><guid>https://www.zansara.dev/posts/2026-03-15-vector-dbs-vs-grep/</guid><description>&lt;hr /&gt;
&lt;p&gt;&lt;em&gt;This is episode 7 of a series of shorter blog posts answering questions I received during the course of my work. They discuss common misconceptions and doubts about various generative AI technologies. You can find the whole series here: &lt;a href="/series/practical-questions"&gt;Practical Questions&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;
&lt;hr /&gt;
&lt;p&gt;For the past two years, the default architecture for giving LLMs access to a knowledge base has been &lt;strong&gt;RAG with vector databases&lt;/strong&gt;. &lt;/p&gt;
&lt;p&gt;This architecture turned out to be very powerful, but it's far from cheap to setup and maintain: you need the system to chunk all the documents, embed all the chunks, store them in a vector DB, retrieve them, and feed them to the model. Every new document needs to go through this pipeline before it's usable, and changes to a document already processed means going through the vector DB and deleting all the affected chunks.&lt;/p&gt;
&lt;p&gt;So it may come as a big surprise for many of us to learn that, as some people claims, an agent equipped with &lt;code&gt;grep&lt;/code&gt; can find the data it's looking for just as well.&lt;/p&gt;
&lt;p&gt;For example, &lt;a href="https://youtu.be/99Kxkemj1g8?t=4308" target="_blank" rel="noopener noreferrer"&gt;one of the many comparisons&lt;/a&gt; that have been done on this topic found roughly these figures when answering questions about a Django codebase:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;Vector search&lt;/strong&gt; over embedded chunks achieved ~60% accuracy.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Agentic search&lt;/strong&gt; using tools like &lt;code&gt;grep&lt;/code&gt;, &lt;code&gt;find&lt;/code&gt;, and &lt;code&gt;cat&lt;/code&gt;, where the model iteratively explores the repository, achieved ~68%.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;The same test on a TypeScript/Go codebase had the two approaches both reaching around ~70%.  &lt;/p&gt;
&lt;p&gt;The difference was &lt;strong&gt;cost and context&lt;/strong&gt;: vector search consumed significantly more tokens. While it arguably provided more context to the agent, it's not clear whether the context retrieved this way was more useful, and it's easy to find contradicting results on the Internet.&lt;/p&gt;
&lt;p&gt;So, what's truly going on? &lt;/p&gt;
&lt;p&gt;If I had to summarize it in one sentence, it would be: retrieval quality depends heavily on the domain and the structure of the information.&lt;/p&gt;
&lt;h2&gt;Let's check our assumptions&lt;/h2&gt;
&lt;p&gt;Classic retrieval steps in the RAG architecture assumes the query &lt;strong&gt;must be correct on the first try&lt;/strong&gt;. Because of this, most of the effort and breakthroughs in this field focused on getting decent results for all possible queries. &lt;/p&gt;
&lt;p&gt;Vector search shines at this. By getting the chunks of context that semantically come as close as possible to the query (or to an answer to it), embedding-based retrieval was crucial for the one-shot retrieval typical of RAG apps.&lt;/p&gt;
&lt;p&gt;However, agents remove that constraint. An agent can try an initial search with a surely subpar query, then inspect the results, refine the query, and search again.&lt;/p&gt;
&lt;p&gt;This iterative process dramatically reduces the weaknesses of keyword search and, in fact, leverages all its strengths: exact keyword retrieval is not an ideal task for a vector DB, because semantically similar keywords will also be included.&lt;/p&gt;
&lt;p&gt;This does not mean vector search is useless in the age of agents.&lt;/p&gt;
&lt;h2&gt;Domain Differences&lt;/h2&gt;
&lt;p&gt;Retrieval strategies behave very differently depending on the domain. Let's see a few examples to understand where one approach or the other shines.&lt;/p&gt;
&lt;h3&gt;Code Search&lt;/h3&gt;
&lt;p&gt;Code search is a perfect candidate for &lt;strong&gt;agentic keyword search&lt;/strong&gt;, because identifiers are keywords that need exact matches in the results. &lt;/p&gt;
&lt;p&gt;Vector search, while possible, has always been difficult to perform effectively on code. On top of that, there are tons of tools and techniques made for human coders to navigate a codebase with keywords, and agents can take advantage of those. For example, agents can use &lt;code&gt;grep&lt;/code&gt;, AST search, symbol indexing, repository graphs, and more.&lt;/p&gt;
&lt;p&gt;There's also a problem with &lt;strong&gt;context fragmentation&lt;/strong&gt;. Vector search returns chunks, which in the case of code search are usually a fixed number of lines or symbols. Most of the time this context is useless for the agent, because it rarely includes a full logical unit, and when it does (such as when chunking on function boundaries), it becomes much harder to retrieve, because the chunks are larger.&lt;/p&gt;
&lt;p&gt;This means that not only is vector search less precise, but it also wastes a lot of context.&lt;/p&gt;
&lt;h3&gt;How-to Guides / Knowledge Bases / General Prose&lt;/h3&gt;
&lt;p&gt;This is the classic use case where &lt;strong&gt;vector search shines&lt;/strong&gt; and keyword search is far less effective.&lt;/p&gt;
&lt;p&gt;When your corpus of text is made of conceptual explanations, natural language queries, inconsistent terminology, and so on, semantic similarity is the most likely to bring up relevant results.&lt;/p&gt;
&lt;p&gt;Even in this case, however, pure vector search usually gets beaten by hybrid approaches, such as running vector and keyword searches in parallel and then reranking the results.&lt;/p&gt;
&lt;p&gt;You can find more about hybrid retrieval in &lt;a href="/posts/2025-11-04-hybrid-retrieval/"&gt;this other post of mine&lt;/a&gt;.&lt;/p&gt;
&lt;h3&gt;Legal / Medical / Scientific Documents&lt;/h3&gt;
&lt;p&gt;These sit somewhere in between. In these documents, the terminology is specialized, wording matters, and citations and sections are important. Vector search can surface relevant passages, but precision matters more than in the previous scenario. There's more structure than in free-form prose, and you can't lose it during the retrieval phase.&lt;/p&gt;
&lt;p&gt;For these kinds of documents, hybrid approaches are necessary to avoid too many false positive matches.&lt;/p&gt;
&lt;h2&gt;What should I pick?&lt;/h2&gt;
&lt;p&gt;Choosing an approach usually depends on the use cases you foresee for your agent, but in practice it's often difficult to know beforehand what kind of documents your agent will need to sift through. Even coding agents need to search the web and read technical documentation, for example.&lt;/p&gt;
&lt;p&gt;In these situations, it's best to avoid flattening the decision into a "keyword vs embeddings" choice. Your agent can make use of both of them and more. For example, if your agent must be able to search anything, you may give it:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;A vector DB for static, shapeless prose, for example internal knowledge bases, static "ground truth" documents, foundational data, etc. Even searching through messages on Slack and Teams may be a good fit for a vector DB.&lt;/li&gt;
&lt;li&gt;Tools like &lt;code&gt;grep&lt;/code&gt;, &lt;code&gt;cat&lt;/code&gt;, &lt;code&gt;find&lt;/code&gt;, etc. Let the agent leverage its coding skills for quick keyword searches across all the data. Don't forget to make the data that's available in the vector DB also accessible through these tools.&lt;/li&gt;
&lt;li&gt;A simple BM25 index that can be searched for keyword matches when the results from the command-line tools are overwhelming for the agent.&lt;/li&gt;
&lt;li&gt;A web search tool that the agent can use to complement its local search results, if applicable.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;... and so on. &lt;/p&gt;
&lt;h2&gt;Conclusion&lt;/h2&gt;
&lt;p&gt;Vector databases are not automatically the correct architecture. Neither is &lt;code&gt;grep&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;Before choosing, it is worth asking:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Is the information to search through &lt;strong&gt;structural&lt;/strong&gt; or &lt;strong&gt;semantic&lt;/strong&gt;?&lt;/li&gt;
&lt;li&gt;Do queries benefit from &lt;strong&gt;iteration&lt;/strong&gt;? Will my agent be able to retry the search as many times as it wants?&lt;/li&gt;
&lt;li&gt;Would a simple keyword search index solve most cases, or do I need to search by meaning?&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Sometimes the correct system architecture is a sophisticated hybrid embedding retriever. And sometimes it is still just &lt;code&gt;grep -R "the keyword"&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;The only way to know for sure is, as usual, a RAG evaluation pipeline. Don't forget to measure your outcomes!&lt;/p&gt;</description></item><item><title>Phishing AI Agents</title><link>https://www.zansara.dev/posts/2026-03-04-phishing-ai-agents/</link><pubDate>Wed, 04 Mar 2026 00:00:00 +0000</pubDate><guid>https://www.zansara.dev/posts/2026-03-04-phishing-ai-agents/</guid><description>&lt;hr /&gt;
&lt;p&gt;&lt;em&gt;This post is based on one of my talks, &lt;a href="https://www.zansara.dev/talks/2026-02-25-mindstone-lisbon-meetup/"&gt;"Phishing AI Agents"&lt;/a&gt;. Have a look at the &lt;a href="https://community.mindstone.com/annotate/article_B3qZVBLeehDkqDzhj7" target="_blank" rel="noopener noreferrer"&gt;recording&lt;/a&gt; of my presentation at Lisbon's &lt;a href="https://community.mindstone.com/events/mindstone-lisbon-february-ai-meetup" target="_blank" rel="noopener noreferrer"&gt;Mindstone AI Meetup&lt;/a&gt; in February 2026, and check out the &lt;a href="https://www.zansara.dev/talks/2026-02-25-mindstone-lisbon-meetup/"&gt;talk page&lt;/a&gt; for slides and demo code.&lt;/em&gt;&lt;/p&gt;
&lt;hr /&gt;
&lt;p&gt;Lately, everyone is talking about deploying AI agents, but not many ask themselves what happens once those agents are out in the world.&lt;/p&gt;
&lt;p&gt;We are used to thinking about phishing as a human problem: a person receives an unusual message, trusts it for some reason, and gives away something sensitive. But what happens when the target is not a person, but an AI agent? Can an agent be phished? And if so, what does that actually look like in practice?&lt;/p&gt;
&lt;h2&gt;Useful agents are trusted agents&lt;/h2&gt;
&lt;p&gt;AI agents are powerful precisely because they are trusted with access to many of our most private accounts. An agent may need to read email, access calendars, browse internal documentation, inspect private GitHub repositories, review tickets, or interact with SaaS tools and APIs. In other words, the agent must have both context and capability.&lt;/p&gt;
&lt;p&gt;That also means it becomes a &lt;strong&gt;security boundary&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;A common but weak assumption in many deployments is that if we tell the agent that some data is confidential, it will keep that data confidential. In practice, that is not a sufficient control. Once an agent is exposed to the wrong content under the wrong conditions, secrecy instructions alone do not reliably prevent leakage. But what is the wrong content and conditions? Is browsing the web the issue? Or the ability to interact with strangers? Is my air-gapped agents running on a dedicated Mac Mini secure?&lt;/p&gt;
&lt;h2&gt;The “lethal trifecta”&lt;/h2&gt;
&lt;p&gt;A useful way to think about this is through what &lt;a href="https://simonwillison.net/2025/Jun/16/the-lethal-trifecta/" target="_blank" rel="noopener noreferrer"&gt;some researchers&lt;/a&gt; call the &lt;strong&gt;lethal trifecta&lt;/strong&gt;. The term is not especially intuitive, but the idea is simple:&lt;/p&gt;
&lt;p&gt;If an agent has:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;access to private data,  &lt;/li&gt;
&lt;li&gt;the ability to communicate externally, and  &lt;/li&gt;
&lt;li&gt;exposure to untrusted content,  &lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;then you agent is &lt;strong&gt;vulnerable by design&lt;/strong&gt;, and there is a path to data exfiltration.&lt;/p&gt;
&lt;p&gt;&lt;img alt="" src="/posts/2026-03-04-phishing-ai-agents/lethaltrifecta.jpg" /&gt;&lt;/p&gt;
&lt;p&gt;&lt;em&gt;The original definition of the "lethal trifecta" comes from &lt;a href="https://simonwillison.net/2025/Jun/16/the-lethal-trifecta/" target="_blank" rel="noopener noreferrer"&gt;Simon Willison's blog&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;The exact exploit path may be simple or more complicated. It may take one try or many. But if those three conditions are present, the question is often not &lt;em&gt;whether&lt;/em&gt; a leak is possible, but &lt;em&gt;when&lt;/em&gt; it will happen.&lt;/p&gt;
&lt;p&gt;This matters because many real agents satisfy these conditions almost by default. A very small agent that can read email, browse the web, and access a secret is already vulnerable.&lt;/p&gt;
&lt;p&gt;That does not mean every such agent will be compromised immediately. It does mean you should not assume that prompt instructions alone make it safe.&lt;/p&gt;
&lt;h2&gt;Demo setup&lt;/h2&gt;
&lt;p&gt;To make this concrete, I built a minimal demo in a controlled environment. You can find all the code I used to build this demo &lt;a href="https://github.com/ZanSara/mindstone-lethal-trifecta-demo" target="_blank" rel="noopener noreferrer"&gt;here&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;The demo agent is implemented in &lt;a href="https://n8n.io/" target="_blank" rel="noopener noreferrer"&gt;n8n&lt;/a&gt; as a low-code workflow and it's intentionally very simple:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;it receives chat input formatted as if it were email,&lt;/li&gt;
&lt;li&gt;it's powered by a modern frontier model, specifically GPT 5.2,&lt;/li&gt;
&lt;li&gt;it has access to only one tool, HTTP GET, for web browsing,&lt;/li&gt;
&lt;li&gt;it operates in a small local environment with a fake search engine, fake documentation pages, and a fake SaaS product.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;img alt="" src="/posts/2026-03-04-phishing-ai-agents/agent.png" /&gt;&lt;/p&gt;
&lt;p&gt;&lt;em&gt;The agent's achitecture in &lt;a href="https://n8n.io/" target="_blank" rel="noopener noreferrer"&gt;n8n&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;Somewhere in this environment I also placed an attacker's trap, and if the agent falls for it, we should receive the leaked credentials through a Telegram message.&lt;/p&gt;
&lt;p&gt;The agent’s system prompt contains instructions and a few secrets, including an API key for our imaginary SaaS product. The prompt explicitly told the agent not to share those credentials with anybody and indeed, if you directly ask the agent for the API key, it refuses.&lt;/p&gt;
&lt;p&gt;That is what many teams observe in testing, and it often creates false confidence. The agent appears aligned. It appears to understand that the credential is sensitive. But direct requests are the easy case: our demo is not about getting the model to share the credentials through an email, or some other form or prompt injection. We're gonna demonstrate an entirely different attack surface, something much more similar to regular phishing as conducted against human targets.&lt;/p&gt;
&lt;h2&gt;A plausible support request&lt;/h2&gt;
&lt;p&gt;The interesting failure mode appears when the attacker does not ask for the secret directly. Instead, they send something that looks like a normal support or troubleshooting request:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;I’m trying to call this endpoint on this SaaS API but I can’t get it to work. Can you send me a working example?&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;This is exactly the kind of task a helpful agent is supposed to solve. So the agent does what a helpful agent would do:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;it searches for relevant documentation,  &lt;/li&gt;
&lt;li&gt;it follows documentation links,  &lt;/li&gt;
&lt;li&gt;it discovers API references or an OpenAPI spec,  &lt;/li&gt;
&lt;li&gt;it come across for a sandbox or example environment,  &lt;/li&gt;
&lt;li&gt;and it tries to produce a working example.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;And that is where the leak happens.&lt;/p&gt;
&lt;iframe src="https://drive.google.com/file/d/1O6gynFHtquZQ4cEybfeqiMNP_Yob0fnK/preview" width="800" height="500"&gt;&lt;/iframe&gt;

&lt;p&gt;In the demo, the agent found documentation that pointed to a sandbox endpoint controlled by the attacker. The agent treated that documentation as legitimate, believed the sandbox was part of the normal workflow, and tested the integration using the real API key it had been given.&lt;/p&gt;
&lt;p&gt;The result: the attacker received the credential.&lt;/p&gt;
&lt;p&gt;Not because the agent was asked to disclose it, but because the agent was induced to &lt;strong&gt;use&lt;/strong&gt; it in the wrong place.&lt;/p&gt;
&lt;p&gt;That distinction matters. Many defenses focus on preventing explicit disclosure. Real attacks often succeed by steering the agent into operational misuse instead.&lt;/p&gt;
&lt;h2&gt;How does the trick work?&lt;/h2&gt;
&lt;p&gt;The attack depends on a simple fact: the agent is willing to treat some external content as trustworthy enough to act on.&lt;/p&gt;
&lt;p&gt;If attacker-controlled documentation, examples, links, or sandboxes are interpreted as valid guidance, then the agent can be manipulated into doing work on the attacker’s infrastructure. Once that happens, any credential it uses may be exposed.&lt;/p&gt;
&lt;p&gt;Usually, a developer won't use a real API key on a sandbox system randomly found on the web, but an agent, being more naive, will try it out.&lt;/p&gt;
&lt;p&gt;Seen under this light, this is a phishing attack:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;The email to the agent is the lure.  &lt;/li&gt;
&lt;li&gt;The malicious documentation is the fake login page.  &lt;/li&gt;
&lt;li&gt;The sandbox is where the credential gets captured.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;And critically, a limited toolset does not save you. Restricting an agent to HTTP GET does &lt;strong&gt;not&lt;/strong&gt; eliminate prompt-injection or phishing-style risk. If the agent can fetch attacker-controlled content and then use secrets in a way that causes outbound requests, that can be enough.&lt;/p&gt;
&lt;h2&gt;In the real world&lt;/h2&gt;
&lt;p&gt;A common reaction is that this sounds artificial: surely a fake documentation page will never outrank the real docs, and an agent will be able to tell the difference, right? Surely the agent will not fall for something that naive.&lt;/p&gt;
&lt;p&gt;That objection misses two things. First, &lt;strong&gt;attackers have time&lt;/strong&gt;. They can try many variants, test against many products, and refine their lures, and with the help of modern LLMs, setting up a trap like this takes a hour at most, and can be automated to a large degree. Second, the search engine is not even necessary: an attacker can send the link directly by email, ticket, document, chat message, or issue comment. If the agent consumes the content and treats it as actionable, that may be enough.&lt;/p&gt;
&lt;p&gt;Also, the leak only needs to happen once.&lt;/p&gt;
&lt;p&gt;A stolen API key does not announce itself! If the attacker uses it quietly, the victim may not notice for some time. That makes one-time leakage operationally serious even if the exploit is intermittent.&lt;/p&gt;
&lt;h2&gt;What to do about it&lt;/h2&gt;
&lt;p&gt;The real problem is that there is no complete, simple fix today. If your architecture satisfies the lethal trifecta, you should assume residual exfiltration risk remains. That said, some mitigations are still worth applying to reduce your attack surface area.&lt;/p&gt;
&lt;h3&gt;1. Use disposable, low-privilege credentials&lt;/h3&gt;
&lt;p&gt;Do not give agents credentials you cannot afford to lose.&lt;/p&gt;
&lt;p&gt;Prefer:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;narrowly scoped API keys,&lt;/li&gt;
&lt;li&gt;short-lived credentials,&lt;/li&gt;
&lt;li&gt;credentials and keys that are easy to rotate,&lt;/li&gt;
&lt;li&gt;strong isolation between environments,&lt;/li&gt;
&lt;li&gt;permissions minimized to exactly what the agent needs.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;If a key leaks, recovery should be operationally manageable and should not bankrupt you.&lt;/p&gt;
&lt;h3&gt;2. Monitor and review credential use&lt;/h3&gt;
&lt;p&gt;If agents are using secrets, their activity should be observable. If your agent is exposed and has access to some sensitive credentials, you should consider setting up:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;usage logs,&lt;/li&gt;
&lt;li&gt;anomaly detection,&lt;/li&gt;
&lt;li&gt;per-agent attribution,&lt;/li&gt;
&lt;li&gt;alerts for unusual destinations or access patterns,&lt;/li&gt;
&lt;li&gt;rapid revocation workflows.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;This is not perfect, but it reduces dwell time after compromise.&lt;/p&gt;
&lt;h3&gt;3. Red-team the agent continuously&lt;/h3&gt;
&lt;p&gt;Static evaluation is not enough.&lt;/p&gt;
&lt;p&gt;When you discover a new attack pattern, test it against your own deployment. If your agent reads email, test adversarial email. If it reads docs, test malicious docs. If it uses APIs, test whether it can be tricked into authenticating to the wrong place. Then assess the damage and reinforce the prompt guardrails, tighten whitelists, but also improve your own process for recovery from the type of leak you observed, because no safeguard is 100% secure today.&lt;/p&gt;
&lt;p&gt;Treat agent security as an ongoing adversarial exercise, not a one-time review.&lt;/p&gt;
&lt;h3&gt;4. Improve prompts&lt;/h3&gt;
&lt;p&gt;Stronger system prompts can help. You can include examples of prompt injection, tool misuse, credential theft, malicious links, and suspicious documentation patterns. However, this should be treated as one layer, not as a primary guarantee. Prompting can reduce some classes of failure, but does not remove the inherent risk.&lt;/p&gt;
&lt;h2&gt;Architectural defenses&lt;/h2&gt;
&lt;p&gt;The more serious defenses are architectural.&lt;/p&gt;
&lt;p&gt;A promising direction is to &lt;strong&gt;separate the model that reads untrusted content from the model or system that has tool access and secrets&lt;/strong&gt;. In other words, do not let the same component both interpret attacker-controlled input and directly act with privileged credentials. This kind of separation reduces the chance that malicious instructions flow directly from content ingestion into secret-bearing tool use.&lt;/p&gt;
&lt;p&gt;One example of this broader design direction is the &lt;a href="https://simonwillison.net/2025/Apr/11/camel/" target="_blank" rel="noopener noreferrer"&gt;CaMeL&lt;/a&gt; approach, where responsibilities are split across components with different trust assumptions. That area is still early, and there are not yet many mature production implementations, but it points toward a more defensible model than "one agent does everything."&lt;/p&gt;
&lt;h2&gt;Conclusion&lt;/h2&gt;
&lt;p&gt;State of the art is improving, but most current agent implementations still do not adequately account for these threats. If you are deploying agents into real workflows, especially workflows that combine private data, external communication, and untrusted content, then you need to be much more careful than most demos and product pages suggest.&lt;/p&gt;
&lt;p&gt;The problem is not just that an agent might say the wrong thing to the wrong person. The problem is that a capable agent can be manipulated into &lt;strong&gt;doing the wrong thing with your secrets&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;That is what phishing an AI agent looks like. If you are building or deploying agents today, assume they are vulnerable to this class of attack.&lt;/p&gt;</description></item><item><title>Mindstone AI Meetup Lisbon - Phishing AI Agents</title><link>https://www.zansara.dev/talks/2026-02-25-mindstone-lisbon-meetup/</link><pubDate>Wed, 25 Feb 2026 00:00:00 +0000</pubDate><guid>https://www.zansara.dev/talks/2026-02-25-mindstone-lisbon-meetup/</guid><description>&lt;p&gt;&lt;a href="https://community.mindstone.com/events/mindstone-lisbon-february-ai-meetup" target="_blank" rel="noopener noreferrer"&gt;Announcement&lt;/a&gt;, &lt;a href="https://community.mindstone.com/annotate/article_B3qZVBLeehDkqDzhj7" target="_blank" rel="noopener noreferrer"&gt;recording&lt;/a&gt;, &lt;a href="https://drive.google.com/file/d/1EA1OuZRaP0JMboZ_lYiN8bEidxOLACf9/view?usp=sharing" target="_blank" rel="noopener noreferrer"&gt;slides&lt;/a&gt;, &lt;a href="https://github.com/ZanSara/mindstone-lethal-trifecta-demo" target="_blank" rel="noopener noreferrer"&gt;demo repository&lt;/a&gt; and &lt;a href="https://drive.google.com/file/d/1O6gynFHtquZQ4cEybfeqiMNP_Yob0fnK/view?usp=drive_link" target="_blank" rel="noopener noreferrer"&gt;demo recording&lt;/a&gt;. All resources can also be found in &lt;a href="https://drive.google.com/drive/folders/1bg7FjLOtf1I-kLaFx9rB63gQKFimpDrM?usp=drive_link" target="_blank" rel="noopener noreferrer"&gt;my archive&lt;/a&gt;.&lt;/p&gt;
&lt;hr /&gt;
&lt;iframe src="https://drive.google.com/file/d/1IlQzxMcD8VR_3fSni26p4mBxJW4PLrP0/preview" width="800" height="500"&gt;&lt;/iframe&gt;

&lt;p&gt;At February's &lt;a href="https://community.mindstone.com/events/mindstone-lisbon-february-ai-meetup" target="_blank" rel="noopener noreferrer"&gt;Mindstone AI Lisbon Meetup&lt;/a&gt; I show how you easy it is to carry out a phishing attack against an AI agent. We &lt;a href="https://drive.google.com/file/d/1O6gynFHtquZQ4cEybfeqiMNP_Yob0fnK/view?usp=drive_link" target="_blank" rel="noopener noreferrer"&gt;live demoed the attack&lt;/a&gt; on stage successfully against an agent powered by GPT 5.2 and equipped with almost no tools, all in just a few minutes. Using a flagship model won't save you from data exfiltration if you don't take additional steps to secure your agent!&lt;/p&gt;
&lt;p&gt;&lt;img alt="" src="/talks/2026-02-25-mindstone-lisbon-meetup/room.jpeg" /&gt;&lt;/p&gt;</description></item><item><title>How does LLM memory work?</title><link>https://www.zansara.dev/posts/2026-02-04-how-does-llm-memory-work/</link><pubDate>Wed, 04 Feb 2026 00:00:00 +0000</pubDate><guid>https://www.zansara.dev/posts/2026-02-04-how-does-llm-memory-work/</guid><description>&lt;hr /&gt;
&lt;p&gt;&lt;em&gt;This is episode 6 of a series of shorter blog posts answering questions I received during the course of my work. They discuss common misconceptions and doubts about various generative AI technologies. You can find the whole series here: &lt;a href="/series/practical-questions"&gt;Practical Questions&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;
&lt;hr /&gt;
&lt;p&gt;People often talk about an LLM "remembering" (or more often "forgetting") things. But how is that possible? LLMs are stateless algorithms that don't inherently have the ability to "remember" anything they see after their training is over. They don't have anything like databases, caches, logs. At inference time, LLMs produce the next token based only on its trained parameters and whatever text you include in the current request.&lt;/p&gt;
&lt;p&gt;So what is "memory" in the context of LLM inference?&lt;/p&gt;
&lt;h2&gt;The chat history&lt;/h2&gt;
&lt;p&gt;When you're having a conversation with an LLM, the LLM does not remember what you've said in your previous messages. Every time it needs to generate a new token it &lt;strong&gt;re-reads everything&lt;/strong&gt; that happened in the conversation so far, plus everything it has generated up to that point, to be able to decide what's the most likely next token. LLMs don't have any internal state: everything is recomputed from scratch for each output token.&lt;/p&gt;
&lt;div class="notice info"&gt;

&lt;p&gt;💡 Methods exist to reduce the time complexity of LLM inference, mostly in the form of smart caching techniques (usually called &lt;a href="/posts/2025-10-17-prompt-caching/"&gt;prompt caching&lt;/a&gt;), but that's a story &lt;a href="/posts/2025-10-23-kv-caching/"&gt;for another blog post&lt;/a&gt;.&lt;/p&gt;

&lt;/div&gt;

&lt;p&gt;This means that the chat history is not part of the LLM, but it's &lt;strong&gt;managed by the application built on top of it&lt;/strong&gt;. It's the app's responsibility to store the chat history across turns and send it back to the LLM each time the user adds a new message to it. &lt;/p&gt;
&lt;p&gt;&lt;img alt="" src="/posts/2026-02-04-how-does-llm-memory-work/naive-chat-history-inv.png"  class="invertible" /&gt;&lt;/p&gt;
&lt;p&gt;The storage of the chat history is the simplest implementation of what "memory" means for an LLM. We can call it &lt;strong&gt;short-term memory&lt;/strong&gt; and it allows the LLM to have a coherent conversation for many turns.&lt;/p&gt;
&lt;p&gt;However, this approach has a limit: the length of the conversation.&lt;/p&gt;
&lt;h2&gt;The context window&lt;/h2&gt;
&lt;p&gt;LLMs can only process a fixed maximum amount of text at once. This limit is called &lt;strong&gt;context window&lt;/strong&gt; and includes both the user's input (which in turn includes all the chat history up to that point) plus the output tokens the LLM is generating. This is an unavoidable limitation of the architecture of Transformer-based LLMs (which includes all the LLMs you're likely to ever come across). &lt;/p&gt;
&lt;p&gt;So, what happens when the context window fills up? In short, the &lt;strong&gt;LLM will crash&lt;/strong&gt;. &lt;/p&gt;
&lt;p&gt;To prevent a hard system crash, various LLM applications handle context window overflows differently. The two most basic approaches are:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;Hard failure (common in APIs):&lt;/strong&gt; If you exceed the model’s context window, the request fails.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Truncation/sliding window (common in chat apps):&lt;/strong&gt; The application drops older parts of the conversation so the latest turns fit. This means that for each new token you or the LLM are adding to the chat, an older token disappears from the history, and the LLM "forgets" it. In practice, during a conversation this may look like the LLM forgetting older topics of conversation, or losing sight of its original goal, or forgetting the system prompt and other custom instruction you might have given at the start of the chat.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;&lt;img alt="" src="/posts/2026-02-04-how-does-llm-memory-work/context-window-overflow-inv.png"  class="invertible" /&gt;&lt;/p&gt;
&lt;p&gt;However, both of these are just patches over the fundamental problem that LLMs can't remember more than the content of their context window. How do we get around that to achieve long-term memory?&lt;/p&gt;
&lt;h2&gt;LLM memory is context engineering&lt;/h2&gt;
&lt;p&gt;Making LLMs able to remember very long conversations is a &lt;strong&gt;context engineering&lt;/strong&gt; problem: the science of choosing what to put in the LLM's context window at each inference pass. The context window is a limited resource, and the best LLMs applications out there usually shine due to their superior approach to context engineering. The more you can compress the right information into the smallest possible context, the faster, better and cheaper your AI system will be.&lt;/p&gt;
&lt;p&gt;In the case of long-term memory, the core of the problem is choosing what to remember and how to make it fit into the context window. There are three common approaches: &lt;strong&gt;summarization&lt;/strong&gt;, &lt;strong&gt;scratchpad/state&lt;/strong&gt;, and &lt;strong&gt;RAG&lt;/strong&gt;. These are not mutually exclusive, you can mix and match them as needed.&lt;/p&gt;
&lt;h3&gt;Summarization&lt;/h3&gt;
&lt;p&gt;In the case of summarization-style memory, the idea is to "compress the past" to make it fit the context window. You keep recent messages verbatim, but you also maintain a rolling summary of older conversations and/or older messages in the same conversation. When the chat gets long, you update the summary and discard raw older turns.&lt;/p&gt;
&lt;p&gt;This is a pragmatic fit for simple chatbots: most users don't expect perfect recall, but are happy with an LLM that sort of remembers a summary of what they talked about in the past. It's also rather cheap and very simple to implement, which makes it a perfect fit for a quick, initial implementation.&lt;/p&gt;
&lt;p&gt;The main issue with summarization memory is that LLMs often don't know what details must be remembered and what can be discarded, so they're likely to forget some important details and this might frustrate the users. &lt;/p&gt;
&lt;p&gt;In short, summarization memory achieves something very like human memory: infinitely compressible but likely to lose details in arbitrary ways. This works for role-playing chatbots for example, but not for personal assistants that are supposed to remember everything perfectly.&lt;/p&gt;
&lt;p&gt;&lt;img alt="" src="/posts/2026-02-04-how-does-llm-memory-work/summarization-memory-inv.png"  class="invertible" /&gt;&lt;/p&gt;
&lt;h3&gt;Scratchpad&lt;/h3&gt;
&lt;p&gt;In order to overcome the fallacies of human memory, people use post-its and notebooks to store important details that can't be forgotten. Turns out that LLMs can do this too! This is called &lt;strong&gt;scratchpad / state&lt;/strong&gt; approach and means that the LLM is now in charge of maintaining a small, structured "state" that represents what the assistant should not forget, such as user preferences current goals, open tasks, todo lists, key decisions, definitions and terminology agreed upon, and more.&lt;/p&gt;
&lt;p&gt;This approach can be implemented in two ways:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;by giving a scratchpad tool to the LLMs, where the model can choose to write, edit or delete its content at all times,&lt;/li&gt;
&lt;li&gt;by having a separate LLM regularly review the conversation and populate the scratchpad.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;In either case, the scratchpad content is then added to the conversation history (for example in the system prompt or in other dedicated sections) and older conversation messages are dropped.&lt;/p&gt;
&lt;p&gt;This approach is far more controllable than summaries, because the LLM can be instructed carefully as of what it's critical to remember and how to save it into the scratchpad. Not only, but the users themselves can be allowed to read and edit the scratchpad to check what the LLM remembers, add more information, or even correct errors.&lt;/p&gt;
&lt;p&gt;&lt;img alt="" src="/posts/2026-02-04-how-does-llm-memory-work/scratchpad-memory-inv.png"  class="invertible" /&gt;&lt;/p&gt;
&lt;h3&gt;RAG Memory&lt;/h3&gt;
&lt;p&gt;But what if the scratchpad becomes itself huge and occupies a large share of the context window, or even overflows it? For agents that need to take on huge tasks (for example coding agents and deep research systems) the scratchpad approach might not be enough. &lt;/p&gt;
&lt;p&gt;In this case we can start to treat memory as yet another data source and perform RAG over the scratchpad and/or the conversation history, stored in a vector DB and indexed regularly.&lt;/p&gt;
&lt;p&gt;The advantage of RAG memory is that you can reuse all well-known patterns for RAG, with the only difference that the content to be retrieved is the chat history itself and/or the LLM's notes. &lt;/p&gt;
&lt;p&gt;However, RAG memory suffers from the shortcomings of retrieval: as the retrieval pipeline is never absolutely perfect, you can't expect perfect recall. You'll have to pay attention to the quality of the memory retrieval, evaluate it carefully and regularly, and so on. This adds a new dimension to your agent's evaluation and in general quite a bit of complexity.&lt;/p&gt;
&lt;p&gt;In addition, you may run into an additional problem that's unique to RAG memory: &lt;strong&gt;context stuffing&lt;/strong&gt;. Context stuffing is the presence of retrieved snippets of context that look like prompts: they can cause problems because they might confuse the LLM into following the instruction contained in the retrieved snippet instead of the user's instruction. &lt;/p&gt;
&lt;p&gt;While context stuffing can happen with malicious context snippets in regular RAG, it's also very likely to happen accidentally when implementing RAG-based memory that searches directly into the chat history. This happens because all the retrieved snippets were indeed user's prompts in the past! In this case, it's essential to make sure that the prompt identifies clearly the retrieved snippets as context and not prompts.&lt;/p&gt;
&lt;p&gt;&lt;img alt="" src="/posts/2026-02-04-how-does-llm-memory-work/rag-memory-inv.png"  class="invertible" /&gt;&lt;/p&gt;
&lt;h2&gt;Conclusion&lt;/h2&gt;
&lt;p&gt;That's it! With any of these three approaches, your LLM-base application is now able to remember things long-term.&lt;/p&gt;
&lt;p&gt;However, don't forget that the moment when you add memory to your LLM powered application, you're now &lt;strong&gt;storing user data&lt;/strong&gt;, with all the problems that this brings. You will need to take care of retention, user control over the memorized data, you'll be storing PII and secrets, and in many cases this process needs to be compliant to whatever policy for data retention you may be subject to.&lt;/p&gt;</description></item></channel></rss>