Why Agents Need Programmable Memory

Author: Dipankar SarkarPublished: June 20, 2026

Give an agent a vector database and you give it exactly one way to remember: call semantic_search(query, k), get back the k nearest chunks. That is a fine default. It is also a ceiling.

The ceiling of a fixed API

Watch how real agents actually want to use memory:

  • prefer memories from the last few days over stale ones,
  • weight high-importance facts above incidental ones,
  • deduplicate near-identical results,
  • cross-reference a conversation against tool outputs,
  • and return the top handful in a specific shape for the next prompt.

None of that fits inside semantic_search(query, k). So it leaks into application code — a growing pile of filtering, scoring, and assembly logic that you write once per agent and maintain forever. The database knows about vectors; it knows nothing about the strategy.

Programmable memory

What if the agent could write the strategy itself? That is the idea behind Liath. Instead of a fixed call, the agent generates a small program:

local results = semantic_search("memories", query, 20)

local recent = filter(results, function(m)
    return m.age_days < 7 and m.importance > 0.8
end)

local scored = map(recent, function(m)
    m.score = m.similarity * m.importance
    return m
end)

return json.encode(top(sort_by(scored, "score"), 5))

Search, filter by recency and importance, re-rank by a custom score, return the top five — one program, generated by the LLM, run inside the engine. The retrieval strategy now lives where the reasoning is, and it can change from task to task.

Safe by construction

Letting a model generate code that touches your data sounds reckless, and it would be without isolation. Liath runs the Lua in a sandbox: no file system, no network, no system calls. The agent gets a real programming language for retrieval; the blast radius is exactly the memory store and nothing else. That combination — programmable and safe — is the whole point.

More than vectors

Programmable memory is most useful when there is something to program over. Liath bundles a key-value store, vector search, and embeddings, plus agent primitives — tagged memory with importance, conversation history, and tool state. A Lua program can join all of them: search semantic memory, check tool state, read the last few conversation turns, and assemble the result.

The SQLite for AI agents

We describe Liath as the SQLite for AI agents because it keeps the embedded, zero-infrastructure model — a single dependency, no server — and points it at the problem of agent memory. If your agents are still limited to one retrieval strategy, programmable memory is the upgrade. See how it compares to a managed vector service in Liath vs Pinecone, or read Liath vs vector databases for the broader argument.

Liath is open source (MIT) and on GitHub. Install liath with pip or add the liath-rs crate to start.

Frequently Asked Questions

What is programmable memory?

Programmable memory means an agent queries its memory by writing a program rather than calling a fixed API. In Liath, the agent generates a sandboxed Lua program that runs semantic search, filtering, ranking, and shaping in one execution.

Why not just call semantic_search?

A single semantic_search(query, k) call encodes one retrieval strategy. Real agents need to weight recency, prefer important memories, deduplicate, and cross-reference — logic a fixed API can't express, so it ends up reimplemented in application code.

Isn't running agent-generated code dangerous?

It would be without isolation. Liath runs the Lua in a sandbox with no file, network, or system access, so the agent gets full programmability over retrieval while the code stays contained to the memory store.

Related Content

Give your agents programmable memory

Open source, MIT licensed. pip install liath or add the liath Rust crate.