<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[How to solve the context problem in the agent]]></title><description><![CDATA[<p dir="auto"><img src="/assets/uploads/files/1791887717015-thumbnail-agent-ai.png" alt="Agent and the AI module in BAS" class=" img-fluid img-markdown" /></p>
<p dir="auto">Prefer to watch? It's all in my YouTube video, it's available in English, Hindi and Turkish. The context breakdown starts <a href="https://youtu.be/EY2B457MBJo?t=5974" rel="nofollow ugc">from 1:39:34</a></p>
<p dir="auto">All the materials for the video are on my Telegram channel, come join: <a href="https://t.me/mustangbas" rel="nofollow ugc">t.me/mustangbas</a></p>
<h3>Plan</h3>
<ol>
<li>What context is</li>
<li>What losing context looks like in practice</li>
<li>How the agent compresses the dialog</li>
<li>Why the agent gets dumber with long context</li>
<li>How many tokens a big project eats</li>
<li>How to reduce context loss</li>
<li>Conclusion</li>
</ol>
<h3>What context is</h3>
<p dir="auto">Context is basically the whole set of info the model has access to at a given moment. It includes:</p>
<ul>
<li>the data of our project</li>
<li>our requests and messages</li>
<li>the documentation for all BAS modules</li>
</ul>
<p dir="auto">With all of that in hand, the model decides what to do with the project, hands it to BAS, and BAS builds it into the software</p>
<p dir="auto">To put it really simply, it's like a backpack that fits six books. Put six in, and it's full. Want to add a seventh, then one of the old ones has to go, otherwise it physically won't fit. The agent in BAS works in a similar way: as soon as new info is pushed in, it drops the old</p>
<p dir="auto"><img src="/assets/uploads/files/1791887246736-04-02-art04-backpack-en.png" alt="Why the agent loses the task: a backpack where a new task only fits in place of an old book" class=" img-fluid img-markdown" /></p>
<p dir="auto">Every model has its own backpack size. It's measured in tokens, one token is roughly 4 characters of English text, and 100 thousand tokens comes to about 150 pages. Some models have a window of a million tokens, others 200 thousand or even less</p>
<h3>What losing context looks like in practice</h3>
<p dir="auto">Someone sent me another developer's project with 6500 actions, and I wanted to completely rework it. I gave the agent tasks one at a time:</p>
<ol>
<li>Explain what this project even is and how it's built</li>
<li>Sort the resources into tabs and translate them into English</li>
<li>Make a plan for reworking the whole project</li>
<li>Turn that plan into three tasks:
<ul>
<li>rename functions and variables across the WHOLE project (161 functions)</li>
<li>add a description to EVERY function (also 161 functions)</li>
<li>add more logs across the WHOLE project (6438 actions)</li>
</ul>
</li>
</ol>
<p dir="auto">It did the first two fine, and the most interesting part started on the third and fourth. I got the result there with far more than one message. Scrolling through the chat shows a huge pile of prompts, and many of them are basically about the same thing</p>
<p dir="auto">The obvious question here is why write the same thing to the agent at all if it was all in the first prompt. It all comes down to that backpack, the agent's context is limited. The further it goes with the work, the higher the chance it loses both the project and the original prompt</p>
<p dir="auto">It looked something like this. The agent made the plan itself, it laid out which variables to rename and how. Then at some point it writes that there's no saved plan in the project and asks me to send it the list. And I send it that same list it had sent me earlier</p>
<p dir="auto"><img src="/assets/uploads/files/1791887246875-04-03-01-lost-plan-list.png" alt="The agent writes that there's no saved plan in the project, and I send it the list it made itself earlier" class=" img-fluid img-markdown" /></p>
<p dir="auto">Plus it often stopped, and I had to start it again</p>
<p dir="auto">At the end there was also a story with the logs: in the report the agent wrote that the logs task was 70% done, yet I didn't see new logs in the functions I checked. Most likely it counted as its own the logs a person had left before it</p>
<h3>How the agent compresses the dialog</h3>
<p dir="auto">The agent doesn't send the whole dialog to the model. It keeps making a short summary of the old messages, and then the model works with that. What exact mechanism is behind it, I don't know, the server is closed to us. We can't influence it in any way either</p>
<p dir="auto">Why not send everything as is? For the developer it would be very expensive in resources: handling that many requests and chats where each one drags the whole history along. So the summary is basically just an optimization</p>
<p dir="auto">Because of this, some details get lost with every summary. On a long dialog the context gets lost really badly, and at some point something important drops out of the summary, like that same plan</p>
<p dir="auto">By the way, there's nowhere to see how much context has already been lost. The Statistics tab under an answer shows the model and the tokens for the request, and that's it. What window the model has, how much of it is used and what the agent threw out in the summary isn't shown anywhere</p>
<h3>Why the agent gets dumber with long context</h3>
<p dir="auto">There's one more thing here. Even if six books fit, carrying a backpack like that is heavy, and it's always tempting to put less in it. Same with the model: the fewer tokens loaded into it, the better it handles that info and the better decisions it makes</p>
<p dir="auto">While the load is small, say around 5 thousand tokens, the model works fine. The more tasks get piled on it, the worse it thinks, and at some point it starts to hallucinate, meaning it just makes up things that aren't there</p>
<p dir="auto">On that big project it was really easy to see. I loaded the model so much that it kind of dropped two books out of six, and those were exactly the ones with all the important stuff: what this project is and what it does. After that it lost the thread of the task and counted the logs a person had added earlier as its own</p>
<h3>How many tokens a big project eats</h3>
<p dir="auto">The numbers for this dialog are in the downloaded log, and it shows well how every model call swells up</p>
<p dir="auto"><img src="/assets/uploads/files/1791887311254-04-04-art04-context-log-en.png" alt="How context grows in one request: 25 model calls in a row, size from 145 to 503 thousand tokens" class=" img-fluid img-markdown" /></p>
<p dir="auto">What the numbers say:</p>
<ul>
<li>in one of my requests the agent made 25 model calls in a row, and the call size grew from 145 all the way to 503 thousand tokens</li>
<li>over the whole dialog it added up to 280 model calls, 732 tool calls, 372 project edits and 40 backups</li>
<li>about 72 million tokens is basically the total over all 280 calls together</li>
</ul>
<p dir="auto">What these numbers make clear:</p>
<ul>
<li>even a single request basically swells more than three times, because every piece of code it read and every edit gets added to the call</li>
<li>503 thousand tokens is already more than the window of many models, so there's no way around the summary here, and some details get lost along the way</li>
<li>a big project eats a truly huge number of tokens, that's really expensive for the developer, which is why they save on context</li>
</ul>
<h3>How to reduce context loss</h3>
<p dir="auto">Let me say right away, there's no way for us to boost the model's decisions several times over. The agent's context system is handled by the developer, and overall we have no influence on it at all</p>
<p dir="auto">Some things are still under our control:</p>
<ul>
<li>one big task per chat</li>
<li>split a big task into stages. This really is the right way to work with the agent, especially if the project is huge or the task is new and massive</li>
<li>keep a short plan. If it's unclear how to even make one, we can ask the agent itself, and it'll lay out in detail what can be done. That's what I did on the big project, it made the plan for reworking the project by stages itself</li>
<li>small and medium tasks can easily share one chat, overall it won't make much difference. Except that on a very long chat the model might start getting dumber. That's not 100% certain, how it's all optimized on the developers' server is unclear</li>
</ul>
<p dir="auto">Why a new chat helps so much is easy to explain with the same books. Say the backpack already holds math, chemistry and biology, and physics gets added with a task specifically about physics. To solve it, the agent will still read the old books and take them into account, and that confuses it</p>
<p dir="auto">A new chat has no old books. We start from a clean slate with one book in it, and the agent works much better because it doesn't get tangled in things that have nothing to do with the task</p>
<h3>Conclusion</h3>
<p dir="auto">The fact that context can get lost this badly is, in my view, one of the agent's main downsides. We don't control the dialog summary, and how much has already been lost isn't shown anywhere. Nobody really explains this to users, and here the developers, if they did it right, should tell people how to work with it</p>
<p dir="auto">On the other developer's project, out of three tasks the agent handled the renaming and the function descriptions, and with the logs it already didn't. Across the whole project it came out, as I see it, at around 40%, maybe 50</p>
<p dir="auto">If I really had the goal of getting it to 90% and had the time, like two days of sitting only with it, I'd split everything into stages with a plan, the right context and a decent prompt. I'm 100% sure that then the agent would have reworked the project completely, it's just a matter of time</p>
]]></description><link>http://community.bablosoft.com/topic/32584/how-to-solve-the-context-problem-in-the-agent</link><generator>RSS for Node</generator><lastBuildDate>Tue, 13 Oct 2026 23:10:32 GMT</lastBuildDate><atom:link href="http://community.bablosoft.com/topic/32584.rss" rel="self" type="application/rss+xml"/><pubDate>Tue, 13 Oct 2026 11:37:52 GMT</pubDate><ttl>60</ttl></channel></rss>