· 3 min read
Scaling coding agents, part 4: shared memory, and its bill
One self-hosted memory for agents on every machine. In four days it spent $400, and in three weeks it wrote 175,000 memories. What I changed.
Agents on several machines don’t share what they learned. Claude Code’s own memory stays on one machine and one account. So I turned it off and self-hosted Hindsight on the Unraid server from part 3. Every session on every machine now saves into one memory bank per repo, and the sync from part 2 installs the plugin everywhere.
How it works
- Save. After each agent reply, the plugin sends the conversation to the server. A model extracts facts from it.
- Consolidate. A second pass merges those facts into observations.
- Pages. Each repo gets five knowledge pages, such as key decisions and conventions, plus topic pages. A model rewrites them as memories arrive.
- Recall. A new session searches the pages first. That takes 0.1 seconds.
Then two things went wrong.
$400 in four days
My agents run around the clock on five machines. Four days after I pointed Hindsight at an Anthropic API key, it had spent about $400 and run the key out of credit twice. The models weren’t fancy: Haiku for saving and consolidating, Sonnet only for the pages.
Three days of jobs explain it:
- 1,751 saves. Each one sends the whole conversation so far, again, after every reply.
- 916 consolidations.
- 680 page rewrites. The server checked 84 pages every hour and rewrote the busy ones almost every time, on Sonnet. That was about half the bill.
The fix: pages refresh once a day, and only if something new arrived. Haiku does everything.

Since then it costs between $14 and $24 a day, about $19 on average. That is roughly five times less than before. It is also still more than $550 a month, for memory alone.
194,000 characters on one page
Nineteen days in, the server holds 175,631 memories. Finisher, my video editor, has 108,478 of them. Plainpost, my email client, has 47,487. Two projects produced almost all of them.
The pages grew with the memories. One “Key decisions” page reached 194,000 characters. Hindsight caps a page at 4,096 tokens, about 16,000 characters, but routine updates ignored the cap. A page that size is useless to an agent, and every refresh reads all of it back in, which is where much of the money went.
A full rebuild from the memories cut that page to 10,600 characters. All pages now get one every Sunday, and the 22 that were over 16,000 characters were rebuilt once by hand.
What I’d set on day one
- One cheap model for every step.
- Pages: refresh daily, rebuild weekly, and check their size.
- A separate API key with a spending limit. The limit is what stopped mine.
- Memory and CPU limits on the container.