Reusable memory lifecycle command declarations and response shapes.

Sibling to ::ai::memory, not a replacement: ::ai::memory is the memory engine (AgentMemory, remember, recall, the three-store backing). This namespace is the command-surface counterpart that concrete agents wire into /forget, /compact, /export, /memory, and /why slash commands — declarations, parsed argument shapes, response types, and neutral formatting.

Files that need both typically alias ::memory ::ai::memory and ::agent-memory ::ai::agent::memory.

Concrete agents own policy, authorization, and execution hooks. This namespace keeps the common command surface and neutral formatting in one place.

Functions

common-memory-commands

fn (): Vec<::ai::agent::command/Command>

Command declarations for common memory lifecycle controls.

Example

map(::ai::agent::memory/common-memory-commands(), %.name)  // ["memory", "forget", "export", "compact", "why"]

inspect-export

fn (bundle: ::ai::memory/MemoryExport, opts: Map?): MemoryInspection

Build a MemoryInspection from an exported memory bundle plus optional capsule/graph counts.

Example

::agent-memory ::ai::agent::memory

bundle ::ai::memory/MemoryExport({agent-name: "team-agent", session: [], user: [], kb: []})
view ::agent-memory/inspect-export(bundle, {capsule-count: 2})
view.session-count  // 0
view.capsule-count  // 2

parse-forget-request

fn (arg: Str): ForgetRequest

Parse /forget arguments into {scope, selector, raw}.

Example

::agent-memory ::ai::agent::memory

req ::agent-memory/parse-forget-request("source slack:C123")
req.scope  // "source"
req.selector  // "slack:C123"
::agent-memory/parse-forget-request("").scope  // "session"

render-export-summary

fn (bundle: ::ai::memory/MemoryExport): Str

Render a concise summary of a memory export bundle.

Example

::agent-memory ::ai::agent::memory

bundle ::ai::memory/MemoryExport({agent-name: "team-agent", session: [], user: [], kb: []})
::agent-memory/render-export-summary(bundle)  // "Export bundle contains 0 records: 0 session, 0 user, 0 KB."

render-inspection

fn (inspection: MemoryInspection): Str

Render MemoryInspection as concise user-facing text.

Example

::agent-memory ::ai::agent::memory

bundle ::ai::memory/MemoryExport({agent-name: "team-agent", session: [], user: [], kb: []})
text ::agent-memory/render-inspection(::agent-memory/inspect-export(bundle, {capsule-count: 2}))
split(text, "\n")[0]  // "Memory snapshot:"
split(text, "\n")[4]  // "- Capsules: 2"

select-policy

fn (policies: Vec<RetentionPolicy>, name: Str?): RetentionPolicy

Select a retention policy by name, defaulting to the first policy or DEFAULT_RETENTION.

Example

::agent-memory ::ai::agent::memory

policies [
    ::agent-memory/RetentionPolicy({name: "short", raw-retention-secs: 86400}),
    ::agent-memory/RetentionPolicy({name: "long", raw-retention-secs: 2592000}),
]
::agent-memory/select-policy(policies, "long").name  // "long"
::agent-memory/select-policy(policies, "missing").name  // "short"
::agent-memory/select-policy([], null).name  // "default"

Types

ForgetRequest

ForgetRequest type {
    scope: Str,
    selector: Str,
    raw: Str
}

Parsed forget request from a command argument.

MemoryInspection

MemoryInspection type {
    session-count: Int,
    user-count: Int,
    kb-count: Int,
    capsule-count: Int,
    graph-node-count: Int,
    graph-edge-count: Int,
    metadata: Map?
}

Neutral memory-inspection response shape for agents.

RetentionPolicy

RetentionPolicy type {
    name: Str,
    raw-retention-secs: Int?,
    capsule-retention-secs: Int?,
    compact-after-secs: Int?,
    export-allowed: Bool?,
    forget-allowed: Bool?,
    metadata: Map?
}

Reusable retention policy shape for agent memory lifecycle jobs.