↓ Skip to main content

The Eight Second Budget: Why Long Messages Silently Cost My Agent Its Memory

·6 mins
Joe Gilmore
Author
Joe Gilmore
Notes on network security, homelab builds and self-hosting, by Joe Gilmore.
Table of Contents

My agent keeps its long-term memory in a service called Hindsight. Before every turn it asks Hindsight for anything relevant to the message it is about to answer, gets back a few dozen observations, and pastes them into the prompt. When that works, it remembers what we decided two weeks ago. When it doesn’t, it starts cold and asks me something I already answered.

Last week I found out that “when it doesn’t” has a pattern, and the pattern is message length. Every turn that arrived as a long paste, whether a monitoring notification, a log dump or an alert email, was coming back with no memories at all. No error, no warning in the chat, just a shorter prompt. I only noticed because the agent kept rediscovering facts it had recorded the day before.

The eight seconds belong to the client, not the server
#

The agent waits 8.0 seconds for a recall. That number is hardcoded in the memory manager, it applies to every single turn because the recall runs synchronously before the model is called, and no config key or environment variable moves it. If the response is late, the manager writes one log line and moves on:

Memory provider 'hindsight' prefetch timed out after 8.0s; the call keeps running

The call does keep running. Nothing looks broken from the outside; the turn simply gets no memories. Counting that line in the log is the only honest measurement of the problem, because a manual query against the API always returns, and returns whatever it takes.

I suspected the wrong numbers first
#

The obvious suspect was candidate count. Recall pulls a pool of facts and reranks all of them, so fewer candidates should mean less work. The second suspect was CPU. The memory service shares a box with camera detection and a media library scanner, and I had already measured rerank time swinging by more than 2x depending on what else was awake.

Both of those are real costs. Neither explained why the failures clustered on notifications.

It was query length
#

A cross-encoder reranker scores pairs, meaning the query once against each candidate fact. Cost tracks the length of the pair, so every extra character in the query is added to all N pairs, not to one. Sweeping the query length against a fixed candidate cap made that visible immediately.

Query lengthRecall time
60 characters4.0 to 4.2 s
200 characters4.8 to 4.9 s
400 characters6.5 to 7.3 s
600 characters8.1 to 8.5 s, over budget
800 charactersabout 10.1 s

Roughly 0.8 seconds per extra 100 characters at that candidate cap. Typed messages sit around 90 characters, which is why they never showed the problem. Notifications run 600 to 1,000, which is why they always did.

Measured through the real input path, not a hand-written probe
#

The first version of this test was wrong in a way worth describing. I was sending the full message to the API myself, which measures a workload no turn actually runs. The plugin truncates the message before it goes out, using a setting called recall_max_input_chars that defaults to 800. Everything I changed had to be measured through that path, three rounds per setting, using a real notification as the sample.

Input capTyped message (~90 chars)Long turn (~950 chars)Turns over 8 s
800, the default4.2 to 4.5 s10.2 to 11.0 s3 of 3
6004.2 to 5.5 s8.9 to 10.7 s3 of 3
450not measured7.4 to 7.9 s0 of 3
350not measured6.9 to 7.9 s0 of 3

Dropping to 600 was not enough, which was useful to learn before shipping it.

Two ways to buy back the time
#

Latency comes from the query length and the candidate cap, so either can be cut and the two multiply. The temptation is to cut candidates, because it is a server setting and costs nothing to reason about. I checked what each lever actually changes in the results, comparing the top 10 for each setting against the old one.

Trimming the query from 800 to 350 characters reshuffled about 70 percent of the returned list. Cutting candidates from 250 to 200 changed about 4 percent on short queries and 7 percent on long ones. If you read only that, cutting candidates looks like the safe move.

It measures the wrong thing. Overlap tells you a result set changed, not whether it got worse. Cutting candidates also throws away reach, since a fact ranked 220th is gone rather than downweighted. So I ran a relevance check instead.

Checking quality, blind
#

I pulled 14 long turns out of the session database, kept the 11 that were genuinely over the cap, and recalled the top 5 memories for each one at both settings. The two lists went to a separate model, shuffled, with the full message attached and no indication of which setting produced which list. It scored every memory 0, 1 or 2 for usefulness in answering that message.

Truncation to 350 scored 2.82 out of 10 against 2.45 for the full message. It was ahead on 6 messages, behind on 2 and tied on 3. That is 11 messages and one judge, so it is not a precision claim, but nothing in it suggests the shorter query found worse memories. The mechanism makes sense: in a long paste the tail is usually boilerplate, and boilerplate pulls the query off topic about as much as it adds signal. The head was already carrying the intent.

Across those 14 long turns, turns that blew the 8 second budget went from 12 of 14 to 1 of 14.

What truncation actually costs you
#

Truncation keeps the head of the message. That is fine for notifications, whose first line is the alert. It is bad if you paste a log and put your question at the bottom, because the question is not in the query at all and the memories come back for the boilerplate. Short typed messages are unaffected, since they fit under any cap.

There is also a trap in how you sample long messages to test this. The stored copy of a user turn includes the memory block the agent prepended to it, so a message of 400 characters of actual typing measures several thousand characters in the database. The recall query never contains that block, so it has to be stripped before you measure message lengths. I wasted an afternoon on a sample padded with short messages wearing long coats.

Where it settled
#

The cap went to 350 characters, and the candidate count from 250 to 225. Long turns now measure 6.5 to 6.8 seconds through the plugin and typed ones 3.6 to 4.9, leaving headroom for the box to be busy.

Two things I would hand to anyone measuring the same problem. Do not extrapolate from a single very long query: a probe at 2,400 characters measured about the same latency as 800, because the cross-encoder caps how much of a pair it will read, so the curve is linear only over the range you tested. And the 8 seconds is a client side timeout in one agent’s memory manager, not a property of the memory server, so the fix that matters is knowing what your client does when recall is slow. A silent empty result is the hardest failure mode to notice, and it is invisible from the server side, where every query succeeds.

Related

Three Model Swaps Behind a Self-Hosted Memory Bank

·8 mins
I run an agent called Hermes with a long-term memory service called Hindsight behind it. Hindsight reads every conversation turn, pulls out facts worth keeping (one LLM call, the extraction pass), and later merges them into longer-lived observations (a background consolidation pass that dedupes and combines). The service runs on my own hardware, in Docker with embedded Postgres, and the embeddings and reranking happen locally on the box. So the only cloud spend in the whole system is those two calls, which makes the bill a clean measurement of exactly two model choices.

Hello, and how this site is built

·3 mins
This is the first real post here: a short introduction, then a walk through how the site you’re reading is put together. What this blog is for # I’m a network security engineer. Most of my working day goes to firewall policy, segmentation and remote access, and to the change process around them. Outside of work I run a homelab that is part test bench and part household infrastructure, built on Proxmox, TrueNAS, Docker, pfSense and Tailscale, with Home Assistant and a growing set of self-hosted services on top.