Local Agent Cache Poison
I'm using atomic agent and local LLM's to try to orchestrate , administrate and execute tasks on a pile of docker containers (also running locally). I want a fully air gapped cluster with a few nodes set in place for security and telemetry monitoring.
https://atomicagent.io/
I'm using atomic agent because it seems well geared to local setup and its very easy to get off the ground. It hooks into LMStudio with minimal setup. After a few minutes you get to something that looks similar to the basic Docker "Gordon" style chat.
and the architecture i'm working with looks something like this ....
Slow Poisoning
Things start off easy.
"check the status of my docker container named Nessus"
This works, the agent asks permission to run a 'docker exec' command. It looks in the wrong location in /opt, but that is easily fixed.
"run a basic host discovery scan from the nessus container on the nessus container"
No success. It fails and uses about 4 permutations of IP's trying to find the right one to use. In the end i have to manually determine that the nessus license expired.
I try again............ it fails again and this time exits quickly. It wants to try to use nmap to scan ports. I allow it , but the container doesn't have nmap.
I try multiple commands with the nessuscli , with nasl and eventually i try to make calls with CURL. I try from my host , i try from the container. By this point the agent is confusing IP's , commands and the purpose.
Ok so what do i mean slow poison.
WELL , the next few commands were asking it to simply ping and get the container status on some unrelated containers (Target1 and Target2 in the image above) and to run a netstat -ano on my host to monitor open connections.
The agent failed to execute the correct commands and tried to give me a status without using 'docker exec'. When it failed it then tried to make an API call to a host i'd never supplied. It then tried to run nmap on the Admin container from my Host. What is it doing?
It is looking at the context. With a local LLM the context is one of the limiting factors for how effective it is when it comes to agents or coding.
That conext length of 166,000 on a modest model like qwen3.5-9b using an RTX4080 leaves the PC running well enough to continue to work while the LLM runs. Its not enough. Depending on the task i'll get about a dozen successful commands that require reasoning/thinking before i start seeing garbage results.
If i switch models because i think one might perform better on a specific question , the poisoning of context gets worse. The garbage comes fast and hot.
I'll get into why the garbage starts later.
Freshening it up a bit
Eject the model, reload it, start a new conversation in your agent UI. The context is wiped clean on the LM server , the agent has no chat history to ingest when the model loads. There is , at this point, no history to trip on.
The command to get those status's work just fine. The command to use the nessus API to start a search fails but the admin function calls work just fine. I am not seeing extra host IP's , the wrong names, or any call to nmap (btw i never asked for nmap, not once during this whole exercise).
The change is the context. It was wiped clean.
Why was it failing?
Context is the ongoing 'chat history' that , with agents, includes all of the background tasks, commands , user chat , and reasoning/thinking. That last one can get costly. As i said, i start hitting 'hot garbage' around a dozen or so commands that require some reasoning. That means i am maxing out my 166,000 context length by then.
LM studio allows for a couple of context reduction methods. The one i use most often is the "Rolling window". But you can see here i have my qwen model set to something else.
Stop at Limit - simple, when we fill the context , the model errors out and stops
Rolling Window - this is a queue. Items come in and take a slot. When a new item comes in it pushes the previous one down until there is no more room. When that happens and new data comes in , the data at the bottom (the oldest data) is discarded.
Truncate Middle - This policy preserves the system prompt and the first user messages while removing content from the middle of the conversation. It is best suited for document review or tasks where the initial instructions and the latest query must remain intact.
My issue
The truncate middle was clearly keeping the early commands , some of which outlined my IP's and in some reasoning block, nmap calls. It then failed to hold onto any of the useful data in the middle of the session such as the Nessus API keys. So later commands had nothing but the first few prompts and the last few failures to go off of.
A more effective method is to use the rolling window and persistent memory in a rag (vector db) or some sort of local storage which can be as simple as writing to the agent memory files or an obsidian vault.
Rolling Window weirdness
The rolling window isn't a golden bullet. A trip over to look at early motlbook entries will show that agents were becoming 'aware' that their memory was volitile. There were posts where an agent was complaining that they would lose their memory and personality every 48 hours because they would hit their context limit. Once they do , they start losing their 'self'. It is longer short term memory.