ToriiDB in Agenvoy
Last updated
Agenvoy, an open-source local AI agent by Pardn Chiu that runs 24/7 on your machine, keeps its recent conversation vectors, tool error memory, tool result cache, and running-task markers in ToriiDB; this page maps each Agenvoy feature to the ToriiDB database and API it uses.
One daemon for every Agenvoy process
The Agenvoy TUI and one-shot prompt (both through
openLocal in cmd/app/local.go), the background daemon (cmd/app/daemon.go), and the running-task check before stop/update (confirmInterrupt in cmd/app/main.go) all call torii.Init(filesystem.StoreDir), which runs:- d, err := toriidb_daemon.New(path, go_pkg_filesystem_keychain.Get("OPENAI_API_KEY"))
- // ...
- err = d.Start()
| Item | Behavior |
|---|---|
| Data directory | ~/.config/agenvoy/.store |
| First process to start | Becomes the server, opens the store, and serves the unix socket |
| Every later process | Dials the same socket as a client and calls the same Get/Set/Del methods |
| Embedder availability | Asked from the server with d.HasEmbedder(ctx) instead of the local keychain; without an OpenAI key, conversation vectors are not written |
So when the TUI and the background daemon run at the same time they read and write the same data, with no file lock and no second store. See Mode Resolution for the mechanism.
Database map
Agenvoy defines four database indexes in
internal/runtime/torii/torii.go and wraps the Daemon methods per database (its scan wrapper calls Entries, and its multi-key expiry wrapper calls Expire with several keys):| DB | Agenvoy constant | Contents | ToriiDB API used |
|---|---|---|---|
| 0 | torii.DBToolCache | Tool result cache, fetch_page skip list, provider quota cache, provider model lists, the decision model's last chosen model | Set (with TTL), Get, Entries, Del |
| 1 | torii.DBSessionHist | Every conversation message with its embedding | SetVector, VSearch, Entries (Contains/After), Keys, Del |
| 2 | torii.DBErrorMemory | Tool error and fix records | SetVector (90-day TTL), VSearch, Expire |
| 3 | torii.DBOnline | Liveness markers for running tasks | Set (60-second TTL), Keys, Del |
Semantic chat search (DBSessionHist)
Each user and assistant message is written with
SetVector under the key <sessionID>:<unixNano>, and ToriiDB attaches an OpenAI embedding in the background. The chat_history tool builds two search modes on it:| Mode | ToriiDB call |
|---|---|
match=semantic | VSearch ranks by cosine similarity; each hit is expanded with the messages around it |
match=keyword | Entries(db, sessionID+":*", &ScanOption{Contains, After, Limit}) filters by keyword and time range on the server, then merges with the SQLite FTS5 archive |
On history compaction, session reset, and session removal, Agenvoy lists the affected keys with
Keys and deletes them in one Del, so ToriiDB holds only recent conversations. The three-tier memory design on the Agenvoy side is described in Memory System.Tool error memory (DBErrorMemory)
The
write_error tool stores a tool failure and its fix under <toolName>:<unixNano> as a JSON record with keywords, written with SetVector and a 90-day TTL. The error_history tool searches with VSearch first and falls back to a keyword scan; every record it returns is extended by another 90 days with one Expire call over all returned keys, so fixes that keep being used do not expire. See State and Memory Tools.Tool result cache (DBToolCache)
| Use | Key | TTL |
|---|---|---|
search_web/fetch_page results, returned directly for a repeated call with the same arguments | tc:<sessionID>:<callID> (tc:global: for global tools) | 30 minutes |
fetch_page skips URLs that returned 4xx | skip4xx:<sha256(url)> | 90 days |
fetch_page skips URLs that returned 5xx | skip5xx:<sha256(url)> | 12 hours |
fetch_page skips URLs with empty content | skipEmpty:<sha256(url)> | 72 hours |
| Provider remaining quota | provider:quota:<id> | 180 seconds |
Provider model lists (list, image, decision, stt, tts); deleted in one Del when the provider is changed | provider:models:<target>:<name> | 15 minutes |
| The decision model's last chosen model | lastModel:<sessionID> | 5–60 minutes by provider |
All of these rely on ToriiDB TTLs: an expired key reads as missing, so Agenvoy never cleans them up itself. See Tool Dispatch for how tool calls run.
Running-task markers (DBOnline)
Every running task writes
action:<sessionID>:<taskHash> with Set every 55 seconds and a 60-second TTL, and deletes it with Del when it finishes. Agenvoy counts a session's running tasks with Keys("action:<sessionID>:*"); if a process dies, its markers expire within 60 seconds. See Running Tasks for concurrency and cancel.Related pages
- Data Methods — full reference for
Get/Set/SetVector/Entries/VSearch - Server-Side Filtering — how
Contains/After/Limitrun on the server - Expiration — TTLs and when expired keys are removed