Browse modules

memory

v0.1.1 · compiled with katari 0.1.0

memory

15 declarations

target#

request
request target() -> store.store

The 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.

Wire view (JSON Schema)

save#

data
data 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

key
string
summary
string
body
string
Wire view (JSON Schema)

drop#

data
data drop(key: string)

One memory mutation: DROP a memory — both its index summary and its body, under key.

Parameters

key
string
Wire view (JSON Schema)

change#

type
type change = save | drop

Definition

one of

apply#

request
request apply(change: change) -> null

The 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

change

The mutation to apply.

Returns

null
Wire view (JSON Schema)

provider#

agent
agent provider[R, effect E](subtree: store.store, continuation: agent(value: null) -> R with {...E, target, apply}) -> R with E | store.get | store.set | store.delete

Provide 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

Rtype
Eeffect

Parameters

subtree

The durable subtree this scope's memory lives under.

continuation

Runs with target and apply served; its result is the provider's result.

agent
input
object
value
null
output
R
effects
override
base
E
overrides

Returns

R

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#

agent
agent entries() -> store.store

The BODY subtree — one full note per key under entries, apart from the one-line summaries in the index.

Inferred type

agent(...record) -> store with target
Wire view (JSON Schema)

render_note#

agent
agent render_note(value: unknown) -> string

Render one stored memory value for the model: a plain string as itself, anything else as its JSON.

Parameters

value
unknown

Returns

string
Wire view (JSON Schema)

index#

agent
agent 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

record
unknown

Inferred type

agent(...record) -> record with target | get
Wire view (JSON Schema)

index_lines#

agent
agent 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

array
string

Inferred type

agent(...record) -> array[string] with target | get
Wire view (JSON Schema)

index_note#

agent
agent index_note() -> string

The 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

string

Inferred type

agent(...record) -> string with target | get
Wire view (JSON Schema)

remember#

agent
agent remember(key: string, summary: string, body: string) -> string

Tool: 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

key

A short path-like key, e.g. "user/name".

string
summary

A one-line summary, shown every turn in the index.

string
body

The full note, read back with recall.

string

Returns

string

Inferred type

agent(body: string, key: string, summary: string) -> string with apply
Wire view (JSON Schema)

recall#

agent
agent recall(key: string) -> string

Tool: 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

key

The key to read.

string

Returns

string

Inferred type

agent(key: string) -> string with target | get
Wire view (JSON Schema)

forget#

agent
agent forget(key: string) -> string

Tool: 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

key

The key to delete.

string

Returns

string

Inferred type

agent(key: string) -> string with apply
Wire view (JSON Schema)

list_memories#

agent
agent list_memories() -> string

Tool: 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

string

Inferred type

agent(...record) -> string with target | get
Wire view (JSON Schema)