Found a way to fix Agent Zero slowing down / VRAM crashing over time (without breaking the core container) #1544
zayzay109
started this conversation in
Show and tell
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Hey everyone. I'm still somewhat new to this side of the AI world and learning as I go, but I ran into a massive wall with Agent Zero lately that I managed to fix without deleting any data.
I’ve been running AZ heavily for a few weeks, and recently the web UI started freezing up on boot, hanging, and taking 15+ seconds just to load the sidebar.
It turns out, Agent Zero's frontend tries to render the metadata of every single
.jsonfile sitting in your/a0/data/api/chats/directory simultaneously. When I checked mine, I had hundreds of thick chats causing over 100 million tokens of JSON data to hit the DOM. The UI was essentially choking on weeks of old context it didn't even need to be rendering visibly.I definitely didn't want to "monkey patch" or hack the core Agent Zero UI code because I want my container to survive future updates safely, and I absolutely did not want to lose my actual chat history.
The Fix: Visual Archiving
If you check the official Agent Zero Plugin Hub, there is a very popular UI plugin available to everyone called Chat Archive. Many of you are probably already using it! (Note: It's not a miraculous find for me, just one of the common plugins available. A second popular one we use for other workflows is the YouTube Transcriber.) When installed, Chat Archive hijacks the frontend data store and strips "archived" chats from the DOM before they render, natively stopping the UI bleed.
To automate it, I wrote a standalone Python script to act as a background janitor. It groups your chats by age and silently injects the old ones into the plugin's hidden database.
How it works seamlessly:
The Script
If you want to use it, grab the plugin from the link above, and then drop this Python file anywhere inside your container (I put mine at
/a0/usr/scripts/context_pruner.py):Automating it
Once I saw it was safe, I tossed it into my cron jobs so I never have to think about it again. If you open your
/a0/usr/crontab.savefile, you can add this line at the bottom to make it sweep out old chats every hour:Hopefully, this helps out anyone else who has been struggling with mysterious UI lag after running the agent for a while! Your disk won't magically be emptied, but your browser will take a massive sigh of relief. Let me know if you guys have better ways of doing this, I'm always trying to learn.
All reactions