Blog

Engineering · · 11 min read

Our AI assistant stored 20,420 memories. When was a lookup worth the wait?

On the evening of November 7, a Stevin user sent our assistant a direct message asking it to draft an update for the weekly meeting. The draft was to stay in the chat. They had done this together before. The team shared a document, and the user was responsible for one section. Once, they had corrected the assistant about which page their update belonged on. This time, the user left all that unsaid.

That request and the work of answering it made up one turn. The assistant could search for a document, call a tool, and draft a reply, all within the same turn. The chat itself was a session. Think of a DM with a bot in Slack. If the user came back to that chat a week later, their new request would start another turn in the same session.

At the time, we used mem0, a long-term memory system we ran on our own servers. It held facts drawn from conversations and records of successful tool actions. Before every reply, the assistant searched that store using the new request. For the weekly update, the search returned ten records. Five were personal notes from July through October, all from the chat where the user had just asked for the draft.

We read everything the model had received before it started writing. The new request told it where to deliver the draft. Only the retrieved notes contained the earlier instructions about whose work to cover and where the user had wanted their update filed in the shared document. In a different conversation, a user simply said hello. The same search returned five receipts for actions the assistant had completed in the team's messaging app. Our monitoring counted one hit for the weekly update and one for the greeting.

Two days after the weekly update, we removed the search that ran before every reply and the background process that captured new memories afterward. Conversation history stayed in place. The old memory store also survived, which let us look back at several months of use in one production workspace. We could see what went into the store, what came back out, and where the assistant had paused to wait for it.


How the assistant's own writing became personal memory

Figure 1 shows where the 20,420 records came from. Of the 16,240 records filed under individual users, 13,329 came from the assistant's replies. Another 2,823 came from messages people sent in the team's messaging app, and the rest from phone and WhatsApp interactions. The assistant's project summaries, explanations of code changes, and suggested to-do lists could all end up filed under the name of the person it was helping.

Sources of the 20,420 records, including 13,329 from assistant replies and 4,180 from tool actions.

"Personal" determined when a record was available. In a private chat, the assistant could search both the current user's records and the organization's shared records. In a group chat, it could search only the shared ones. Authorship was a separate question. When the user asked for that weekly draft, the background writer extracted one new entry from the request and eight from the assistant's reply. The next time that person needed help, the assistant could find its own account of their work.

Tool receipts took another route into storage. After a successful operation, we saved a one-line account in the shared collection. An issue number or document link could be useful a week later. But 2,084 of the 4,180 shared receipts contained only a tool name and a success marker. In 1,763 cases, the text was identical. That explains how a greeting could turn up five receipts and why a receipt like that would be little help to someone asking which document had been updated.


What could the assistant learn from what it had saved?

We sampled 36 stored records by source and visibility. We also read 12 turns where a search had returned something, with the user's request, the retrieved records, and the assistant's answer side by side. In the weekly update, the user's earlier instruction gave us a concrete test for the draft. Someone reading it could check whether it stayed within the section the user owned.

A reminder was more complicated. The system correctly recorded the deadline and the user's request for a reminder. The five receipts it retrieved belonged to other tasks. The new reminder was still awaiting approval. If the user came back the next day to ask about it, the conversation could identify the reminder they meant. Checking whether it had actually been scheduled meant looking up its current status in the task system. Treating the request itself as evidence of completion could have led the assistant to report success too early.

In a discussion about latency, a user described two improvements they had observed and suggested a cold-start explanation they still wanted to test. The writer saved all three. A separate engineering summary said a permission check had moved into the background. Reading the code supplied the condition the summary had dropped. The system could refresh a populated cache in the background. The first lookup against a cold cache still had to wait. For an engineer investigating a slow first request months later, that condition might be the most important part of the note.

In a restaurant conversation, the assistant described a test restaurant, and the writer saved details from that description as facts. A user-confirmed fact, the assistant's own summary, and an example from a demo deserve different levels of trust when the assistant answers the next question. All three could reappear in the same form, as a sentence retrieved from memory.


How a memory search became part of every reply

Figure 2 traces the changes from June to November. In June, we added session history and a separate index of facts for long-term search. In July and August, we began storing tool receipts, set boundaries on reads and writes for personal records, and logged the duration and results of searches. The system could also suggest revisions to personal facts that appeared to be out of date. In this workspace, those suggestions were kept for review.

Session history and long-term search arrived in June. Later changes added receipts and visibility controls, capped search time in October, and retired automatic reads and writes in November.

By October, the team was looking for a way to shorten the wait. Even a short message could set off a second or two of searching before the assistant called the model. On October 5, we let independent searches run in parallel under a shared 600 ms budget. When it expired, the assistant could move on. Before rollout, we had tested the two implementations side by side in another workspace. Their median search times differed by only 3.2 to 4.4 milliseconds. This workspace's production traffic showed a much larger change.


The wait got shorter. Most searches timed out.

Figure 3A tracks the same searches in two ways. The upper panel shows duration, and the lower one shows the share that returned at least one memory. Both panels cover chat and background work, and both measures fell after the October rollout.

Daily search duration and the share returning a memory. The vertical marker shows the rollout.

In the full week before the change, 814 of 816 searches returned a record (99.8%). The median duration was 1.571 seconds, and the 95th percentile was 2.436 seconds, meaning roughly 95% finished within that time. In the first full week afterward, those times fell to 0.606 and 0.665 seconds. Of 675 searches, 83 returned a record (12.3%). Among the 592 that returned nothing, 588 timed out. The assistant generally got to resume work sooner because its allotted time had run out.

The line looks almost flat from there. Figure 3B expands the vertical axes to milliseconds. Under the new rule, daily medians ranged from 600.5 to 615 ms, a range so narrow that it barely registers on Figure 3A's scale of whole seconds. The slower searches still varied. On November 1, the daily 95th percentile reached about 850 ms. The timer includes scheduling and timeout handling as well as the wait for a result.

Post-rollout daily medians and 95th percentiles in milliseconds, with the 600 ms budget marked in both panels.

Background jobs made up most of the searches in both weeks. Their return counts went from 730 of 730 before rollout to 14 of 556 afterward. Private chats went from 44 of 45 to 33 of 64. The low overall return rate held into November. From November 1 to 8, the workspace retrieved something on 61 of 842 searches (7.2%).

In a separate look at 50 user-facing turns before removal, we counted 64 searches. Of these, 39 timed out, 24 returned content, and one finished normally with no results. A timeout and a completed search with no results are different problems to diagnose. If time ran out, the store might still contain a relevant record. Conversely, a search that returned five items tells you how many records were delivered. You still have to read them to see whether the assistant gained anything it needed.


How much time did removing the lookup save?

To measure the November change, we compared group conversations handled by the last production version with automatic retrieval and the first version without it. There were 13 turns before and 23 after. All used the same main model. In group chats, the old assistant could automatically search only shared organizational records, so the access rules were consistent across the old-version turns.

Figure 4 measures several stages of those same turns. On the old version, the assistant waited for its first automatic lookup in every turn. The median wait was 0.517 seconds, and the 95th percentile was 0.719 seconds. All 23 new-version turns skipped that step. From the start of the turn to the first model call, the median fell from 6.16 to 4.26 seconds. Input preparation, which happened before the explicit memory search, also got shorter, from 4.10 to 2.63 seconds at the median.

Median and 95th-percentile times for five measurements on the same group-chat turns.

For a complete turn, the median fell from 80.63 to 31.76 seconds, a difference of nearly 49 seconds. The 95th percentile fell from 524.69 to 124.13 seconds. Figure 5 shows what those requests involved. Each dot on the left is one turn. The two slowest on the old version took about 438 and 655 seconds, with 33 and 29 tool calls, respectively. Much of that work happened after the lookup had finished.

All 36 group-chat turns on the left, and turns with tool-call counts observed in both versions on the right.

The requests on the old version tended to involve more work. Among turns with at least four tool calls, the median number of calls was 29 before removal and 7.5 afterward. The right panel keeps the tool counts that occurred in both versions (0, 1, 2, 3, or 5). That left 7 turns before removal and 16 after. The full-turn medians were then 22.82 and 23.50 seconds, and the 95th percentiles were 74.32 and 49.33 seconds. Restricting the comparison to those jobs was enough to reverse the ordering of the medians. The wait we could trace directly to mem0 was the pause before the first model call, about half a second at the median.


For what comes next, start with the current conversation

In the weekly update, all five personal notes came from the current session. Yet the model input for that November draft contained no prior chat messages or rolling summary. As a chat grows, the assistant can fold older exchanges into a summary. Keeping a conversation open for months and giving the model access to a particular instruction from July are two separate engineering problems.

How often did search reach outside the current session? Between November 2 and the November 9 rollout, the workspace recorded 13 private-chat turns across three sessions. We pooled them, sorted them by start time, and numbered them 1 through 13. Figure 6 shows the full sequence across the top. Only turns 3, 6, 7, 12, and 13 retrieved personal memories. Searches in the other eight timed out. The five rows below keep the original turn numbers.

Take Turn 3, the third turn to start across all three sessions. Of its five personal records, three came from that conversation. The other two were filed under the same user's name and had originated outside the current session. Each of the other four turns shown also returned five items. Counting a record each time it appeared, 13 of the 25 came from the current session and 12 from other sessions under the same user's name.

All 13 turns numbered by start time across three private-chat sessions. The five rows show personal memories from the current session (circles) or another session under the same user's name (squares).

Ten of those 12 results came from background tasks the assistant had run. The other two came from group conversations, the equivalent of threads in a Slack channel. The users had stayed in their DMs. It was the search that reached elsewhere. Eleven of the 12 originated in assistant replies. They included release notes, merge notifications, and a message-delivery receipt. They came back in four turns. Three concerned the current status of an integration, which the assistant checked with a tool. The fourth was a brief acknowledgment. A memory could cross a session boundary and still contribute little to the question at hand.


What a hit was worth

Our assistant could write a project summary, file a sentence from it under the user's name, and retrieve its own sentence on a later turn. That counted as a hit. Nothing in that sequence required the user to have said it or confirmed it. Of 16,240 personal records, 13,329 came from assistant replies. The greeting exposed the same weakness in how we scored retrieval. Returning five tool receipts earned just as much credit as recovering the user's instructions for the weekly draft.

Removing automatic retrieval eliminated a wait we could measure in group chats, about half a second at the median. To decide when that wait buys something, it helps to ask a question the dashboard never did. If the retrieved records disappeared, what would the assistant lose? For the weekly draft, the model would lose the only instructions in its input about whose work to include. For the reminder, all five old receipts could stay in the input, and the decisive fact would still be missing. Whether the new reminder had been approved was something only the task system could settle.

Our system could search across conversations. Yet the clearest case we found for long-term memory was a gap within one conversation. All five personal notes it retrieved for the weekly update came from the chat where the user had set the scope in July and asked for the next draft in November. The user had simply picked up where they left off. Only the assistant needed a way back to July.

Give Stevin a call.