Build1 publisher3 min readPublished
Crystals push agent memory into the hook that runs before each tool call
Crystals, a memory design written up on dev.to, deliver notes to an agent just before a matching tool call runs, from a hook firing about 300 times a day. Its most useful finding is a matched note that the token budget cuts before the model sees it while the logs still count a hit.
The Engineer · Build desk

What happened
- A dev.to post argues that search-based agent memory runs only when the agent suspects it needs help, so a confidently wrong agent never queries it.
- Its alternative, called crystals, binds each note to an action and delivers it just before that action runs, whether or not the agent asked.
- Each crystal is a markdown file whose header names the tools it fires on, plain substrings to match such as git reset --hard, and a delivery channel.
- The author reports notes that matched correctly and were then cut by the context budget packer, so they never reached the model.
- Two of the post's four ideas were already in print, including action-triggered rules injected before a git commit under a hook time budget.
Compiled by The EngineerSomething wrong?How this is made
Why it matters
- decision Counting memory hits at match time overstates what the model saw, so a team running pushed notes needs a per-note log of what survived packing into the context.
- constraint Every false-positive substring match spends context budget that a real warning competes for, so a longer match list raises the odds that a needed note gets cut.
- capability Rules keyed to the prompt act can redirect a task before any tool runs; a retriever only gets that chance if the model asks for it.
- cost Each rule becomes two artifacts to maintain, a long rationale file and a short delivered essence, plus an expiry date that someone has to renew or let lapse.
The matcher is the part I would defend first at review. A crystal's `match:` line is a comma list of plain substrings, tested case-insensitively, with no word boundaries and no embedding anywhere in the path [12]. The author wants a test that is auditable at a glance and cannot drift, on a hook that fires about three hundred times a day [13]. For a guard on destructive shell verbs, I'd make the same choice. The cost is predictable from the rule. With `git clean` in the sample list and no word boundaries, the dry run `git clean -n` contains the substring and draws the same warning as the real command [23].
What a crystal can see depends on the act. The hook fires on the tool call before it executes, and the tool decides the act [5]. A `write` act can see content, so a crystal about pricing claims fires on the pricing claim itself and leaves other edits alone [15]. A `prompt` act lands before the first tool call. The author wrote that this is "the only place you can still change the plan rather than the keystroke" [14].
The post spends a paragraph on why these are called crystals [22]; the file format makes the better case. Two details in it are good engineering. The file can hold three thousand words of history, rationale and dead ends, and only the text between two `crystal:essence` markers reaches the model [6]. In the first example, that text warns that `git reset --hard` also discards tracked-but-uncommitted changes and that only untracked files survive [19]. A `stale_after` date, 2027-03-25 in the sample, withholds the claim once it passes [4].
The packer failure happens between the matcher and the model. "To the model it never existed; to the logs it was a hit," the author wrote [11]. The closest entries in the evaluation literature are two of Mem2ActBench's five error types: Retrieved-but-Unused, defined as "evidence is retrieved but not utilized," and Lossless Retention Failure [9]. The author argues both are failures on the model's side, after the evidence has reached the context window or while the model writes a long value back out [18]. An eval that grades what the model did with its context has no category for a note that never arrived [9][18].
The author ties the one-knowing-per-crystal rule to this failure, calling it "the difference between this working and this quietly failing" [7]. A 2026 survey of agent memory lists "curation under fixed budgets, including update, eviction" as an open direction [16]. The author offers the post as a field report against that request, from a channel that has run long enough to overflow [17]. The available text ends partway through the first of three worked examples from a single day [21]. The reasons, the overflow numbers and the two rules the author says the team did not know it needed do not appear before it stops [20].
What to watch
- The post's promised overflow numbers: how often a correctly matched crystal is cut by the packer once the channel is full.
- Whether a benchmark answers the 2026 survey's request to measure memory quality against token budget, storage cost and latency.
- Whether Mem2ActBench or a successor adds an error type for evidence dropped before it reaches the context window.