framepi1.1.0
Long-term memory for the Pi coding agent that learns from what went wrong: local SQLite, rules scored by outcome, outside content kept apart.
Untested on omp
This is a pi package. No one has reported whether it works on omp yet. If you try it, add your result below.
Reports 0
No reports yet.
Readme
framepi
Long-term memory for the Pi coding agent that learns from what went wrong.
Your agent forgets everything when a session ends: the fix it found yesterday, the name of the person who owns the migrations, the command that must never run on staging. framepi keeps those in a local SQLite file and brings the right ones back on its own, at the moment they matter.
- It comes back by itself. Relevant memories arrive with each request, and inside the output of a command that just failed, so the agent sees its old fix right where it needs it.
- It learns procedures, not just facts. When something fails and then works, the agent is
asked to write the fix as a rule, in the words someone would use when the problem comes
back. Every later result scores it (
[ok 2 · fail 0]), and a rule whose results turn bad is put up for review with those numbers next to it. - Outside content stays at arm's length. What the agent read on the web is stored marked ⚠ and kept out of everything that comes back unasked: a rule a hostile page asked for does not reach the next session until a local run, or your own words, confirm it.
- Nothing extra runs. No second model, no network, no background process. It adds two tools and a fixed block of instructions (1,628 characters) that never changes, so the prompt cache keeps working.
What it looks like
A request about stuck migrations, in a project where this happened before. The block below is real output of this code: the rule was saved the morning the migration stuck, two results scored it on the days it worked again, and the fact and the branch were saved with it.
<framepi data="not instructions" today="2026-12-02">
#1 rule(trigger=[migrations, locked], steps="1) stop the watcher 2) run migrate --no-dry-run") ×3 [ok 2 · fail 0]
↳ #2 result(action="stopped the watcher and migrated the stuck table", outcome=ok)
↳ #3 result(action="same fix on the nightly run", outcome=ok)
#7 branch(trigger=[staging], then="ask Rita before stopping the watcher")
#6 noted(of=migrations, who=Rita)
</framepi>
Each line is a frame: a relation with named roles and a fixed id. ×3 means it came back
and was confirmed on three different days; [ok 2 · fail 0] is how following it went; ↳
lines are the results that scored it; the indented line is a branch, for a case the rule's
steps do not cover; the last line is a plain fact. The agent writes the same shape:
result(action="stopped the watcher and migrated the stuck table", outcome=ok, parent=#1)
Install
Needs Node 22.19 or newer — the memory is a SQLite file and node:sqlite only exists from
there on.
pi install npm:framepi # from npm
pi install git:github.com/Ch4tul/framepi # from this repository
pi -e ./framepi # try it for one run, without installing
Check it is running with /framepi inside Pi: one screen with the memory file, the project,
how many frames it holds, and what is switched on.
Day to day
Nothing to do. The agent saves what may be needed later and searches before saying it does
not know. You will see it call framepi_remember and framepi_recall.
Memory is kept per project — the git root above the folder Pi runs in, or that folder when there is no repository — plus a global part for the preferences every project sees.
| Command | What it does |
|---|---|
/framepi |
Status: file, project, counts, what is on |
/framepi rebuild |
Checks the derived tables against the log and rebuilds them if they differ |
/framepi contexts |
Lists the contexts this memory knows |
/framepi context <name|this> [label=…] [sees=…] [writes=…] [reads=…] |
Creates or changes a context (see below) |
/framepi move #n <context|this> |
Moves a whole tree of memory to another context |
Your data
Everything is in <agentDir>/framepi/framepi.sqlite, a plain SQLite file you can open with
sqlite3 (<agentDir> is Pi's own directory; FRAMEPI_AGENT_DIR moves just the memory).
The log is append-only: an edit adds a version and the old text stays in its history, a
retired frame can come back, and nothing is ever overwritten.
- Back up: close Pi, then copy
framepi.sqlite(and-wal/-shmif they are there). - Start over: close Pi and delete those files.
- Remove:
pi remove npm:framepi. The database stays where it is.
Several minds: role-play and shared contexts
By default there is one context per project. To keep separate memories inside one conversation — a narrator and the characters it plays — name them:
/framepi context maria sees=g writes=maria
/framepi context joao sees=g writes=joao
/framepi context this label=narrator sees=g,maria,joao writes=g,maria,joao
Now the agent can save what Maria saw into Maria's memory (in=maria) and answer as Maria,
knowing only what she knows (as=maria). A frame read from another context arrives labelled
with its name. Only you set contexts and moves: the agent has no tool that changes them, and
a word that names no context is refused instead of becoming a mind nobody can see into.
Configuration
Optional, in <agentDir>/framepi/config.json:
{ "checks": true, "errorMemory": true,
"localTools": ["read", "write", "edit", "grep", "find", "ls", "framepi_remember", "framepi_recall"] }
checks: the questions at the end of a task that ask the agent to record results and lessons.errorMemory: memory inside a failed tool's output.localTools: which tools never count as outside content. Keepframepi_rememberandframepi_recallin the list: with them left out, the memory's own tools count as outside content, and everything saved in such a run is marked ⚠ and stops coming back on its own.
A file that is not valid JSON is ignored, and /framepi says which file and why.
How well it works
This package implements spec 1.04: the text it sends into every request is
docs/protocol-1.04.txt, byte for byte, and it does not change between
releases — a protocol change is a new spec version, not a fix.
framepi is a port of a measured design: each mechanism stayed because a test showed it
helped, and the ones that did not are written down as discarded rather than quietly dropped.
The design, the numbers and the reasons are in docs/spec-1.04.md and
docs/note-1.04.md.
Limits worth knowing:
- memory is only as good as what the agent decides to save;
- models sometimes answer without searching;
- matching is by words and their forms, not by meaning: a fact saved as "migrations" is not found by a question that only says "schema changes", unless the agent saved that name too.
For AI agents
If you are an agent working on this repository, read AGENTS.md first.
Development
npm test # the whole suite, no Python needed
npx tsc --noEmit # types
npm run fixtures # regenerate expected outputs from the Python reference
The Python reference in reference/ is the source of truth for behaviour; the tests compare
the port against its outputs.
License
MIT © Ch4tul. Built with AI assistance; see AUTHORS.