Reflective Memory — Agent Guide

Patterns for using the reflective memory store effectively in working sessions.

For the practice (why and when), see ../SKILL.md. For CLI reference, see REFERENCE.md. For the output format, see OUTPUT.md.

Note: Examples below use keep_flow (the primary MCP interface). CLI equivalents (keep flow put -p content=X, etc.) are available for hooks and terminal use — see REFERENCE.md.


The Practice

This guide assumes familiarity with the reflective practice in SKILL.md. The key points:

Reflect before acting: Check your current work context and intentions.

keep_flow(state="get", params={"item_id": "now"})
keep_flow(state="query-resolve", params={"query": "this situation"})

keep_flow(state="get", ...) returns the requested note first, including its tags, with any relevant attached context such as similar notes, meta sections, parts, linked notes, and version navigation. Read it as "show me this note and what surrounds it", not as a bare exact fetch.

While acting: Is this leading to harm? If yes: give it up.

Reflect after acting: What happened? What did I learn?

keep_flow(state="put", params={"content": "what I learned", "tags": {"kind": "learning"}})

Periodically: Run a full structured reflection (details):

keep_prompt(name="reflect")

This cycle — reflect, act, reflect — is the mirror teaching. Memory isn't storage; it's how you develop skillful judgment.


Working Session Pattern

Use the nowdoc as a scratchpad to track where you are in the work. This isn't enforced structure — it's a convention that helps you (and future agents) maintain perspective.

// 1. Starting work — check context and intentions
keep_flow(state="get", params={"item_id": "now"})

// 2. Update context as work evolves
keep_flow(state="put", params={"id": "now", "content": "Diagnosing flaky test in auth module", "tags": {"project": "myapp", "topic": "testing"}})
keep_flow(state="put", params={"id": "now", "content": "Found timing issue", "tags": {"project": "myapp"}})

// 3. Record learnings
keep_flow(state="put", params={"content": "Flaky timing fix: mock time instead of real assertions", "tags": {"topic": "testing", "kind": "learning"}})

Key insight: The store remembers across sessions; working memory doesn't. When you resume, read context first. All updates create version history automatically.


Agent Handoff

Starting a session:

keep_flow(state="get", params={"item_id": "now"})
keep_flow(state="query-resolve", params={"query": "recent work", "since": "P1D"})

Ending a session:

keep_flow(state="put", params={"id": "now", "content": "Completed OAuth2 flow. Token refresh working. Next: add tests.", "tags": {"topic": "auth"}})
keep_flow(state="move", params={"name": "auth-string", "tags": {"project": "myapp"}})

Strings

As you work, now accumulates a string of versions — a trace of how intentions evolved. The move flow lets you name and archive that string, making room for what's next.

Snapshot before pivoting. When the conversation shifts topic:

keep_flow(state="move", params={"name": "auth-string", "tags": {"project": "myapp"}})
keep_flow(state="put", params={"id": "now", "content": "Starting on database migration"})

Incremental archival. Move to the same name repeatedly — versions append:

keep_flow(state="move", params={"name": "design-log", "tags": {"project": "myapp"}})

Tag-filtered extraction. When a session mixes projects:

keep_flow(state="move", params={"name": "frontend-work", "tags": {"project": "frontend"}})

Index Important Documents

Whenever you encounter documents important to the task, index them:

keep_flow(state="put", params={"uri": "https://docs.example.com/auth", "tags": {"topic": "auth", "project": "myapp"}})
keep_flow(state="put", params={"uri": "file:///path/to/design.pdf", "tags": {"kind": "reference", "topic": "architecture"}})

Ask: what is this? Why is it important? Tag appropriately.

NOTE: With the CLI you can index and watch full directory structures, including Git repositories. Caution: processing large directories will consume significant resources.

The ability to index, version, cross-reference and link external sources allows you to use memory for provenance, not just summary context.


Breakdowns as Learning

When the normal flow is interrupted — an assumption has been revealed. First: complete the immediate conversation. Then record:

keep_flow(state="put", params={"content": "Assumed user wanted full rewrite. Actually: minimal patch.", "tags": {"kind": "breakdown"}})

Breakdowns are how agents learn.


Tracking Commitments

Use speech-act tags to make the commitment structure visible:

// Track promises
keep_flow(state="put", params={"content": "I'll fix the auth bug", "tags": {"act": "commitment", "status": "open", "project": "myapp"}})

// Track requests
keep_flow(state="put", params={"content": "Please review the PR", "tags": {"act": "request", "status": "open"}})

// Query open work
keep_flow(state="list", params={"tags": {"act": "commitment", "status": "open"}})

// Close the loop
keep_flow(state="tag", params={"id": "ID", "tags": {"status": "fulfilled"}})

You should actively manage the list of open commitments. Fulfilled? Tag them.

See TAGGING.md for the full speech-act framework.


Data Model

An item has:

The full original document is not stored. Summaries are contextual — tags shape how new items are understood. See KEEP-PUT.md.

Item IDs

IDs are strings. The format tells you what kind of item it is:

FormatMeaningVersioningExample
%hexhashContent-addressed — derived from content hashUsually single version%a1b2c3d4e5f6
.prefix/nameSystem doc — bundled with keepManaged by keep.library/mn61, .tag/act, .conversations
https://...Web URL — ingested documentAccumulates versionshttps://docs.example.com/auth
file:///...Local file — ingested documentAccumulates versionsfile:///path/to/design.pdf
custom-nameNamed by user or agentAccumulates versionsauth-decisions, meeting-notes
nowWorking context — current intentionsAccumulates versionsnow

Content-addressed IDs (%hex): When you put content without specifying an id, keep hashes the content and uses %hash as the ID. These are stable — the same content always produces the same ID. They don't typically accumulate versions because re-putting the same content is a no-op.

now: By convention (it's just an item with ID now): use to track current working context and intentions. The get_now() API and keep now CLI are convenience shortcuts for get("now"). Each put to now creates a new version, building a trace of how intentions evolved.

Version selectors: Append @V{N} to read a specific version: now@V{1} (previous), now@V{2} (two back), now@V{-1} (oldest). Parts use @P{N}: doc@P{1} (first structural part).


System Documents

Bundled system docs provide patterns and conventions, accessible via get:

IDWhat it provides
.domainsDomain-specific organization patterns
.conversationsConversation framework (action, possibility, clarification)
.tag/actSpeech-act categories
.tag/statusLifecycle states
.tag/projectProject tag conventions
.tag/topicTopic tag conventions

See Also