In this lesson, you will add caching to your Wikipedia analysis app, but more importantly, you will learn how to get back on the happy path with the AI agent that does something slightly unexpected or unintended. Let's dive in. So, here's where we were at the end of the last lesson. We built all of our frequency analysis. But one thing I want to add before I start building the rest of my application is some caching, because it did take quite a bit of time to actually go through the hundreds of pages that corresponded to large language models. So I just want the results to be cached. If I'm using the same input. So as I'm changing the rest part of my applications, there's no issues. So to do this I'm going to use this prompt. Create a local cache so we aren't rerunning retrieval logic. Same category exactly what we just mentioned. Let's see what Cascade does. Great. Seems like Cascade made multiple edits. I can use the Cascade bar to actually go through from diff to diff, and read through and understand the code changes. Let's run this. Of course, the first time that runs actually has to go through each of the files again. Let's look through the cache. Okay. Seems like it didn't really do exactly what I wanted it to do. All it did was it figured out what the page IDs were for each of the different pages. That's not actually what I wanted. I wanted to cache all the results of my script. And if I actually go back up to my query, you'll see that I was a little bit vague with this, right? Technically, it is caching something about the page results for that category, but not what I really wanted. I want the cached results of the overall processing of this script. And so there's a couple things that I could do from here. Even if I have accepted all the changes in the file, there's still two things we could do. We could either go into Cascade and ask Cascade to walk back all the changes, and then try to make some new edits and try to fix it, and maybe get ourselves in a little bit of a mess. Or we could use a handy functionality where if you hover over a message, you can revert to the step, and what this revert will do is it will revert the whole conversation history, and it will revert any of the changes that were made to files throughout the process. So if I click revert. All the caching logic in the wiki category analysis file went away. So that essentially can help keep your conversation history very clean and not have a whole lot of back-and-forth trying to unstick the agent, which might just confuse it later on as it's using that as context in its future conversations. So reverting is a really helpful functionality to get yourself unstuck. So let me delete this cache. We don't need it anymore. And let's change this prompt a little to be a little bit more specific to what I want it to do. So now I'm very clear that I want a local cache of the scripts results. And I just don't want to rerun that. Even the processing logic again for the same category. Right. First, it wants me to create the cache directory. That's fine. All right. So some changes were made. Let's try it out. Again, it'll first have to go through all the different files for the first pass. Let's look at what the cache looks like now. Great. The cache actually has exactly what I wanted to have, which was the results of the script. So if I write it again, though, the results come significantly quicker. So, in this we were able to build some caching logic. Again, I can use a Cascade bar to actually look through all the changes. Make sure that everything actually is what I expect it to be, and that I understand the code and accept it at the individual block level. I can accept it at the file level. But more importantly, in this lesson, you learned how you can unstick yourself when the AI does something you kind of don't expect it to do. So use that well to keep a really healthy conversation history between you and your AI pair programmer. In the next lesson, we're going to take all of this work that we've done and make it visual by adding a front end to expose all of these results in these frequencies in a pretty matter. See you there.