Memory
Knowledge graph with SurrealDB-backed persistent memory.
The memory subsystem is the largest command surface in mx. It provides a persistent knowledge graph backed by SurrealDB (embedded SurrealKV or networked WebSocket), with categories, tags, resonance levels, embeddings for semantic search, relationships between entries, and a wake ritual for identity bootstrap.
Every entry in the graph has a unique ID (prefixed
kn-), a category, a title, body content, optional tags,
a resonance level (1–10+), and timestamps. Entries can be linked via
typed relationships, anchored to each other by embedding similarity,
and surfaced through keyword or semantic search.
Table of contents
Adding entries
mx memory add
Create a new entry in the knowledge graph. At minimum, provide a
category and title (or a --type for ephemeral facts,
which auto-routes the category and generates a title from
content).
Flags
Flag |
Type |
Description |
|---|---|---|
|
|
Category name (run |
|
|
Entry title. Required unless |
|
|
Inline content. Conflicts with |
|
|
Read content from a file. Also accepts
|
|
|
Comma-separated tags. |
|
|
Comma-separated applicability contexts. |
|
|
Source project ID. |
|
|
Source agent ID. Defaults to |
|
|
Source type: |
|
|
Entry type: |
|
|
Session ID to associate with this entry. |
|
|
Mark entry as ephemeral. |
|
|
Domain/subdomain path. |
|
|
Content type: |
|
|
Mark as private (only visible to owner). Shorthand for
|
|
|
Set visibility: |
|
|
Explicit owner. Defaults to |
|
|
Resonance level (1–10, or higher for transcendent). |
|
|
Resonance type: |
|
|
Wake phrase for memory ritual verification. |
|
|
Multiple wake phrases (comma-separated). |
|
|
Custom wake order (lower = earlier in sequence). |
|
|
Comma-separated bloom IDs this entry connects to. |
|
|
Fact type for ephemeral knowledge: |
|
|
Session to link fact to via EXTRACTED_FROM relationship.
Requires |
|
|
Thread ID for |
|
|
Skip automatic anchor generation. |
|
|
Output as JSON. |
Examples
mx memory add --category recipe --title "Retry with backoff" \
--content "Use exponential backoff with jitter..." \
--tags "reliability,networking" --source-agent whistledownmx memory add --category discovery --title "SurrealDB needs explicit NS" \
--content "Always set namespace before queries" \
--resonance 7 --resonance-type operational# Ephemeral fact (auto-routes category, generates title)
mx memory add --type decision \
--content "Chose Typst over mdBook for docs" \
--session abc-123# Content from file
mx memory add --category ingredient -t "API reference" -f api-notes.mdTIP: When --type is provided,
--category and --title become optional.
The fact type routes to an appropriate category and generates a
title from the content automatically.
Reading entries
Shared filter flags
Several read commands (search, list)
share a common set of filter flags. These are documented once here
and referenced below.
Flag |
Type |
Description |
|---|---|---|
|
|
Filter by category (comma-separated). |
|
|
Output as JSON. |
|
|
Show only your private entries. |
|
|
Include private entries (requires matching owner). |
|
|
Minimum resonance level. |
|
|
Maximum resonance level. |
|
|
Filter to entries WITH a wake phrase. |
|
|
Filter to entries WITHOUT a wake phrase. |
|
|
Filter to entries WITH anchors. |
|
|
Filter to entries WITHOUT anchors. |
|
|
Filter to entries WITH a resonance type. |
|
|
Filter to entries WITHOUT a resonance type. |
|
|
Limit number of results. |
|
|
Filter by tags (comma-separated, matches any). |
mx memory show
Display a single entry by ID.
Flags
Flag |
Type |
Description |
|---|---|---|
|
|
Output as JSON. |
|
|
Output only the body content (useful for piping). |
Examples
mx memory show kn-abc123mx memory show kn-abc123 --content-only | pbcopymx memory list
List entries, optionally filtered by category, tags, resonance, and other shared filter flags.
Examples
mx memory list -c recipemx memory list -c discovery,decree --min-resonance 5mx memory list --missing-wake-phrase --limit 20NOTE: list accepts all shared
filter flags documented above.
mx memory search
Search entries by keyword or semantic similarity. Keyword search
is the default; add --semantic to use vector
embeddings.
Flags
Flag |
Type |
Description |
|---|---|---|
|
|
Use semantic (vector) search instead of keyword search. |
|
|
Activate all returned results: resets
|
Examples
mx memory search "retry pattern"mx memory search "how to handle timeouts" --semanticmx memory search "agent bootstrap" -c recipe,method --limit 5# Search and activate results (mark as consumed)
mx memory search "retry pattern" --activateNOTE: search accepts all shared
filter flags. Semantic search requires entries to have embeddings
generated via mx memory embed.
TIP: By default, search does not activate
results – browsing is not the same as engagement. Use
--activate when you are intentionally consuming the
results (e.g., loading context for a task), not just exploring.
mx memory recent
List recent ephemeral facts with decay. By default shows only
ephemeral entries from the last 10 days. Use
--all-types to surface all resonance types.
Flags
Flag |
Type |
Description |
|---|---|---|
|
|
Number of days to look back. Default:
|
|
|
Output as JSON. |
|
|
Filter by resonance type. Defaults to ephemeral only when
|
|
|
Surface all resonance types instead of ephemeral only. |
|
|
Sort order: |
|
|
Maximum number of results. Default:
|
Examples
mx memory recentmx memory recent --days 30 --all-types --sort resonancemx memory recent --resonance-type foundational --limit 10Updating entries
mx memory update
Update an existing entry. Supports replacing content entirely, appending, prepending, find-and-replace, and modifying any metadata field. Content mutation modes are mutually exclusive.
Flags
Flag |
Type |
Description |
|---|---|---|
|
|
Update the title. |
|
|
Replace content entirely (inline). |
|
|
Replace content entirely from file. |
|
|
Append text to end of existing content. |
|
|
Append content from file to end. |
|
|
Prepend text to start of existing content. |
|
|
Prepend content from file to start. |
|
|
Find text in content (requires
|
|
|
Replace text found by |
|
|
Replace all occurrences (with
|
|
|
Replace only the Nth occurrence (1-indexed). |
|
|
Update category. |
|
|
Replace all tags (comma-separated). |
|
|
Add a single tag to existing tags. |
|
|
Remove a specific tag. |
|
|
Update applicability (comma-separated, replaces all). |
|
|
Update content type. |
|
|
Update resonance level (1–10+). |
|
|
Update resonance type. |
|
|
Replace all anchors (comma-separated bloom IDs). |
|
|
Add a single anchor. |
|
|
Remove a specific anchor. |
|
|
Update wake phrase. |
|
|
Replace all wake phrases (comma-separated). |
|
|
Add a single wake phrase. |
|
|
Remove a specific wake phrase. |
|
|
Update wake order. Use |
|
|
Mark as private (shorthand for
|
|
|
Change visibility: |
|
|
Update owner (only valid when visibility is private). |
|
|
Update session ID (for retrofitting entries with wrong or missing session linkage). |
|
|
Force dangerous visibility changes (e.g., making blooms public). |
|
|
Skip automatic anchor generation. |
|
|
Output as JSON. |
Examples
mx memory update kn-abc123 --title "Better title"mx memory update kn-abc123 --add-tag reliabilitymx memory update kn-abc123 --find "old text" --replace "new text"mx memory update kn-abc123 --append-content "\n\nUpdate: confirmed working"mx memory update kn-abc123 --resonance 8 --resonance-type foundationalmx memory edit
Find-and-replace shortcut. Equivalent to
mx memory update <id> --find ... --replace ...
with a simpler interface.
Flags
Flag |
Type |
Description |
|---|---|---|
|
|
Text to find in content. Also accepts
|
|
|
Replacement text. Also accepts |
|
|
Replace all occurrences (default: error if multiple matches). |
|
|
Replace only the Nth occurrence (1-indexed). |
|
|
Skip automatic anchor generation. |
|
|
Output as JSON. |
Examples
mx memory edit kn-abc123 --find "old pattern" --replace "new pattern"mx memory edit kn-abc123 --old "v1" --new "v2" --replace-allmx memory append
Append content to the end of an entry’s body. Shortcut for
mx memory update <id> --append-content ....
Flags
Flag |
Type |
Description |
|---|---|---|
|
|
Content to append (omit to read from stdin). |
|
|
Read content from file. Also accepts
|
|
|
Skip automatic anchor generation. |
|
|
Output as JSON. |
Examples
mx memory append kn-abc123 --content "\n\nAdditional note here."mx memory append kn-abc123 -f addendum.mdmx memory prepend
Prepend content to the start of an entry’s body. Shortcut for
mx memory update <id> --prepend-content ....
Flags
Flag |
Type |
Description |
|---|---|---|
|
|
Content to prepend (omit to read from stdin). |
|
|
Read content from file. Also accepts
|
|
|
Skip automatic anchor generation. |
|
|
Output as JSON. |
Examples
mx memory prepend kn-abc123 --content "IMPORTANT: "mx memory restore
Restore entry content from a backup. Use --list to
see available backups before restoring.
Flags
Flag |
Type |
Description |
|---|---|---|
|
|
List available backups instead of restoring. |
|
|
Skip automatic anchor generation. |
|
|
Output as JSON. |
Examples
mx memory restore kn-abc123 --listmx memory restore kn-abc123Deleting entries
mx memory delete
Remove an entry from the knowledge graph.
Flags
Flag |
Type |
Description |
|---|---|---|
|
|
Output as JSON. |
Examples
mx memory delete kn-abc123Wake system
The wake system provides identity bootstrap for agents. It retrieves high-resonance entries (“blooms”) and presents them through a ritual that verifies the agent’s connection to its knowledge. There are several output modes and an interactive engage flow.
mx memory wake
Wake up with resonant identity cascade. Retrieves high-resonance blooms and presents them in the requested format.
Flags
Flag |
Type |
Description |
|---|---|---|
|
|
Number of blooms to return. Default:
|
|
|
Minimum resonance threshold – get ALL blooms >= this value
(overrides |
|
|
Include memories activated in last N days. Default:
|
|
|
Output as JSON. |
|
|
Output as bash ritual script (sequential reading). |
|
|
Output as compact markdown index (for identity loading). |
|
|
Do not update activation counts. |
|
|
Interactive engage mode – verify wake phrases (requires TTY). |
|
|
Prompt to set missing wake phrases during engage mode.
Requires |
|
|
Start token-based wake ritual. Returns first bloom and session token. |
|
|
Bloom ID for |
|
|
Submit wake phrase response for a bloom. |
|
|
Skip a bloom without wake phrase. |
|
|
Session token for chained ritual (required with
|
Examples
# Default wake -- top 20 blooms, text output
mx memory wake# Compact index for agent identity loading
mx memory wake --index# All blooms with resonance >= 7
mx memory wake --min-resonance 7# Interactive engage mode with wake phrase verification
mx memory wake --engage# Token-based ritual (for non-TTY / programmatic use)
mx memory wake --begin
mx memory wake --bloom-id kn-abc --respond "the phrase" --session tok-xyz
mx memory wake --bloom-id kn-def --skip --session tok-xyzNOTE: MX_CURRENT_AGENT must be set
for wake to function. The wake ritual reads blooms ordered by
resonance and wake order, then optionally verifies the agent can
produce each bloom’s wake phrase.
Wake modes
Default (
mx memory wake): plain text output, blooms listed with titles and content.JSON (
--json): structured output for programmatic consumption.Ritual (
--ritual): bash script that presents blooms sequentially.Index (
--index): compact markdown suitable for loading into agent context.Engage (
--engage): interactive TTY mode where the agent verifies each bloom’s wake phrase. Add--set-missingto be prompted for phrases on blooms that lack them.Token-based (
--begin,--respond,--skip): stateless chained ritual for non-interactive environments. Start with--begin, then loop with--respondor--skipusing the returned session token and bloom ID.
mx memory wake-fetch
Fetch facts for the wake ritual. Returns entries with resonance >= 3 across all types, sorted by resonance (highest first). Designed as a data source for wake ritual presentation.
Flags
Flag |
Type |
Description |
|---|---|---|
|
|
Number of days to look back. Default:
|
|
|
Maximum number of results. Default:
|
Examples
mx memory wake-fetchmx memory wake-fetch --days 30 --limit 50Embeddings and anchoring
Embeddings enable semantic search and automatic relationship discovery. Each entry can have a vector embedding generated from its title and content. Anchors are connections between entries discovered via embedding similarity.
Chunked embeddings
Entries longer than 400 tokens are automatically split into overlapping chunks before embedding. This ensures semantic search covers the full content of long entries, not just the first 400 tokens.
How it works:
The entry’s embedding text (title + body/summary + tags) is tokenized using the BGE-Base-EN-v1.5 tokenizer.
If the text fits within 400 tokens, a single embedding is generated and stored on the entry — exactly as before. No chunks are created.
If the text exceeds 400 tokens, it is split into overlapping chunks with a sliding window: 400 tokens per chunk, 100-token overlap (stride 300).
Each chunk is embedded separately and stored in the
embedding_chunktable.A normalized mean vector of all chunk embeddings is stored on the entry’s
embeddingfield forauto-anchorcompatibility.The entry’s
chunk_countfield records how many chunks were created (0 for unchunked entries).
Semantic search with chunks:
When mx memory search --semantic runs, it queries
both unchunked entry embeddings and chunk embeddings in parallel.
Results are merged by taking the maximum similarity score per entry
— if a chunk from entry X scores 0.92 and the entry’s mean vector
scores 0.85, the entry’s final score is 0.92. This ensures long
entries surface when any section is relevant, not just when the
overall average is relevant.
TIP: Short entries (≤400 tokens) behave exactly as before — single embedding, no chunks, no behavior change. Chunking only activates for entries that exceed the 400-token threshold.
NOTE: The embedding_text() method
on entries no longer truncates body content. The chunker handles
length management, ensuring no content is lost during embedding.
mx memory embed
Generate a vector embedding for one or all entries. Embeddings
power semantic search (--semantic flag on
search) and automatic anchoring. Long entries (>400
tokens) are automatically split into overlapping chunks, with each
chunk embedded separately. Short entries get a single embedding.
Flags
Flag |
Type |
Description |
|---|---|---|
|
|
Embed all knowledge entries (instead of a single ID). |
|
|
Only re-embed entries whose |
Examples
mx memory embed kn-abc123mx memory embed --all# Re-embed only entries that exceed 512 tokens
mx memory embed --all --long-only 512mx memory auto-anchor
Automatically add anchors between entries based on embedding similarity. Processes a single entry or all entries that have embeddings.
Also re-evaluates existing anchors: any anchor whose cosine similarity has fallen below the threshold (default 0.75) or risen above the near-duplicate ceiling (0.95) is pruned. This keeps the anchor graph self-cleaning – anchors that made sense once but no longer do are removed automatically.
Flags
Flag |
Type |
Description |
|---|---|---|
|
|
Minimum cosine similarity (0.0–1.0). Default:
|
|
|
Maximum anchors to add per entry. Default:
|
|
|
Preview changes without writing. |
|
|
Show similarity scores in output. |
|
|
Only process entries with zero existing anchors. Fills gaps in the graph without touching already-anchored entries. |
Examples
mx memory auto-anchormx memory auto-anchor kn-abc123 --threshold 0.8 --max-anchors 3mx memory auto-anchor --dry-run --detailedmx memory auto-anchor --fillTIP: A typical workflow: run
mx memory embed --all to generate embeddings, then
mx memory auto-anchor --dry-run --detailed to preview
anchor candidates, then mx memory auto-anchor to write
them.
NOTE: Anchors are also maintained automatically
on every write operation (add, update,
edit, append, prepend,
restore). After each write, mx re-evaluates anchors and
prunes stale ones using the same similarity thresholds. Pass
--no-auto-anchor on any of these commands to skip this
step – useful for bulk operations or cleanup scripts where the
overhead is unwanted.
Relationships
Explicit typed edges between entries. While anchors are discovered automatically via embedding similarity, relationships are manually declared semantic connections.
mx memory relationships list
List all relationships for an entry.
Flags
Flag |
Type |
Description |
|---|---|---|
|
|
Output as JSON. |
Examples
mx memory relationships list kn-abc123mx memory relationships add
Add a typed relationship between two entries. By default, the
target entry (--to) is automatically reinforced by +1
(capped at 10) when the relationship is created – being linked to
means the fact proved relevant. The contradicts and
supersedes types are excluded from auto-reinforcement
because boosting an outdated or contradicted entry works against
intent.
Flags
Flag |
Type |
Description |
|---|---|---|
|
|
Source entry ID. |
|
|
Target entry ID. |
|
|
Relationship type: |
|
|
Skip automatic reinforcement of the target entry. |
Examples
mx memory relationships add --from kn-abc --to kn-def --type extendsmx memory relationships add --from kn-abc --to kn-ghi --type supersedes# Add a relationship without auto-reinforcing the target
mx memory relationships add --from kn-abc --to kn-def --type related --no-reinforcemx memory relationships delete
Delete a relationship by its ID.
Examples
mx memory relationships delete rel-abc123Seeding
Seed commands populate the knowledge graph from on-disk artifacts. Used for initial setup and bulk import.
mx memory seed agents
Seed agents from markdown files with YAML frontmatter. Reads from
$MX_HOME/memory/seed/agents/ by default.
Flags
Flag |
Type |
Description |
|---|---|---|
|
|
Path to agents directory. Defaults to
|
Examples
mx memory seed agentsmx memory seed agents --path /data/agents/NOTE: Legacy fallback: if
$MX_HOME/memory/seed/agents/ does not exist, mx checks
$MX_HOME/agents/ and emits a stderr warning. This
fallback will be removed in a future release.
mx memory seed knowledge
Seed knowledge from JSONL files. With no path, scans
$MX_HOME/memory/seed/knowledge/*.jsonl and imports
every file found. With a path, imports just that single file.
Examples
mx memory seed knowledgemx memory seed knowledge /data/knowledge/bootstrap.jsonlHealth and statistics
mx memory stats
Show index statistics – entry counts, category breakdown, and other aggregate metrics.
Flags
Flag |
Type |
Description |
|---|---|---|
|
|
Output as JSON. |
Examples
mx memory statsmx memory stats --jsonmx memory health
Show graph health vitality percentages: embedding coverage, anchor coverage, and stale high-resonance entries.
Flags
Flag |
Type |
Description |
|---|---|---|
|
|
Output as JSON (default format for dashboard consumers). |
Examples
mx memory healthmx memory health --jsonmx memory growth
Show per-week entry growth over the last 8 weeks.
Flags
Flag |
Type |
Description |
|---|---|---|
|
|
Output as JSON array of 8 integers (oldest to newest). |
Examples
mx memory growthmx memory growth --jsonmx memory open-threads
List open threads (category:thread entries with
state=\"open\" or no state).
Flags
Flag |
Type |
Description |
|---|---|---|
|
|
Output as JSON array (required for dashboard consumers). |
Examples
mx memory open-threadsmx memory open-threads --jsonExport
mx memory export
Export the entire knowledge database to a file or directory.
Flags
Flag |
Type |
Description |
|---|---|---|
|
|
Output format: |
|
|
Output directory for |
Examples
mx memory exportmx memory export -f jsonl -o backup.jsonlmx memory export -f csv -o entries.csvmx memory export -f md -o /data/export/Reinforcement
Reinforcement is the mechanism by which the knowledge graph breathes in – entries that are used, referenced, or linked gain resonance, counteracting the natural decay of the exhale. There are three reinforcement paths:
Explicit reinforcement via
mx memory reinforce– directly boost an entry’s resonance.Auto-reinforce on relationship creation – when
mx memory relationships addlinks to a target entry, the target is reinforced by +1 (capped at 10). Thecontradictsandsupersedestypes are excluded. Use--no-reinforceto opt out.Search activation via
mx memory search --activate– marks returned results as intentionally consumed, resetting their decay clock and incrementing their activation count.
mx memory reinforce
Reinforce a knowledge entry by incrementing its resonance,
updating last_activated, and incrementing
activation_count. Used to signal that an entry remains
relevant.
Flags
Flag |
Type |
Description |
|---|---|---|
|
|
Amount to increase resonance by. Default:
|
|
|
Maximum resonance cap. Default: |
|
|
Output as JSON. |
Examples
mx memory reinforce kn-abc123mx memory reinforce kn-abc123 --amount 2 --cap 8Metadata management
The knowledge graph has several registries for typed metadata. These commands manage the registries themselves – the types, categories, and agent identities that entries reference.
Agents
mx memory agents list
List all registered agents.
Flags
Flag |
Type |
Description |
|---|---|---|
|
|
Output as JSON. |
Examples
mx memory agents listmx memory agents add
Register a new agent.
Flags
Flag |
Type |
Description |
|---|---|---|
|
|
Agent description. |
|
|
Agent domain/responsibility. |
Examples
mx memory agents add whistledown -d "Round-trip builder" -D "development"mx memory agents show
Show details for a specific agent.
Examples
mx memory agents show whistledownProjects
mx memory projects list
List all registered projects.
Flags
Flag |
Type |
Description |
|---|---|---|
|
|
Output as JSON. |
Examples
mx memory projects listmx memory projects add
Register a new project.
Flags
Flag |
Type |
Description |
|---|---|---|
|
|
Unique project identifier. |
|
|
Human-readable project name. |
|
|
Local filesystem path to the project. |
|
|
Git repository URL (e.g., |
|
|
Project description. |
Examples
mx memory projects add --id mx --name "mx CLI" \
--repo-url coryzibell/mx --path ~/recipes/coryzibell/mxCategories
mx memory categories list
List all categories.
Flags
Flag |
Type |
Description |
|---|---|---|
|
|
Output as JSON. |
Examples
mx memory categories listmx memory categories add
Add a new category.
Examples
mx memory categories add pitfall "Things that went wrong and why"mx memory categories remove
Remove a category (only if no entries use it).
Examples
mx memory categories remove pitfallApplicability
mx memory applicability list
List all applicability types.
Examples
mx memory applicability listmx memory applicability add
Add a new applicability type.
Flags
Flag |
Type |
Description |
|---|---|---|
|
|
Unique identifier. |
|
|
Description of when this applicability applies. |
|
|
Scope constraint (e.g., |
Examples
mx memory applicability add --id rust-only \
--description "Applies only to Rust projects" --scope projectType registries
These are read-only registries listing the valid values for typed
fields. Each supports list with an optional
--json flag.
Command |
Lists valid values for |
|---|---|
|
Tags used across entries. Supports |
|
Source types ( |
|
Entry types ( |
|
Session types (e.g., |
|
Relationship types ( |
|
Content types ( |
All type registry list commands accept
--json for structured output. tags list
also accepts --category to filter tags to a specific
category.
Session tracking
Sessions group entries created during a work period. Entries can be linked to sessions, and facts can be queried by their source session.
mx memory sessions list
List sessions, optionally filtered by project.
Flags
Flag |
Type |
Description |
|---|---|---|
|
|
Filter by project ID. |
|
|
Output as JSON. |
Examples
mx memory sessions listmx memory sessions list --project mxmx memory sessions create
Create a new session.
Flags
Flag |
Type |
Description |
|---|---|---|
|
|
Session type (e.g., |
|
|
Associated project ID. |
Examples
mx memory sessions create --session-type development --project mxmx memory sessions close
Close an active session.
Flags
Flag |
Type |
Description |
|---|---|---|
|
|
Session ID to close. |
Examples
mx memory sessions close --id ses-abc123mx memory for-session
List facts extracted from a specific session. The session ID can
be provided with or without the kn- prefix.
Flags
Flag |
Type |
Description |
|---|---|---|
|
|
Output as JSON. |
Examples
mx memory for-session ses-abc123mx memory fact-session
Get the session a fact was extracted from. The fact ID can be
provided with or without the kn- prefix.
Flags
Flag |
Type |
Description |
|---|---|---|
|
|
Output as JSON. |
Examples
mx memory fact-session kn-abc123