November 25, 2026 · 16 min read
My AI Agents Got a Memory and a Night Shift. Here Is What Broke First.
One morning in late November, two pull requests were waiting for me on this site’s repo. One converted nineteen German posts from the informal du to the formal Sie. The other fixed four small findings a code review had left behind. Neither was written by me. They were written overnight by Claude Code, on a mini-PC in my flat, from cards I had put on a task board the afternoon before. Each one came with a note saying what it had changed, which checks it had passed, and, for one of them, three questions it wanted me to decide. I read both, merged both (#65, #66), and that was my morning.
That moment took five weeks to build. It rests on four small, dull systems, each of which fixed one thing I had lost, and each of which broke in its own way before it worked.
What I lost when I turned off Hermes
On 18 October I turned off Hermes Agent and replaced it with a harness of fixed pipelines, one gated door to the models and an allowlist per job. I do not regret it. But I was honest in that post about the cost, and two items on that list kept bothering me.
The first was memory. Hermes remembered things across conversations. My new harness did not, and neither did the chat UI I use for quick questions. Every new chat started from zero, and so did every coding session.
The second was open-ended work. “Go and work out X on the box” was a normal request with Hermes. The harness runs a fixed list of jobs, and nothing else. My list of small tasks was not getting shorter, and nobody was picking any of them up.
I fixed the memory first, twice, because the first fix taught me why I needed a second one.
A search over my own notes
I keep an Obsidian vault. It started as notes and became the long-term memory of my coding agent: decisions, lessons, what I did on which day, which approach failed and why. It already held most of what a chat assistant would need to know about me. It just lived on my laptop.
So two days after Hermes went off, I built SuperBrain: a small server on the mini-PC that searches a copy of the vault and answers with the note it found. My Mac pushes the vault to it every hour, over a key that can only write into that one folder. The server is read-only, and it has no route to the internet. That last part mattered most to me. My notes are the most private thing on any of my machines, so the embeddings are computed on the box itself and never leave it.
Picking the embedding model was the first surprise. I expected the bigger model to win. On a twelve-question test against my own notes, Google’s small embeddinggemma-300m beat a Qwen3 embedding model with twice the parameters on recall, rebuilt the whole index in 16 minutes instead of 52, and used a quarter of the memory. I kept the bigger model on disk as a standby and have not needed it. Search is hybrid: plain keyword search and vector search, merged, because people search their own notes by exact words more often than they think.
SuperBrain is a tool I switch on per chat in chat.ashkmb.com, my self-hosted LibreChat. Most days I use it for three things. I ask what I decided about something weeks ago, and get the decision with a link to the note. I type “Daily” and the name of a workspace, and a small skill reads that day’s journal through SuperBrain and gives me my standup bullets. And I research things in chat, which brings me to the part I did not plan.
The chat that remembers itself
Research chats are worth keeping, but I never remember to copy anything out of them. So the harness now does it. Once an hour it looks for chats that have been quiet for a day. A cheap model throws out the obvious throwaways, writes a summary of the rest, and a sanitizer strips anything that looks like a key, an address or a work detail. A small classifier then answers one question about the summary: is this worth remembering? Kept summaries become a second source in SuperBrain, labelled as unreviewed, so a later chat can find what an earlier one worked out.
Calibrating it was a lesson in how literal machines are. Of my first twelve chats, one was clearly worth keeping: a comparison of Raspberry Pi alternatives. Another scored 0.90, comfortably above my cut-off of 0.85. It was a chat called “Memory Inquiry”, in which I had asked SuperBrain to look something up in my notes. The classifier was right that it was about memory. It was wrong that the memory was new: saving it would only store a copy of a note I already had. It dropped out once the criteria said so in plain words. For the cases the classifier gets wrong the other way, I tag a chat keep and it skips the judges.
SuperBrain solved memory for the chat. It did not solve it for my coding agents, and that is where it got harder.
Why one memory was not enough
My coding agent already read the vault, through a skill that searched and wrote notes. It worked, but it had two problems I could no longer ignore.
The first was cost. One run of that skill read between 300,000 and more than two million tokens, mostly cached, because finding the right note meant reading a lot of notes.
The second was worse. I work in four places that must never mix: my day job, my startup, my personal projects and a volunteer initiative. My vault knew all of them. Nothing stopped a session in my startup’s repo from recalling a detail from my day job, or from repeating it somewhere it did not belong. My rules said “don’t”. The model had to remember to obey them.
So on 1 November I built Treant, a memory server with walls. Every workspace gets its own schema in Postgres, with its own access token, and a token can only read and write its own workspace. Next to the walled workspaces sits a shared general area for know-how that is useful anywhere, something like “Bot Fight Mode can’t be skipped with WAF rules”. No token can write there directly.
The folder I am working in picks the workspace. When a session starts in my startup’s repo, it gets a short briefing from that workspace only. When it ends, the session is saved, scrubbed twice, and handed to a worker that distills it into facts and links between them: this repo uses that service, this decision replaced that one, this thread is still open. Distilling costs about two cents per saved session, on a cheap model, from a budget of three dollars per workspace per month. Nothing a session learns goes into general until a gate has checked it: rules first, for anything shaped like a ticket number, an IP address or an account ID, then a model that asks whether the fact would reveal anything about where it came from.
flowchart LR
vault["Obsidian vault<br/>my notes"] -->|hourly copy| sb["SuperBrain<br/>read-only search"]
sb --> chat["chat.ashkmb.com<br/>LibreChat"]
chat -->|kept chats,<br/>summarized| sb
code["Coding sessions<br/>on my Mac"] -->|brief at start,<br/>save at end| tr["Treant<br/>one wall per workspace"]
night["Night shift<br/>board cards"] -->|run journal| tr
tr -.->|next?| chat
The guard that asked too much
Treant came with a second idea: a guard that checks every shell command an agent wants to run, and asks me first if the command points somewhere that does not belong to the current workspace. A kubectl against a work cluster from a startup folder. A git push from a work repo to GitHub. A Terraform run in another workspace’s folder.
My first version asked about every target it did not recognise, and I switched it off the same day. In one startup session, every plain kubectl, helm and aws call prompted me, because the cluster my shell happened to point at was a work cluster. My note from that evening says the guard was “more blocker than helper”. A safety tool I turn off protects nothing.
The version that stayed asks about two things only: production, and targets that belong to another workspace. Everything else runs. It is a weaker rule on paper, and a much stronger one in practice, because it is on.
Along the way I learned something about Claude Code itself. A hook that answers “ask” makes Claude Code prompt even when it runs with permission checks bypassed. It does that on purpose: a hook has the last word. That is exactly what I want from a guard, but it took me a while to understand why my “skip permissions” sessions kept stopping.
The bug that hid most of my memory
The worst Treant bug was quiet. It surfaced in the second week as a review queue full of stale items, and digging into why led somewhere worse. Every time a session was saved again, Treant treated the new save as the full truth and marked anything the older saves had said, and the new one did not repeat, as superseded. Sessions get saved many times: at the end, before the context is compacted, after resuming. So each save quietly retired most of what the earlier ones had learned. When I counted, about 86% of the facts in my workspaces were hidden from search. My personal workspace had 78 current facts and 811 superseded ones.
The fix was a change of mind more than of code: a save adds, it does not restate. Only the list of open threads is replaced by the newest save, because that list really is a snapshot. Then I took a backup and ran a restore. By then my personal workspace was down to 64 current facts; the restore brought it back to 769.
Nothing had been deleted, which is the only reason that story has a happy ending. Treant never deletes a fact; it marks it superseded and keeps its history. That rule was in the design from the start, and it is what made the bug recoverable.
A dashboard for the memory
A memory you cannot see is a memory you cannot trust, so Treant got a dashboard at treant-ui.ashkmb.com, on my home network only. It is deliberately plain: server-rendered pages and no JavaScript at all. The graph view is drawn on the server as a picture.
I use it for three things. The review queue shows what wants to move from a workspace into general, with a short rule of thumb on every item: a public tool or principle, approve; my own host, repo or person, drop; when unsure, drop, because the workspace keeps its copy. The graph view shows how a workspace has grown. On the first day, my work workspace got 36 nodes from three sessions, almost all of them ticket numbers, which raised the question of whether a ticket should be a fact instead of a node. I still have not decided. And the duplicates page finds facts that say the same thing twice and merges them, with history kept.
Anything sensitive, like approving a fact into general or showing a token, needs a fresh login. That part broke too, in the most confusing way. After a few minutes, the Approve button did nothing at all. The page’s own security policy only allowed forms to post back to the dashboard, so the browser silently refused the redirect to the login page. One line of policy fixed it.
A board, and a night shift
Memory was back. Open-ended work was still missing.
The harness already had a dashboard at agent.ashkmb.com, the one that replaced Hermes’s: research digests, invoice review, the spend page. In November it got a task board. A card is a task with a description, and optionally a written spec and an implementation plan attached. Every night at 23:00, a runner picks up the cards I have marked as ready and hands each one to Claude Code in a sandbox. It runs in two lanes, one per Claude subscription. By morning, every card is back in Review as a draft pull request, a held git bundle I push by hand, or a written note. One message on my phone summarises the night. The runner never merges, never deploys and never pushes to main.
It only touches cards that I created and that only I have edited. The board also has agent accounts, and a card an agent wrote is not an instruction I gave.
The first week of the night shift taught me more than the design had, and none of it was where I expected.
Subagents died with their parent. My plans are written for subagent-driven work: the main agent hands each task to a fresh subagent, and a reviewer checks the result. The first real plan card had 17 tasks and stopped after one. The main agent had started the next subagent in the background and ended its turn, and in headless mode Claude Code exits when the main agent replies. The runner saw a clean exit with 16 tasks left. One environment variable that turns off background tasks fixed it, and any headless run that uses subagents will need the same.
Stop meant delete. I stopped a running card once, to deploy a fix. The cleanup removed the work directory before anything was published, and three finished tasks and their final review were gone. Now a stop keeps whatever is committed. I wrote the lesson down bluntly: never promise “committed work is kept” without reading the code that runs on SIGTERM.
A template ate a newline. The sandbox units are rendered from templates, and one template tag at the end of a line removed the newline after it. The next directive was glued onto the end of a firewall line. systemd did not complain; it ignored what it could not parse. Two of my workspaces ran their night jobs with no DNS, and nothing said so until a job tried to resolve a hostname.
The limit message changed. The runner tells “out of usage” apart from “Claude crashed” by the wording Claude Code prints. An upgrade changed the wording, and a card that only needed to wait for the other lane was filed as an error. After every upgrade, I now search the new binary for the limit messages.
Every one of these is an assumption that held in my tests and failed in production, because my tests ran my code against my idea of the tools around it.
Read everything, change nothing
A night agent that cannot look at anything is useless for “why does this service keep restarting”. One that can change things is not something I want running while I sleep. The design gives the agent read access to its workspace’s infrastructure and no write path at all, and neither half depends on the agent behaving well.
The agent has no GitHub credentials. Its code leaves the sandbox as a git bundle, and a different user checks the bundle before anything reaches GitHub. Cloud access uses short-lived, read-only credentials, minted outside the job from a key the job never sees. SSH goes to a user on my machines that can only run a fixed menu of read commands. After every job, a leak guard scans everything that leaves for every credential the job could have seen, and nothing is pushed without its “ok”.
There is also a deny list in Claude Code’s settings that refuses write commands. I treat it as a second layer, not the control. If the deny list missed something, the provider would still say no.
Done, according to whom?
For the first week, a card was done because the agent said so. Then a test card broke one of its own rules, running two commands in parallel when the card said not to, and nothing noticed.
So now a plan can end with an ## Acceptance block: the shell commands I would run myself to believe the work is done. When a run finishes, a separate check user with no credentials clones the pushed branch into a fresh directory and runs them. No result counts as failed. A failed check sends the card back to the agent with the output as its first job, at most twice. A plan without checks is marked “unverified”, not “done”.
The two pull requests from the start of this post were among the first real cards through that gate. They passed their checks, three and four of them, on the first run, with no fix attempts. That is a small sample, and I will not pretend it is more.
What comes next: Treant in the chat
Today my memories live in two places that do not talk to each other. The chat knows my notes and its own past chats, through SuperBrain. My coding sessions and the night shift know what they learned, through Treant. When the night shift finds out why a service keeps restarting, my chat has no idea.
The next step I am considering is to give chat.ashkmb.com a read-only key to Treant’s personal workspace. Treant already scopes every token to one workspace and to specific actions, so a key that can only search is a configuration change, not new code. Writing is a different question. A chat that can write to the memory my agents rely on is an easy way to poison that memory, so if it ever happens, it will go through the same review queue as everything else.
What the five weeks taught me
Walls beat rules. “Don’t mix workspaces” was a rule in a prompt for months. A schema per workspace, and a token that cannot read the others, made it a fact.
A safety tool you switch off protects nothing. The guard got useful when it asked less.
Never delete; supersede. It is the only reason the bug that hid 86% of my memory was a bad week and not a lost month.
Ask for proof, not a report. “Done” from an agent is a claim. An acceptance check is a command I would have run anyway.
Most bugs live at the seams. A changed message in a CLI, a lifecycle I had not read about, a template that ate a newline, a browser silently refusing a redirect. Very little broke inside my own code. Almost everything broke where my code met something else.
None of these systems is clever. SuperBrain is a search box. Treant is Postgres with walls. The board is a list, and the night shift is a timer. Together they gave me back what I missed from Hermes, and this time I know where every fence is, because I built each one.