memory
v0.1.1 · compiled with katari 0.1.0
memory
15 declarationstarget#
requestrequest target() -> store.storeThe memory subtree capability: WHERE this scope's memory lives. The provider serves it; the tools and index_note perform it, so the model is handed tools, never a store.
Returns
Wire view (JSON Schema)
save#
datadata save(key: string, summary: string, body: string)One memory mutation: SAVE a memory — its one-line index summary and its full body, under key.
Parameters
Wire view (JSON Schema)
drop#
datadata drop(key: string)One memory mutation: DROP a memory — both its index summary and its body, under key.
Parameters
Wire view (JSON Schema)
change#
typetype change = save | dropapply#
requestrequest apply(change: change) -> nullThe WRITE channel: every mutation of the memory subtree rides this one request, served by a SEQUENTIAL handler in the provider. The tool loop dispatches a turn's tool calls CONCURRENTLY (parallel for), and the index is a read-modify-write of one record — two racing remembers would lose one summary. The handler's FIFO is the serialization point: mutations apply one at a time, in arrival order, so no update is ever lost.
Parameters
Returns
Wire view (JSON Schema)
provider#
agentagent provider[R, effect E](subtree: store.store, continuation: agent(value: null) -> R with {...E, target, apply}) -> R with E | store.get | store.set | store.deleteProvide the memory subtree for the extent of the continuation: use memory.provider(subtree = store.scope(target = store.root(), path = "assistant/memory")). The provider holds no state — every read recomputes its view from the one served subtree — but it IS the write serialization point: mutations ride apply, whose sequential handler applies them one at a time (see apply), so the parallel tool dispatch cannot interleave two index read-modify-writes.
Generics
Parameters
Returns
Effects
Inferred type
agent(continuation: agent(value: null) -> T0 with apply | target | E1, subtree: store) -> T0 with delete | get | set | E1
Wire view — the wire shape is fixed at the call site, where the generic parameters are instantiated.
entries#
agentagent entries() -> store.storeThe BODY subtree — one full note per key under entries, apart from the one-line summaries in the index.
Returns
Inferred type
agent(...record) -> store with target
Wire view (JSON Schema)
render_note#
agentagent render_note(value: unknown) -> stringRender one stored memory value for the model: a plain string as itself, anything else as its JSON.
Parameters
Returns
Wire view (JSON Schema)
index#
agentagent index() -> record[unknown]The memory INDEX: the one record mapping each saved key to its one-line summary, read fresh from the durable store (empty when nothing is saved). Read TOTAL (json.entries), so a missing or malformed value degrades to the empty record rather than throwing into an every-turn injection.
Returns
Inferred type
agent(...record) -> record with target | get
Wire view (JSON Schema)
index_lines#
agentagent index_lines() -> array[string]The index as one - key: summary line per saved memory — the shared rendering behind list_memories (the tool) and index_note (the every-turn injection).
Returns
Inferred type
agent(...record) -> array[string] with target | get
Wire view (JSON Schema)
index_note#
agentagent index_note() -> stringThe memory index as an every-turn prompt block: a '[memory index]' header plus one - key: summary line per memory, or the EMPTY string when nothing is saved — hand this to ai.with_context (an empty injection is skipped there).
Returns
Inferred type
agent(...record) -> string with target | get
Wire view (JSON Schema)
remember#
agentagent remember(key: string, summary: string, body: string) -> stringTool: save a note to your persistent memory under a short key (e.g. "user/name", "prefs/timezone"). You give a one-line summary (shown back to you every turn in the memory index) and the full body (read on demand with recall). Both survive restarts, so save durable facts, preferences and decisions — not this turn's scratch work. Re-using a key overwrites it. ALWAYS write a real summary: it is all you see of this memory until you recall it.
Parameters
A short path-like key, e.g. "user/name".
A one-line summary, shown every turn in the index.
The full note, read back with recall.
Returns
Inferred type
agent(body: string, key: string, summary: string) -> string with apply
Wire view (JSON Schema)
recall#
agentagent recall(key: string) -> stringTool: read back the FULL note for one memory key — the body you saved with remember. The one-line summaries are already shown to you each turn under '[memory index]', so use this to read a specific note in full. Call list_memories first if you are unsure of the key.
Parameters
The key to read.
Returns
Inferred type
agent(key: string) -> string with target | get
Wire view (JSON Schema)
forget#
agentagent forget(key: string) -> stringTool: delete a memory by its key — removes BOTH its index summary and its body. Use it to prune stale or wrong facts. Deleting a missing key is a no-op.
Parameters
The key to delete.
Returns
Inferred type
agent(key: string) -> string with apply
Wire view (JSON Schema)
list_memories#
agentagent list_memories() -> stringTool: LIST your saved memories — one key: summary line per memory — so you can see what you have without guessing keys. Read a full note with recall(key).
Returns
Inferred type
agent(...record) -> string with target | get