Programmable memory for AI agents: why fixed vector APIs fall short
By Dipankar Sarkar ·
Ask most “agent memory” systems a question and you get the same shape of answer: semantic_search("query", k=5). A single similarity call, a fixed number of results, ranked one way. That’s fine for a demo. It falls apart the moment a real task needs anything more specific.
The problem with a fixed API
Consider what an agent actually wants to do with its memory:
- “Find memories related to this query, but only from the last 7 days, and only ones I marked important.”
- “Retrieve the top 20 by similarity, then re-rank by recency, then keep the 5 most diverse.”
- “Cross-reference these entities against my earlier conversations and return what changed.”
None of these are a single search() call. With a fixed vector API you push this logic up into the application, round-tripping data back and forth — or you don’t do it at all.
Liath’s approach: let the agent write the query
Liath — the SQLite for AI agents — takes a different stance. Instead of a fixed API, agents write programs to query their own memory:
local results = semantic_search("mem", query, 20)
local recent = filter(results, function(r)
return r.age_days < 7 and r.importance > 0.8
end)
return json.encode(top(recent, 5))
The LLM generates Lua; Liath executes it. Custom retrieval, ranking, and filtering — expressed as code the model can adapt to the task in front of it.
But isn’t running agent-generated code dangerous?
It would be, if the code could touch your system. Liath runs Lua in a sandbox with no file, network, or system access. The agent gets a real programming language for querying memory, and you get a hard security boundary. That combination — programmable and safe — is the whole point.
Embedded, not another server
Liath is embedded. There’s no server to run, no infrastructure to manage — a KV store, vector search, and embeddings in a single dependency, with a Rust core for speed and portability. Use it from Python (pip install liath) or Rust (liath-rs).
If your agents are outgrowing a one-line search call, give them programmable memory. Read more at liath.incredlabs.com or explore the code at github.com/incredlabs/liath.
Built by incredlabs — Rust-native data infrastructure for AI. Explore ORMDB and Liath.