Context Rot in LLMs Building Resilient AI Agents
- Published:
- Length: 12:51
- Channel: Eugene Vyborov
- Video: https://www.youtube.com/watch?v=wIz9X-csrs4
- YouTube video id: wIz9X-csrs4
Description on YouTube
Understanding Context Rot in Large Language Models Deep Research and Links: https://docs.google.com/document/d/1pEtinLUzIHwKPmckX54htNn6WXHMpu2PvJ59bzogTLc/edit?usp=sharing In this video, Eugene, CEO and founder of Ability AI, discusses the concept of 'context rot' in large language models (LLMs). He explains how LLMs like GPT-4, Claude, and Gemini do not perform uniformly across their entire context window, leading to degradation in performance as the context increases. Eugene highlights the importance of context engineering, relevant data input, and modular architectures to manage this issue. He also shares insights from his personal experiences and research, offering practical solutions for enhancing AI agents' efficiency. Stay tuned to learn more about context management and improving AI-driven results. 00:00 Introduction to Context Rot 00:24 Understanding Context Rot in LLMs 01:48 Performance Degradation in LLMs 03:22 Main Causes of Context Failures 05:43 Model-Specific Observations 09:30 Strategies to Mitigate Context Rot 11:28 Future Directions and Conclusion 12:19 About the Creator
Full transcript
[0:01]Hey guys. So I want to talk to you about something quite interesting today. Specifically about the concept of the context rot. That's a relatively novel thing to me at the very least. I heard about that maybe a few months ago, but I kind of felt it inside me for all this all this time. And if you haven't heard of that or haven't dug into that, stay because it's going to be interesting. So basically look the the the whole concept of the context rod is the fact that the LLMs are not performing equally across the entire context window. And I am
[0:34]pretty sure that you know what I'm talking about that you kind of expect the same from the same model. You expect that say GPT5 is going to be as smart as GPT5 is. But actually it is not the case in the beginning when you have no context when the window is kind of small and later when you talk to it for a long time. It is especially noticeable in the coding environments when you have to work with building software because those agents like cloud code or corso or others when you work with them they grow the context and you can see how it's
[1:08]kind of exploding in size over time and you can clearly notice that at some point models become dumber they get confused and most importantly they get confused in different ways. So it's not the same for every model. It's almost like different people and yeah actually this way you're kind of developing this nuanced preferences to different models for different kind of tasks. So basically what I'm saying is those declarations from the companies that hey we have 1 million token window etc.
[1:41]They're actually I think less important than models ability to stay coherent as the context grows because if we look at this data here on the slide we can see that the like if we take some tasks and give it to LLMs with a short prompt they have very high resolution percentage but as we increase the size of the prompt that actually drops and it's not as simple it just gives you like a feel and this is the numbers that I was able to find but some research search even says that for like Gemini 5 or something like
[2:13]that, the effective talking or Gemini 4, I apologize, the effective talking window is actually actually 64K rather than 128K, which is like, you know, half the size and it's not not really cool. And I mean, I can definitely confirm from personal experience that this is the case. And that's one of the things that you kind of develop as you work a lot with AI. This feel of where how the behavior of a model changes and an agent as well depending on how big is the size of the window that you're using.
[2:49]There's also a number for the reasoning degradation for the complex reasoning which is you know some say 3,000 tokens. And by the way, in terms of the sources of the data, I did the research with Google deep research and we kind of put together this presentation. I will attach that to the YouTube video with a whole bunch of links to read about that. It was mostly most recent information and mostly from the researchers. So this data I think should be trustable, but I'm not going to go and verify every number. If you want to there's all the links are over there.
[3:23]Now there are three main ways in which the context fails. I think there are more ways that are subtle and we don't see them but these are kind of the main ones. So the Uturn or U- shape kind of change in the quality of attention towards data within the window which means that if you send it a big chunk of text by design the transformers that are behind the LLMs basically it's a machine learning model there. designed to pay a special attention to the beginning and to the end of the prompt and what is in the
[3:57]middle can be lost or misinterpreted. Now the second one is if we're talking about semantically similar but irrelevant information. So basically if you throw a lot of random stuff into LLM hoping that it may might have some nuggets over there to help you you know resolve your problem often times that results in a degradation of performance and you know some models just completely go crazy and that actually means and it's an important point I believe that look if you if you think that you just need to send as much data as possible to
[4:31]LLM and that will allow it to make a higher quality decision that's not going to work. You need to send high signal information, high quality information to the LLM. That's more important than sending a whole ton of information. And another way in which this whole thing breaks is when they start being weird. I mean the models themselves like GPTs and and I observed that very much with GPT family, they just become confidently wrong. They're just like absolutely confidently saying that, you
[5:04]know, they're convinced that their solution is correct, but in fact, it goes further and further from being correct and it's just a form of a hallucination. And yeah, with the clo models, people report that they refuse to answer. I personally haven't run into that. I have run into when clothed models in Corser or in CL code start to do things without confirming with me. basically they're like more biased to act to call the tools rather than to at least inform of what's happening and that also usually happens on the large
[5:38]kind of context scenarios right that's an interesting slide with the performance comparison and this data is something that Gemini pulled from different kind of research I'm not convinced that all of it is correct but I can give you my kind of insights on where I think it works and where it So if we look at the GPT4 model because about GPT5 I we haven't found much of the resources but as I mentioned the effective context over there is half so 64k tokens it becomes overconfident and
[6:13]the degradation pattern is less predictable than with some of the other models it just goes up and down and it's harder to develop the feel for that. That's that's what I would say for the claude models and over here we're mostly talking about previous claude not the 4.5 but 4.1 and I can tell you for sure absolutely convincingly that the degradation over there is slower and the main behavioral change that I'm personally seeing with claude is that it kind of starts to talk way too much. It's verbose on its
[6:48]own on its own right. And when I say talk too much, it doesn't mean like it specifically explains me too much. It means that usually it tends to create more stuff than I asked it for. It's like being overly helpful, overly caring. And yeah, in my mind, in terms of degradation, Claude family is probably the best. And in terms of my personal experience with them, when we talk about CL Claude Opus 4.1, which is my favorite model to work with, I I go to about 60% of the context window size confidently over that I start to expect
[7:22]problems. So it's very power it's incredibly powerful model, but this incredibly powerful model is also like a large language model. So it's prone to some deterioration over time over the context window size. Now cloet 4.5 is my second model that I'm working with. It also degrades somewhere in the half of the context for me like 50 maybe 60% even less than oppus but for this model it means actually a lot of usable tokens because they have 1 million context window. So it's quite impressive. Now, Gemini 2.5, which was my formerly
[7:57]favorite model, and I kind of liked them a lot up until probably until Sonet 4.5, I think, maybe even until OPUS. But point is, it is more fragile and kind of degrades in performance more with the size of the context and with confusing context that it can receive. So it's like if the breadth of a task that it's working on is pretty wide and the context size is pretty big, it's just going to start completely losing its mind and you
[8:29]cannot trust it. GPT5 I find okayish in context management. But to be fair, I didn't have much experience with that because I seriously didn't don't like GPT5 for gentic encoding tasks in comparison to you know claude whether it's Opus or or Sonnet. Somehow for me it worked out not never never better than those two models that I mentioned. Now there was some sort of quant quantitative research which I I think I already mentioned to you so I would not
[9:03]repeat that but important numbers is that I guess roughly in the middle of the context you should start worrying about the model degradation and you know it can vary in a way it degrades and when it degrades and how much it degrades based on each individual model but that's more of a field that you develop for for a specific speific model. What else? Yeah. So that brings us to what to do about that and what to do about that. That is pretty obvious that
[9:35]the context engineering is critical and you need to make sure that you are giving your LLMs relevant information especially in the Gentic solution and not too much of this information because again giving it too much will result in worse results even if the information is kind of relevant. Also, the size of the window that they declare matters a lot less than you might think. And yeah, that's that's a tough one that we'll keep solving that as we go. Obviously, you should use some sort of external
[10:08]memory. And there's I I talked a lot about that in my agents course and in the different ways you can organize this memory and set up to make those agents effective. You can use the sub aent architecture which is something that claude introduced in the cloud quad recently and it's a pretty powerful tool and it's powerful for the most part because it allows to focus agents on specific kind of vertical tasks which allows to limit the context that they're working with and you know it added over here G context controller but I I I saw the research paper about that it's
[10:42]basically relatively novel memory approach that works with git but I haven't tested that so I don't know what what it's going to be you know how it's going to be working or functioning right so forget about the infinite context embrace modular architecture in terms of having sub agents that are limited in responsibilities and in context implement a proper context management and test things against the real world scenarios because in your test scenarios the amount of information and the kind of information that ends up
[11:15]in your context it's not necess necessarily correct and yeah it can just degrade your system can degrade in the actual production usages if you have too big of a difference between those two things and in terms of what's going to happen in the future and how we're going to handle this scenario a few thoughts is that the the guys are developing across the world different architectures for for the models that are attentionfree and to be honest I don't know much about them but that's one of the problems that they're trying to solve really then I I'm pretty sure that entropic and
[11:49]open AI they're all working on more effective ways of degradation or no that's not not the right word but you get what I mean more effective ways of managing degradations within the large language models themselves so I think they going to they are making progress clearly as evidenced by sonet 4.5 and the long-term vision is basically well use better memory systems and manage the quality of the context that you're sending I Hope this was useful and have a wonderful day. Cheers. Hey guys, my name is Eugene. I'm a CEO
[12:23]and founder of Ability AI where we build artificial intelligence agents for business process automation. And also on this channel, I talk about building those agents and technologies around them as well as I make educational materials courses on Udemy to get you guys up to speed on how to build agents and take advantage of this AI revolution. So, subscribe to the channel and hope to see you in our communities and in my courses. Bye-bye.