memharness

v0.1.2
io.github.las7/memharness Checked 14 hours ago Published 5 months ago

Bi-temporal, provenance-carrying long-term memory for AI agents, in one SQLite file.

These tools were reported by the server itself during our smoke test (tools/list), not copied from the README.

remember

Store ONE atomic fact in long-term memory: a single assertion, ideally one sentence (aim for under 250 characters; writes over 1500 are rejected). Split compound knowledge into multiple remember calls so each piece can be revised independently later. Use for durable knowledge about the user, their projects, preferences, decisions, and environment — not transient task state. If this contradicts an existing belief, find it with recall and use revise instead. Always fill source_ref with where this came from (session, file, URL) if known. If the fact describes code you just read at a known commi…

ParameterTypeDescription
fact *stringThe atomic statement itself
subject *stringWhat the fact is about, e.g. 'user' or 'project:memharness'
basisstringHow you know this: user-stated (they told you), verified (you checked directly), reported (read in docs/code but not confirmed), inferred (your deduction). Sets confidence. Default user-stated
confidencenumberNumeric override for basis; rarely needed
importanceinteger1–10 salience: how strongly this should rank up and resist decay. Default 5 (neutral). Reserve 8–10 for durable, high-stakes facts (core identity, hard constraints); 1–3 for incidental detail.
kindstringsemantic = stable facts/preferences (slow decay), episodic = events/one-offs (fast decay), procedural = how-to/workflow (slow decay). Default semantic.
predicatestringOptional relation type, e.g. 'prefers', 'works-on'
source_agentstringWhich agent/app is writing this
source_commitstringGit SHA you read this code at; pins the fact for staleness checking. Omit for non-code facts.
source_pathstringRepo-relative file path this fact describes, if any.
source_refstringWhere this came from: session id, file path, URL, utterance
valid_fromstringISO 8601: when this became true in the world, if not now

recall

Retrieve relevant memories. A plain call returns current beliefs ranked by relevance × confidence × importance × recency (recency is freshened each time a fact is recalled). as_of (ISO date, e.g. '2026-06-01') returns what was believed AT THAT TIME — including facts since revised or retracted. Use as_of to answer 'what did you think before I corrected you?'. subject filters to one entity; kind filters to semantic/episodic/procedural.

ParameterTypeDescription
as_ofstringISO date/datetime: return beliefs as held at that instant
kindstringFilter to one memory kind
limitintegerMax facts, default 8
max_tokensintegerToken budget for the returned facts
querystringFree-text search over the facts
subjectstringExact subject filter, e.g. 'user'

revise

Replace a belief with an updated one. The old fact is closed and linked to its successor — history is preserved, never deleted. Use when the user corrects you or circumstances change. Find the old fact's id with recall first. valid_from can backdate when the new state actually began (e.g. 'moved last month'). importance and kind are inherited from the old fact unless you override them.

ParameterTypeDescription
new_fact *stringThe corrected statement
old_fact_id *integerId of the fact being superseded
basisstringHow you know the correction. Sets confidence. Default user-stated
confidencenumberNumeric override for basis
importanceinteger1–10 salience override; default inherits the old fact's importance
kindstringOverride the memory kind; default inherits the old fact's kind
source_agentstring
source_commitstringGit SHA you re-read this code at; re-pins the corrected fact. Not inherited from the old fact — supply it if the correction came from code.
source_pathstringRepo-relative file path the corrected fact describes, if any.
source_refstring
valid_fromstringISO 8601: when the new state became true, if not now

diff

What changed in memory since a given ISO date: new facts learned, beliefs revised, facts retracted. The 'what have you learned about X since Monday?' query.

ParameterTypeDescription
since *stringISO date/datetime to diff from
subjectstringLimit to one subject

why

Full provenance and revision chain for a fact: where it came from, when it was learned, what it superseded, and what superseded it. Use to answer 'why do you believe that?' or to audit a belief before revising it.

ParameterTypeDescription
fact_id *integerThe fact to explain

forget

Retract a fact by id, or retract EVERYTHING from a given source_ref (provenance-based deletion: 'forget everything from that session'). Tombstoned, not erased: as_of queries before the retraction still show history; current recall never returns it.

ParameterTypeDescription
fact_idintegerRetract this fact
source_refstringRetract every fact recorded from this source

stats

Memory database statistics: counts, top subjects, schema version, db path.