Skip to content

docs: an agent-memory how-to page, with every block run by a test - #498

Merged
tae898 merged 2 commits into
mainfrom
docs/306-agent-memory-page
Nov 27, 2026
Merged

tae898 merged 2 commits into
mainfrom
docs/306-agent-memory-page

Conversation

@tae898

@tae898 tae898 commented Nov 27, 2026 •

Copy link
Copy Markdown
Collaborator

What does this PR do?

Adds the how-to page "Agent memory" (docs/modules/ROOT/pages/how-to/agent-memory.adoc). It builds a small agent memory in one database, with messages as documents, facts linked in a graph, and an embedding on each fact:

  • store a fact with its links, and update it by key
  • read the latest five messages as dicts
  • search the nearest facts of one user
  • follow the links, in openCypher and after a vector search
  • forget an entity with its facts
  • remove duplicate facts
  • what a search sees right after a write, and how the vector index behaves as it grows

The statements are SQL and openCypher through db.command and db.query. The page gives no collection size from which the graph index beats an exact scan, because I have not measured one. It shows how to compare the two instead. The sizes and thresholds it does state come from the 26.12.1 engine sources.

While testing I found that on both packages a relative database path does not open the same directory after os.chdir. The page says to use an absolute path in that case, and the tests do so.

Related issues

Refs #306 (the docs page, item 4). The issue stays open for item 3, which needs a measurement first.

Docs

The new page, its nav entry, a link from "Vectors", and the list of how-to pages in README.md.

Checklist

  • tests/test_docs_agent_memory_page.py runs every block of the page on both packages, compares the printed output, and calls the page's functions on more data
  • The test suite that the change can affect passes (the checks below)
  • uvx pre-commit run --files <changed files> passes (ShellCheck and hadolint skipped, no shell or Docker file changed)

Item 4 of #306 asks for one page on agent-memory use. The page builds a small memory in one database: messages as documents, facts as vertices linked to what they mention, and an embedding on each fact. It covers the six tasks that the docs did not show (store with links, upsert by key, latest rows as dicts, filtered nearest neighbours, delete an entity with its facts, remove duplicates), what a search sees right after a write, and how the vector index behaves as it grows.

The statements are SQL and openCypher through db.command and db.query. The sizes and thresholds are read from the 26.12.1 engine sources, and the page says that it gives no size from which the graph beats an exact scan, because none was measured.

tests/test_docs_agent_memory_page.py runs every block on both packages and compares the printed text, reports every block that differs, and calls the page's functions on more data.

Refs #306
@tae898 tae898 added documentation Improvements or additions to documentation python Pull requests that update python code vector Vector indexes and find_nearest labels Nov 27, 2026
@tae898 tae898 self-assigned this Nov 27, 2026
The tests that reopen the page's database failed in CI on both packages: they ran the page after os.chdir and its path is relative. On the native package the run-again test counted the 5 facts of an earlier test, and on both packages the reopened database had no type Memory. The tests now replace the page's path with an absolute one, the run-again test checks that a row survives, and the page says to use an absolute path after os.chdir.
@tae898
tae898 merged commit a9a59ea into main Nov 27, 2026
24 checks passed
@tae898
tae898 deleted the docs/306-agent-memory-page branch November 27, 2026 07:38
@github-actions github-actions Bot added this to the 26.12.1 milestone Nov 27, 2026
@tae898 tae898 mentioned this pull request Nov 30, 2026
1 of 10 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation python Pull requests that update python code vector Vector indexes and find_nearest

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant