Documentation
Browse documentation

Using memory

Knowledge agents

A knowledge agent is a focused brain built from your notes. Collect everything about one topic, load it into a model session once, then ask it questions. It answers from your own history, such as "what are the hooks and when does each run?"

Before you start

  • An agent with MemIndex installed, so it has MemIndex's tools (build_corpus, prime_corpus, query_corpus). See Supported agents.
  • Notes on the topic you want. Building reads only your notes and costs nothing; priming and asking use your model account.

Build, prime, ask

  1. Build a collection of notes with a filter.
  2. Prime it, which loads those notes into a model session.
  3. Query it with as many follow-up questions as you like. The session remembers the conversation.

Your agent runs these as tools, or you can ask for the /knowledge-agent skill. Build one for the sign-in work in a project:

build_corpus name="login-expertise" description="Decisions about sign-in and timeouts" project="shop" query="login" limit=50
Corpus ready.
login-expertise — 4 observations; 335 estimated tokens; not primed
Decisions about sign-in and timeouts
Use prime_corpus before querying.

List what you have:

list_corpora
Knowledge corpora (1 of 1):

login-expertise — 4 observations; 335 estimated tokens; not primed
Decisions about sign-in and timeouts

Then prime it and ask:

prime_corpus name="login-expertise"
query_corpus name="login-expertise" question="Why do sign-in tokens last 15 minutes?"

Priming and querying use your model account, so they cost usage. Building does not, and a build reads only your notes.

Choose what goes in

build_corpus filters by any of these. Combine them to keep a corpus focused, because "hooks" works better than "everything":

  • project, to stay in one project.
  • types, a comma-separated list from decision, bugfix, feature, refactor, discovery, change, security_alert, security_note and sensitive.
  • concepts and files, comma-separated.
  • query, a search that picks the notes.
  • dateStart and dateEnd, an ISO date range.
  • limit, the most notes to include.

The name may hold letters, digits, dots, underscores and hyphens. Building with an existing name replaces it.

Keep it fresh

  • rebuild_corpus runs the stored filter again to pick up new notes. If the result would be much smaller than before, it refuses unless you pass force. Prime again afterward.
  • reprime_corpus starts a fresh session from the same notes. Use it when a conversation has drifted.

A corpus is a file named <name>.corpus.json in the corpora folder of your data folder. It holds the text of the notes, so treat it as private.

Next steps