recall

package module
v0.26.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 19, 2026 License: Apache-2.0 Imports: 8 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

Polign Recall

Recall gives an agent memory and state that survive the conversation and the process. Memory is what the agent knows: facts a user stated, with every correction kept, so the agent can say what it believes now, what it believed before, and why. State is where the agent is: its progress, its notes to its next instance, and the tool calls it had in flight, so a run that crashes or moves machines resumes from its own records.

Recall is a Go library, a recall binary that serves the same operations as MCP tools and as HTTP, and a Python client. It stores everything in a database you run: polign_db, PostgreSQL, MongoDB or Qdrant. Apache 2.0.

Recall, mem0 and Zep answering questions about a user whose facts changed over nine months

One user over nine months, three homes, three employers, three work emails, six questions, Claude Opus 5.5 extracting, answering and judging for all three systems: Recall 18/18, mem0 18/18, Zep 12/18. Tokens to save one message: Recall 3.0k, mem0 12.7k, Zep 14.7k.

The code to the Recall repository.

Install

pip install polign-recall          # the Python client, the recall binary, and the database it runs
brew install polign/tap/recall     # the same for Homebrew
go install github.com/Polign/recall/cmd/recall@latest   # the binary alone; it fetches the database on first use

Then give it to the agent you use:

claude mcp add recall -- recall mcp -write      # Claude Code

Add to Cursor · Add to VS Code · any other MCP host: command recall, arguments mcp -write (details).

With nothing configured, memory lives in a local database in ~/.local/share/recall, started on first use and shared by every agent on the machine. No model and no API key are needed to start. To keep memory in a database you already run, see Backends.

What a correction looks like

Every change is kept. Three commands read the record:

$ recall history "which editor do I use"
user preferred editor
  believed now: user preferred editor: zed
  2026-09-01 10:00  stated, user_stated
      + user preferred editor: vim
  2026-09-20 10:00  replaced, user_stated
      - user preferred editor: vim
      + user preferred editor: emacs
  2026-10-05 10:00  replaced, user_stated
      - user preferred editor: emacs
      + user preferred editor: zed

$ recall ask -as-of 2026-09-25 "which editor do I use"
Believed as of 2026-09-25 00:00:
user preferred editor: emacs  (since 2026-09-20)
  replaced: vim  (since 2026-09-01)

$ recall diff -from 2026-09-15 -to 2026-10-31
Changed between 2026-09-15 00:00 and 2026-10-31 00:00:
- user home city: Lisbon
+ user home city: Porto
- user preferred editor: vim
+ user preferred editor: zed

Why Recall

  • Corrections are records, not overwrites. A new value replaces the old one by a rule you can read, and every answer arrives with what it replaced.
  • Any moment is readable. as_of, history and diff say what the agent believed then and when that changed.
  • Every answer has a source. recall explain shows the message a fact came from, the rule that decided it, and its history.
  • Agents resume from records. A crashed or moved agent gets its working state, recent turns and unfinished tool calls back, not a snapshot.
  • Your storage, your rules. Memory lives in a database you already run, and the vocabulary of what gets remembered is yours to define or leave open.

Quickstart

Python 3.10 or later. Save a preference, then correct it:

pip install polign-recall
python - <<'PY'
from polign_recall import Client

with Client(local_dir="./recall-data", typed=True) as memory:
    memory.remember("user", "prefers_editor", "vim")
    memory.remember("user", "prefers_editor", "neovim")
PY

A second process reads the current value, the history, and what was believed before the correction:

python - <<'PY'
from polign_recall import Client

with Client(local_dir="./recall-data", typed=True) as memory:
    print(memory.recall("user", "prefers_editor")[0].value)   # neovim

    events = memory.history("user", "prefers_editor")
    print([e.value for e in events])                           # ['vim', 'neovim']

    before = memory.recall("user", "prefers_editor", as_of=events[0].observed_at)
    print(before[0].value)                                      # vim
PY

The first client to open ./recall-data starts a local database for it and later clients share it; the memories stay there after the program exits. A bare Client() uses ~/.local/share/recall, the memory every agent on the machine shares. The Python client guide covers the rest: plain-text memory with a model, forgetting, history, and resuming an agent.

How memory works

A memory is a subject, a predicate and a typed value: user, prefers_editor, neovim. Predicates live in a registry that says what type a value has, whether the predicate holds one value or many, and which predicates it contradicts: dislikes excludes likes, gave_away excludes owns. A single-valued predicate replaces its value on a new statement; a multi-valued one accumulates. Forgetting records a withdrawal; nothing is deleted. Recall ships starter registries for coding, personal assistant, support, sales and voice agents, and you can change a registry later without touching what was already remembered.

You do not have to define predicates. With an open vocabulary the first use of a predicate defines it, and with a model configured the MCP tools take plain text and no predicates appear anywhere:

recall setup -extract-model anthropic:claude-haiku-4-5-20251001
remember("I switched from helix to zed last week")
recall("which editor do I use?")  ->  "user prefers editor: zed" (before: helix)
forget("my editor")

The model decides how each statement is filed. Once filed, replacement follows the predicate's rule, every filing is recorded, and a wrong filing is corrected with one event that every later answer follows. No model reconciles memory on its own: Recall applies the registry's rules, shows what may conflict, and lets the agent confirm the rest, so every correction reads back to the rule or statement that made it. recall mcp -typed serves the typed tools (remember(subject, predicate, value)) instead. The developer reference has the details and the Memory API is the contract.

State

The second half of Recall, with its own contract, docs/state-api-v1.md. An agent writes down where it is as it works, and a new process resumes from those records instead of from a snapshot:

  • Working state: goal, plan, progress, focus, decisions, open questions.
  • Turns, verbatim, and large tool outputs stored by reference.
  • Pointers to where the work lives: a branch, an object key, a process.
  • Actions: each tool call that touches the world, recorded before it runs and closed with its result, so a crash between the two is visible and the next resume lists the call as unconfirmed instead of repeating it.

Resume takes a lease on the agent id, so one process acts for an agent at a time, rebuilds the context within a token budget, and renders it as one briefing for the model:

agent, err := client.Resume(ctx, recall.ResumeRequest{AgentID: "coder-1", TokenBudget: 8000})
if err != nil {
    return err
}
defer agent.Release(context.Background())

briefing := agent.Resumed().Briefing // hand this to the model

In Python, an agent remembers a fact and records where it is, the process is killed, and a new process resumes from the records:

import os, signal
from polign_recall import Client

with Client(local_dir="./recall-data", agent=True, typed=True) as client:
    client.remember("user", "project_constraint", "deploy only on weekdays after 18:00 UTC")
    with client.resume("coder-1") as agent:
        agent.update_working_state(goal="Move billing to the v2 API",
                                   plan=["find call sites", "migrate them", "run the tests"])
        agent.record_turn("user", "Start with the charge endpoint.")
        agent.milestone("call sites found", progress="12 call sites listed")
        os.kill(os.getpid(), signal.SIGKILL)   # dies here, lease unreleased
import time
from polign_recall import Client

with Client(local_dir="./recall-data", agent=True, typed=True) as client:
    agent = client.resume("coder-1", token_budget=8000, defer_lease=True)
    print(agent.context.briefing)   # at once: the goal, plan, milestone, turn, and constraint
    while not agent.acquire():      # False until the dead process's lease expires
        time.sleep(1)
    agent.record_turn("assistant", "Picking up at the charge endpoint.")

Without defer_lease=True, resume raises lease_held until the crashed process's lease expires (Python client guide).

The same operations are MCP tools (agent_resume, update_working_state, record_turn, begin_action, ...) and, on recall serve, HTTP routes at POST /v1/agent/<verb>. Over HTTP the server holds the lease between requests: resume returns an epoch and every write carries it, so a stale process cannot write over its successor. The State API is beta; the records it writes are stable (STABILITY.md). The resume example kills an agent mid-task and continues it in a new process.

Serving many agents

recall mcp is one agent, one process. recall serve is the same memory and state for many agents over HTTP, each inside the namespace its key names. The server holds the database credentials; agents hold Recall keys.

recall serve -backend polign -url http://polign:23000 -bootstrap-key-file admin.key
recall key create -backend polign -url http://polign:23000 -namespace acme:agent-7 -expires 168h

Each namespace gets its own collection, so nothing a caller sends can reach another namespace's records. POST /mcp is MCP over streamable HTTP; POST /v1/<tool> takes a memory tool's arguments as the body, and POST /v1/agent/<verb> a state tool's. Any stdio MCP client reaches the server through recall connect with RECALL_URL and RECALL_API_KEY set.

On Kubernetes a pod needs no key at all. With recall serve -kubernetes, it posts its projected service account token and gets a short-lived key fixed to its own agent id, which recall connect and the Python client obtain and renew by themselves. The Helm chart is charts/recall in Polign/polign; the agent-sandbox demo runs it on kind.

On Agent Substrate an actor needs no key either. With recall serve -substrate-issuer, the actor's egress policy has Substrate's gateway put a short-lived token for that actor in the Authorization header, and the server gives each actor its own memory. The agent-substrate example runs it on kind.

Backends

local (default) polign_db PostgreSQL + pgvector MongoDB Qdrant
RECALL_BACKEND local polign pgvector mongodb qdrant
RECALL_BACKEND_URL a directory http://host:23000 postgres://user:pw@host/db mongodb://user:pw@host/db http://host:6333
Memory, history, as-of yes yes yes yes yes
Keyword search yes yes yes yes no
Cached reads yes yes yes yes no
State API (leases) yes yes yes yes no
export RECALL_BACKEND=pgvector RECALL_BACKEND_URL=postgres://user:password@localhost:5432/mydb
recall mcp -write

Three settings name the database for every command: -backend, -url and -key, or the variables above. Everything else, including what each backend needs and how to add one, is in docs/backends.md.

Benchmark

LongMemEval user-facts subset, 267 questions about a user's own facts, preferences, updates and dates, with Claude Sonnet 5.5 as reader and judge and the upstream prompts:

What the reader is given Score
Nothing 6.0
The full chat history 88.0
BM25 over sessions, top 10 89.9
Recall, built-in word search 88.8
Recall with a model embedder (OpenAI text-embedding-3-small, 512 dims) 92.9
Only the sessions that hold the answer 96.6

With word search Recall is even with BM25 overall and behind it on preference questions (70.0 against 83.3); a model embedder puts it ahead. Recall handed the reader about 28k tokens per question, against 44k for BM25 and 168k for the full history. The harness is in eval/longmemeval.

Integrations

Python pip install polign-recall, then the client guide.
Go go get github.com/Polign/recall, then the Go library guide.
MCP Connect any agent to remember, recall and forget.
Claude Code The Recall plugin: memory across coding sessions.
LangGraph pip install recall-langgraph to resume LangGraph agents.
LiveKit, Vapi recall-livekit and recall-vapi for caller memory in voice agents.
Pydantic AI pip install recall-pydantic-ai for memory tools in Pydantic AI agents.
Vercel AI SDK The Next.js chat example, one click to deploy.
OpenClaw @polign/openclaw-recall on npm, the OpenClaw plugin.

Documentation

Developer reference · Memory API contract · State API contract · Backends · Connecting through MCP · Caching memory reads · Exporting and replaying history · What is stable and what is beta · Development guide · Usage statistics

Usage statistics

Release builds send an anonymous heartbeat: version, platform, a random install ID, and counts of memory operations. Nothing that is remembered is ever sent. recall telemetry prints exactly what is sent, and recall telemetry off, RECALL_TELEMETRY=0 or DO_NOT_TRACK=1 turns it off. TELEMETRY.md lists every field.

Support the project

If Recall kept your agent from acting on a stale fact, a star on this repository helps other people find it. Bugs, questions and ideas go in issues.

License

Apache 2.0.

Documentation

Overview

Package recall is the typed agent-memory layer: a registry of predicates that declares each one's cardinality, type, and which predicates contradict it, an append-only event log per subject, and the fold that turns that log into what the agent believes, now or at any past instant. The starter registries cover personal, coding, support, sales, and voice agents; an application adds its own predicates, or lets writes define them.

The central decision is that a belief is derived, never mutated. An earlier design flipped a record's status to "superseded" in a second write after storing its replacement, which left two live beliefs for a single-valued predicate whenever a process died between the two. Here the log is the truth and Fold deterministically interprets the events visible to a reader. This does not serialize concurrent writers or establish a read snapshot. Current and historical beliefs use the same fold with a different ceiling.

Retraction is likewise an event, not a deletion. Forgetting a fact on Wednesday must not change what the agent believed on Tuesday, and a log that erases its own history cannot answer that.

Index

Constants

View Source
const (
	StarterCoding   = engine.StarterCoding
	StarterSupport  = engine.StarterSupport
	StarterSales    = engine.StarterSales
	StarterVoice    = engine.StarterVoice
	StarterPersonal = engine.StarterPersonal
)

Starter registries, by the kind of agent each is written for.

View Source
const (
	RegistrySubject   = engine.RegistrySubject
	RegistryPredicate = engine.RegistryPredicate
)

The registry's own history lives in the log it governs: each change is an event about RegistrySubject under RegistryPredicate. Reads leave these events out unless a query names them.

View Source
const (
	ExtractionSubject   = engine.ExtractionSubject
	ExtractionPredicate = engine.ExtractionPredicate
)

ExtractionSubject and ExtractionPredicate name the reserved events that record what each model extraction proposed, so that remembering the same text again replays them. Answers leave them out.

View Source
const (
	PointerGitRef   = engine.PointerGitRef
	PointerObject   = engine.PointerObject
	PointerEnv      = engine.PointerEnv
	PointerExternal = engine.PointerExternal
	PointerProcess  = engine.PointerProcess
)

Pointer types.

View Source
const (
	ActionPure       = engine.ActionPure
	ActionIdempotent = engine.ActionIdempotent
	ActionExternal   = engine.ActionExternal

	ActionStarted   = engine.ActionStarted
	ActionDone      = engine.ActionDone
	ActionFailed    = engine.ActionFailed
	ActionAbandoned = engine.ActionAbandoned
	ActionUnknown   = engine.ActionUnknown
)

Action classes and statuses.

View Source
const AuditVersion = engine.AuditVersion

AuditVersion identifies the bundle envelope and its canonical checksum.

View Source
const DefaultSubject = engine.DefaultSubject

DefaultSubject is who a note is about when the text yielded no proposal to take a subject from.

View Source
const EventVersion = engine.EventVersion

EventVersion identifies the typed Event fields recorded in a bundle.

View Source
const FoldVersion = engine.FoldVersion

FoldVersion identifies observation-time ordering and the current single and multi-value fold rules. Incompatible changes need a new replay path.

v2 orders a retraction after the assertion it withdraws when the two share an instant. v1 ordered that tie on the event id, so the same log can fold differently under the two, and a v1 bundle must not be replayed here as though nothing had changed.

View Source
const LexicalSpace = engine.LexicalSpace
View Source
const MaxCandidateEvents = engine.MaxCandidateEvents

MaxCandidateEvents bounds event discovery for broad exact queries. A query for one explicit subject/predicate uses MaxHistoryEvents instead.

View Source
const MaxEvidenceBytes = engine.MaxEvidenceBytes

MaxEvidenceBytes bounds the excerpt a statement keeps as its evidence.

View Source
const MaxExport = engine.MaxExport

MaxExport bounds an unbounded export, so that asking for everything cannot turn into an unbounded scan by accident.

View Source
const MaxGetEvents = engine.MaxGetEvents

MaxGetEvents bounds one Client.Events call.

View Source
const MaxHistoryEvents = engine.MaxHistoryEvents

MaxHistoryEvents bounds a complete subject-and-predicate history. Histories beyond this bound fail explicitly; a partial fold could revive a retraction.

View Source
const MaxObservationSkew = engine.MaxObservationSkew

MaxObservationSkew is how far past the writer's clock RememberRequest.ObservedAt may be before Remember refuses it.

View Source
const MaxRecall = engine.MaxRecall

MaxRecall bounds the number of beliefs a query can request. Candidate discovery and result allocations are bounded independently of caller input.

View Source
const Multi = engine.Multi

Multi means values accumulate: an agent may like many languages.

View Source
const NotePredicate = engine.NotePredicate

NotePredicate is where a statement goes when no registered predicate fits it. Every client and store registers it, so "nothing matched" always has a place to be written instead of being dropped. A note is multi-valued free text: it never supersedes anything, and recall ranks it after typed beliefs.

View Source
const Single = engine.Single

Single means a newer value replaces the older one: an agent has one preferred editor.

View Source
const TextField = engine.TextField

TextField is the metadata key that holds each event's searchable text.

Variables

View Source
var (
	ErrLeaseHeld        = engine.ErrLeaseHeld
	ErrLeaseLost        = engine.ErrLeaseLost
	ErrLeaseUnsupported = engine.ErrLeaseUnsupported
	ErrAgentClosed      = engine.ErrAgentClosed
	ErrLeaseNotHeld     = engine.ErrLeaseNotHeld
	ErrPositionBehind   = engine.ErrPositionBehind
	ErrPositionAhead    = engine.ErrPositionAhead
	ErrRecordExists     = engine.ErrRecordExists
)
View Source
var ErrDigestMismatch = engine.ErrDigestMismatch

ErrDigestMismatch means validated content differs from its checksum.

View Source
var ErrEmbedderRequired = engine.ErrEmbedderRequired

ErrEmbedderRequired means an operation needs vectors but no embedder was configured.

View Source
var ErrGetUnsupported = engine.ErrGetUnsupported

ErrGetUnsupported reports a backend that cannot read records by id.

View Source
var ErrIncompleteCandidates = engine.ErrIncompleteCandidates

ErrIncompleteCandidates means a broad exact query could not discover enough matching beliefs or prove it exhausted the candidate set. No partial answer is returned; callers can narrow the query to an explicit subject/predicate.

View Source
var ErrIncompleteHistory = engine.ErrIncompleteHistory

ErrIncompleteHistory means the backend could not supply a complete exact log. No belief or write may be derived from such a log.

View Source
var ErrInvalidAudit = engine.ErrInvalidAudit

ErrInvalidAudit marks unsupported versions or invalid bundle inputs.

View Source
var ErrInvalidEvent = engine.ErrInvalidEvent

ErrInvalidEvent means a stored record cannot safely participate in a fold.

View Source
var ErrRegistryMismatch = engine.ErrRegistryMismatch

ErrRegistryMismatch means this client's configured registry disagrees with the registry recorded in the store, or asks for a change that would make stored values unreadable. Client.SyncRegistry records an intended change.

View Source
var ErrTextSearchUnsupported = engine.ErrTextSearchUnsupported

ErrTextSearchUnsupported is what a text search returns when the collection has no lexical index yet; recall then uses the vector search alone.

View Source
var ErrWatermarkUnsupported = engine.ErrWatermarkUnsupported

Functions

func Backends added in v0.13.0

func Backends() []string

Backends lists the registered backend names, sorted.

func Digest added in v0.2.0

func Digest(events []Event) string

Digest is the legacy stable checksum over a log. It uses case-insensitive value identity, so it does not detect changes only to string capitalization. Use DigestV2 for exact typed values or ExportAudit for reproducible bundles.

A separately trusted digest lets two parties compare logs without exchanging them. A checksum alone does not authenticate an exporter or prove completeness. The input is each event's canonical fields in a fixed order, so the digest depends on the content of the log and not on how it was serialised, paged, or which node answered.

func DigestV2 added in v0.3.0

func DigestV2(events []Event) (string, error)

DigestV2 hashes exact typed event fields, including case-sensitive strings and the IEEE-754 bits of finite numbers (so -0 and +0 differ). Instants are canonical UTC timestamps. It rejects invalid events and duplicate IDs. Digest remains the legacy, case-insensitive checksum for existing exports.

func DigestV3 added in v0.8.0

func DigestV3(events []Event) (string, error)

DigestV3 is DigestV2 that also covers each event's Evidence and EvidenceID.

func ObservedAt added in v0.9.0

func ObservedAt(ctx context.Context) time.Time

ObservedAt is when the text an extractor is reading was said, as given to RememberTextAt. Zero means now. An extractor uses it to resolve relative dates such as "last week".

func OpenVocabulary added in v0.14.0

func OpenVocabulary(ctx context.Context) bool

OpenVocabulary reports whether the client asking for an extraction has an open vocabulary (Config.Open), so an extractor may coin predicates instead of choosing only from the registry it is given.

func RegisterBackend added in v0.13.0

func RegisterBackend(name string, d BackendDriver)

RegisterBackend makes a backend available by name. It panics when the name is empty or taken or the driver has no Open, because each is a programming error that should fail at startup.

func Sentence added in v0.14.0

func Sentence(subject, predicate string, value any) string

Sentence tells one statement in words, the way Client.Ask does.

func SortEvents added in v0.2.0

func SortEvents(events []Event)

SortEvents orders a log oldest first, breaking ties on id so that two exports of the same events are byte-identical.

func SplitParams added in v0.23.0

func SplitParams(rawURL string, keys []string) (string, map[string]string, error)

SplitParams takes the listed keys out of rawURL's query string and returns the URL without them beside the values found. Keys not listed are left in place. A key given twice is an error, since the two values cannot both be meant.

Only the query string is parsed. The rest of the URL is passed through untouched, so connection strings Go's URL parser would refuse but the driver underneath accepts (a MongoDB host list, say) still work; a URL without any of the keys comes back as it was.

func StarterNames added in v0.9.0

func StarterNames() []string

StarterNames lists the starter registries StarterRegistry knows.

func Transcript added in v0.20.0

func Transcript(messages []Message) (string, error)

Transcript writes a conversation as User: and Assistant: lines for an extractor.

func ValueKey

func ValueKey(v any) string

ValueKey renders a value in the canonical form used to tell two values apart. Strings fold case, so "Neovim" stated twice with different capitals is one belief rather than two; the event keeps whatever form was written, and only identity is case-insensitive. Numbers render without exponent drift so that 8000 and 8000.0 are one value rather than two.

func VerifyDigest added in v0.3.0

func VerifyDigest(events []Event, expected string) error

VerifyDigest verifies either a legacy sha256: digest or a sha256:v2: digest. Legacy verification intentionally retains its original identity semantics.

func WithHeld added in v0.19.0

func WithHeld(ctx context.Context, held []Belief) context.Context

WithHeld returns a context on which Held reports held, for testing an extractor without a store.

Types

type Action added in v0.21.0

type Action = engine.Action

Action is one tool call recorded around its run, so a resume knows which calls a crash left unfinished. See Agent.BeginAction and Agent.Reconcile.

type ActionClass added in v0.21.0

type ActionClass = engine.ActionClass

ActionClass says what running a tool again would do.

type ActionEnd added in v0.21.0

type ActionEnd = engine.ActionEnd

ActionEnd is how an action finished.

type ActionStatus added in v0.21.0

type ActionStatus = engine.ActionStatus

ActionStatus is where an action stands.

type Agent added in v0.6.0

type Agent = engine.Agent

Agent is a resumed agent: it holds the agent's lease and writes its working state, pointers, turns, outputs and actions. Obtain one from Client.Resume.

type AskRequest added in v0.20.0

type AskRequest = engine.AskRequest

AskRequest is a read in words: a question, a profile, or what changed since a time.

type AuditBundle added in v0.3.0

type AuditBundle = engine.AuditBundle

AuditBundle records the inputs needed to reproduce exact beliefs offline. The digest covers every field except Digest itself, independent of event or registry iteration order. It is a checksum, not a signature or proof that the exporter supplied every event. Retain its digest through a trusted channel.

type AuditRequest added in v0.3.0

type AuditRequest = engine.AuditRequest

AuditRequest selects histories and the instant at which to replay them. A zero AsOf captures the store's current time once, before reading events.

type AuditScope added in v0.3.0

type AuditScope = engine.AuditScope

AuditScope selects complete histories. Empty fields match all subjects or predicates. Unlike Export, this scope cannot request a truncated event subset.

type Backend added in v0.3.0

type Backend = engine.Backend

Backend is the context-aware storage contract used by Client. Implementations must be safe for concurrent calls. List must obey VectorDB's exact totals, internal pagination, and stable ordered-prefix contract.

func OpenBackend added in v0.13.0

func OpenBackend(name string, opts BackendOptions) (Backend, error)

OpenBackend opens the backend registered under name. An empty URL means the driver's DefaultURL. The query keys the driver lists in Params are moved from the URL into opts.Params; a key given in both places keeps the one in opts.Params.

type BackendDriver added in v0.13.0

type BackendDriver struct {
	// Open connects to the database. It should validate options without
	// making requests, as the built-in backends do.
	Open func(BackendOptions) (Backend, error)
	// DefaultURL is the endpoint used when none is given.
	DefaultURL string
	// URLEnv and KeyEnv name the environment variables the recall command
	// read the endpoint and credential from before 0.23.0, such as
	// QDRANT_URL and QDRANT_API_KEY. The command reads them still, as
	// deprecated aliases of RECALL_BACKEND_URL and RECALL_BACKEND_KEY.
	//
	// Deprecated: new backends need not set them; they go away with the
	// aliases.
	URLEnv, KeyEnv string
	// Params lists the query keys the backend takes as options. OpenBackend
	// moves them from the URL to BackendOptions.Params before Open runs.
	// Keys not listed stay on the URL for the driver underneath.
	Params []string
}

BackendDriver is one storage backend a program can open by name. Backend packages register a driver from init, as database/sql drivers do, so a program picks backends by importing them:

import _ "github.com/Polign/recall/backend/qdrant"

b, err := recall.OpenBackend("qdrant", recall.BackendOptions{URL: "http://localhost:6333"})

func LookupBackend added in v0.13.0

func LookupBackend(name string) (BackendDriver, bool)

LookupBackend returns the driver registered under name.

type BackendOptions added in v0.13.0

type BackendOptions struct {
	// URL is the database endpoint, in the backend's own form: an HTTP(S)
	// address for polign and qdrant, a connection string for pgvector and
	// mongodb, a directory for local.
	URL string
	// APIKey is the credential, when the database wants one and the URL
	// does not carry it: the API key of polign and qdrant, the password of
	// pgvector and mongodb.
	APIKey string
	// Params are the backend's own options. OpenBackend fills them from the
	// URL's query string: every key the driver lists in Params is moved
	// here and removed from the URL, so a backend can take options on the
	// same string that names the database (postgres://host/db?schema=memory)
	// and the driver below it never sees keys it does not know.
	Params map[string]string
}

BackendOptions is what a registered backend is opened with.

type Belief

type Belief = engine.Belief

Belief is a statement that holds at some instant: the result of folding a log, not a stored row.

func Fold

func Fold(events []Event, card Cardinality, asOf time.Time) []Belief

Fold reduces one subject-and-predicate's events to the beliefs that hold at asOf. A zero asOf means now.

Events may arrive in any order and may repeat; the fold is defined by the log's content alone, so a partially applied write, a retried write, or a clock that stepped backwards changes the answer only in so far as it changed the log.

func Held added in v0.19.0

func Held(ctx context.Context) []Belief

Held returns the beliefs memory held when the extractor was asked: the ones the text is about first, then the newest, so it can file a statement that updates one of them under that fact's predicate, or name it in Proposal.Replaces. Notes are left out.

type BeliefRef added in v0.15.0

type BeliefRef = engine.BeliefRef

BeliefRef names a belief of a statement's own subject by its predicate and value, for RememberRequest.Replaces and Proposal.Replaces.

type Cardinality

type Cardinality = engine.Cardinality

Cardinality decides what a second value for the same subject and predicate means.

type Client added in v0.3.0

type Client = engine.Client

Client is a context-aware memory client. Configuration is immutable, and operations have independent request state. Concurrent writes still follow the backend's consistency guarantees; Client does not promise serializable writes.

func NewClient added in v0.3.0

func NewClient(cfg Config) (*Client, error)

NewClient validates configuration and copies the registry.

type Config added in v0.3.0

type Config = engine.Config

Config configures an immutable Client. Embedder is optional for exact reads, histories, and exports; writes and semantic recall require it.

type CreateBackend added in v0.26.0

type CreateBackend = engine.CreateBackend

CreateBackend optionally writes a record only when its id holds none, so a process restored from an earlier snapshot cannot replace later agent records. polign_db 0.16.0 and later, pgvector and MongoDB implement it.

type DiffRequest added in v0.22.0

type DiffRequest = engine.DiffRequest

DiffRequest names two instants for Client.Diff to compare.

type Earlier added in v0.14.0

type Earlier = engine.Earlier

Earlier is a value a Memory replaced.

type EmbedFunc added in v0.3.0

type EmbedFunc = engine.EmbedFunc

EmbedFunc adapts a function to Embedder.

type Embedder added in v0.3.0

type Embedder = engine.Embedder

Embedder supplies compatible document and query vectors. Implementations must honor cancellation and be safe for concurrent calls.

type Event

type Event = engine.Event

Event is one durable statement about a subject, or the retraction of one. Events are immutable once written: a correction is a later event, never an edit of an earlier one.

func DecodeEvent added in v0.3.0

func DecodeEvent(id string, m map[string]any) (Event, error)

DecodeEvent validates typed event metadata before returning it. Store reads use this strict decoder so a malformed correction or retraction cannot be silently skipped. EventFromMetadata remains available as a permissive decoder. Missing retraction denotes a legacy assertion; observed_ms is optional because observed_at is the authoritative timestamp.

func EventFromMetadata

func EventFromMetadata(id string, m map[string]any) Event

EventFromMetadata decodes without validation, retaining its legacy behavior. Invalid fields become their zero values. Use DecodeEvent before deriving beliefs from stored metadata; Store uses that strict decoder internally.

type Explanation added in v0.14.0

type Explanation = engine.Explanation

Explanation says why one belief is held, as Client.Explain returns it.

type Export added in v0.2.0

type Export = engine.Export

Export selects part of the log for audit. An empty field means "every one of these": zero Export exports everything the store holds.

type ExtractionResult added in v0.3.0

type ExtractionResult = engine.ExtractionResult

type Extractor added in v0.3.0

type Extractor = engine.Extractor

type Fence added in v0.21.0

type Fence = engine.Fence

Fence names the lease epoch an agent write is made under.

type FencedBackend added in v0.21.0

type FencedBackend = engine.FencedBackend

FencedBackend optionally refuses, on the server, an agent write its lease no longer backs. polign_db and pgvector implement it.

type ForgetRequest added in v0.3.0

type ForgetRequest = engine.ForgetRequest

ForgetRequest selects exactly one typed Value or All=true. False and numeric zero are values; an omitted value never implicitly withdraws everything.

type ForgetTextResult added in v0.14.0

type ForgetTextResult = engine.ForgetTextResult

ForgetTextResult reports what Client.ForgetText withdrew.

type GetBackend added in v0.8.0

type GetBackend = engine.GetBackend

LexicalEmbedder is a dependency-free signed feature-hashing fallback. It retrieves overlapping words, not semantic synonyms. Use a dedicated collection for this versioned 256-dimensional space; never mix it with model embeddings. GetBackend is an optional Backend capability: reading records by id, which Client.Events uses to follow a belief's EvidenceID to its text.

type Hit

type Hit = engine.Hit

Hit is one search result.

type LeaseBackend added in v0.6.0

type LeaseBackend = engine.LeaseBackend

LeaseBackend optionally grants per-agent leases. Resume requires it unless ResumeRequest.Unleased is set.

type LeaseGrant added in v0.6.0

type LeaseGrant = engine.LeaseGrant

LeaseGrant is one held lease epoch; the epoch is the fencing token.

type LeaseHeldError added in v0.6.0

type LeaseHeldError = engine.LeaseHeldError

LeaseHeldError names who holds a lease that could not be taken.

type LexicalEmbedder added in v0.3.0

type LexicalEmbedder = engine.LexicalEmbedder

type Materialization added in v0.3.0

type Materialization = engine.Materialization

Materialization is a bounded, process-local derived belief view owned by one client. The durable event log remains authoritative. Restart rebuilds the view.

type Memory added in v0.14.0

type Memory = engine.Memory

Memory is one belief told as a sentence, as Client.Ask returns it.

type Message added in v0.20.0

type Message = engine.Message

Message is one turn of a conversation to remember.

type Output added in v0.6.0

type Output = engine.Output

Output is a large tool result, kept whole and fetched by reference.

type OutputRef added in v0.6.0

type OutputRef = engine.OutputRef

OutputRef describes a stored output without its content.

type PairChange added in v0.22.0

type PairChange = engine.PairChange

PairChange is how one subject and predicate's beliefs differ between the two instants of a Client.Diff.

type Pointer added in v0.6.0

type Pointer = engine.Pointer

Pointer is a typed reference to where some of an agent's work lives.

type Position added in v0.26.0

type Position = engine.Position

Position is how far an agent's records go: the newest turn and action seqs and the working state version. Agent.Position returns it; At makes a write conditional on it; Agent.Since reports what came after one.

func ParsePosition added in v0.26.0

func ParsePosition(s string) (Position, error)

ParsePosition reads the turns.actions.state form of a position.

type PositionError added in v0.26.0

type PositionError = engine.PositionError

PositionError is ErrPositionBehind or ErrPositionAhead with the positions.

type Predicate

type Predicate = engine.Predicate

Predicate is one registry entry. Cardinality decides what a second value for the same subject means: "single" makes a newer value supersede the old one, "multi" makes it an additional fact. ValueType decides what a value IS: a string, a number, a boolean, an enum (one of Allowed), a date, or a ref to another subject. Values are stored with that type, so a number compares numerically in recall filters instead of lexically. Aliases are names the predicate used to have.

type PriorValue added in v0.10.0

type PriorValue = engine.PriorValue

PriorValue is a value a belief displaced, listed in Belief.Replaced.

type PromoteRequest added in v0.5.0

type PromoteRequest = engine.PromoteRequest

PromoteRequest files a note under a typed predicate. Note is the note's value exactly as recall returned it; the remaining fields are the typed statement it becomes, with RememberRequest's defaults.

type Proposal added in v0.3.0

type Proposal = engine.Proposal

Proposal is an untrusted model suggestion, never a belief until Remember validates and folds it. Evidence must be an exact excerpt from the input.

type ProposedStatements added in v0.3.0

type ProposedStatements = engine.ProposedStatements

ProposedStatements adapts proposals made by the calling agent. This lets an MCP host use its own model for extraction without another model service. RememberText still treats every proposal as untrusted and validates the batch.

type Query

type Query = engine.Query

Query is one read. With Text set the read is semantic (the text is embedded and searched); without it it is an exact filtered read. Both modes answer with beliefs folded from the same log, so semantic recall can never return something exact recall would say is no longer believed.

type ReconcileReport added in v0.21.0

type ReconcileReport = engine.ReconcileReport

ReconcileReport lists the actions Reconcile closed and those still open.

type Registry

type Registry = engine.Registry

Registry is the closed set of predicates the store accepts. A write with an unregistered predicate is rejected, so an agent cannot invent near-duplicate predicates ("editor_preference" beside "prefers_editor") and split one fact across two names that never meet.

func DefaultRegistry added in v0.3.0

func DefaultRegistry() Registry

DefaultRegistry returns an independent starter vocabulary, the one for coding agents. Applications may extend the returned map before constructing a Client. StarterRegistry has the others.

func LoadRegistry

func LoadRegistry(raw []byte) (Registry, error)

LoadRegistry parses and validates a registry document.

func StarterRegistry added in v0.9.0

func StarterRegistry(name string) (Registry, error)

StarterRegistry returns an independent copy of a starter vocabulary: a registry that is useful for one kind of agent before anyone has written their own. It is a starting point, to be extended or trimmed, and it always includes the note predicate.

type RegistryChange added in v0.9.0

type RegistryChange = engine.RegistryChange

RegistryChange is one recorded definition of a predicate: what it was from At until the next change to the same name. Client.RegistryLog returns them, and Client.SyncRegistry records them.

type RememberRequest added in v0.3.0

type RememberRequest = engine.RememberRequest

RememberRequest records a typed value: a string, float64, or bool. An enum, a date, and a ref are given as strings. Kind defaults to fact and Source to user_stated. Nil Confidence defaults to 1; a pointer to zero records zero confidence rather than selecting the default.

type RememberResult

type RememberResult = engine.RememberResult

RememberResult is what a write reports back: the assertion stored or found, whether it already held, and anything it displaced.

type Resolver added in v0.21.0

type Resolver = engine.Resolver

Resolver settles an action a crash left open: it runs an idempotent one again with its Key, or checks whether an external one happened.

type ResumeContext added in v0.6.0

type ResumeContext = engine.ResumeContext

ResumeContext is the context a resumed agent starts from. Its Briefing is one message a harness can hand the model as its starting context.

type ResumeRequest added in v0.6.0

type ResumeRequest = engine.ResumeRequest

ResumeRequest names the agent to resume and how to build its context.

type Rule added in v0.14.0

type Rule = engine.Rule

Rule is one recorded predicate definition in an Explanation.

type Selector added in v0.14.0

type Selector = engine.Selector

Selector picks which remembered statements a request in words is about, for Client.ForgetText.

type SinceReport added in v0.26.0

type SinceReport = engine.SinceReport

SinceReport is what an agent's records hold after a position.

type Step added in v0.22.0

type Step = engine.Step

Step is one statement in a Timeline, with the beliefs it began and ended.

type Store

type Store = engine.Store

Store turns writes into durable, typed events and reads into beliefs. It derives each answer from the log returned by its backend at read time. Consistency across concurrent operations depends on that backend.

func NewStore

func NewStore(db VectorDB, collection string, registry Registry, embed func(string) []float32) *Store

NewStore returns a store over one collection.

An invalid registry is recorded rather than returned, because this constructor has never had an error to return. Every operation reports it, so a bad cardinality surfaces at the first call instead of silently folding a multi-valued predicate as single-valued and appearing much later as a malformed audit.

type StoredVector

type StoredVector = engine.StoredVector

StoredVector is one record as the database returns it.

type TextSearchBackend added in v0.7.0

type TextSearchBackend = engine.TextSearchBackend

TextSearchBackend is an optional Backend capability: a lexical (BM25) search over the TextField metadata key of each event. When the backend has it, semantic recall fuses it with the vector search.

type TextSearcher added in v0.7.0

type TextSearcher = engine.TextSearcher

TextSearcher is the VectorDB form of TextSearchBackend, for NewStore.

type Timeline added in v0.22.0

type Timeline = engine.Timeline

Timeline is one subject and predicate's history told as changes, as Client.Timeline returns it.

type Turn added in v0.6.0

type Turn = engine.Turn

Turn is one message of an agent's run, kept verbatim.

type VectorDB

type VectorDB = engine.VectorDB

VectorDB is the database surface the store needs. Keeping it an interface is what lets the memory layer live outside the database it usually runs against, and lets tests exercise the semantics without one.

type WatermarkBackend added in v0.3.0

type WatermarkBackend = engine.WatermarkBackend

WatermarkBackend optionally supplies an opaque revision of the complete collection visible to this reader. It must change on every visible mutation, including overwritten IDs, deletes, late arrivals, restores, and route changes. It is not an observation timestamp or a maximum event ID. Equality is the only meaningful operation; replicas need not expose the same revision.

A revision must never be reused once it has changed. A counter that resets on restart lets a revision repeat, and a repeat silently revalidates a cached fold that the log has since moved past. Entries also expire after 30 seconds so that a backend which under-reports bounds, rather than keeps, the staleness it causes.

type WorkingState added in v0.6.0

type WorkingState = engine.WorkingState

WorkingState is an agent's handoff note to its next instance.

type WriteOption added in v0.26.0

type WriteOption = engine.WriteOption

WriteOption adjusts one agent write: At, CallID.

func At added in v0.26.0

func At(p Position) WriteOption

At makes an agent write conditional on the records standing at p.

func CallID added in v0.26.0

func CallID(id string) WriteOption

CallID gives BeginAction the harness's id for the tool call; a call already begun under it is returned instead of a new action.

Directories

Path Synopsis
backend
local
Package local is the backend Recall uses when nothing names a database: a polign_db that Recall runs itself, kept in a directory on this machine.
Package local is the backend Recall uses when nothing names a database: a polign_db that Recall runs itself, kept in a directory on this machine.
mongodb
Package mongodb implements Recall's Backend on MongoDB.
Package mongodb implements Recall's Backend on MongoDB.
pgvector
Package pgvector implements Recall's context-aware Backend on PostgreSQL with the pgvector extension.
Package pgvector implements Recall's context-aware Backend on PostgreSQL with the pgvector extension.
qdrant
Package qdrant implements Recall's context-aware Backend over the Qdrant REST API.
Package qdrant implements Recall's context-aware Backend over the Qdrant REST API.
Package backendtest is a conformance suite for recall.Backend implementations.
Package backendtest is a conformance suite for recall.Backend implementations.
cmd
recall command
Command recall serves typed, correctable agent memory over MCP, kept in a local polign_db it runs itself when nothing names a database, or in any backend registered in backends.go: -backend says which, -url where, -key the credential (see database.go).
Command recall serves typed, correctable agent memory over MCP, kept in a local polign_db it runs itself when nothing names a database, or in any backend registered in backends.go: -backend says which, -url where, -key the credential (see database.go).
recall-audit command
recall-audit verifies a JSON audit bundle from stdin and prints its replayed beliefs.
recall-audit verifies a JSON audit bundle from stdin and prints its replayed beliefs.
deploy
agent-substrate/actor command
The demo actor for Recall on Agent Substrate.
The demo actor for Recall on Agent Substrate.
eval
longmemeval/reembed command
Command reembed copies a question's Recall store from the lexical collection into a model-embedder collection, so a run with LME_EMBED_URL reuses the facts an earlier run extracted instead of extracting them again.
Command reembed copies a question's Recall store from the lexical collection into a model-embedder collection, so a run with LME_EMBED_URL reuses the facts an earlier run extracted instead of extracting them again.
predicate-matching command
Command predicate-matching measures how well an embedder tells predicate names that mean the same relation from names that do not, the comparison an open Recall client makes before defining a new predicate.
Command predicate-matching measures how well an embedder tells predicate names that mean the same relation from names that do not, the comparison an open Recall client makes before defining a new predicate.
examples
amend command
amend demonstrates Recall as the memory of record for a support team: a chat agent and a voice agent share one memory of customer commitments and policies.
amend demonstrates Recall as the memory of record for a support team: a chat agent and a voice agent share one memory of customer commitments and policies.
resume command
resume shows an agent surviving a crash by resuming from its records, not from a process snapshot.
resume shows an agent surviving a crash by resuming from its records, not from a process snapshot.
sessions command
sessions demonstrates exact memory across separate client processes.
sessions demonstrates exact memory across separate client processes.
internal
engine
Package engine implements Recall's typed memory, event histories, and audit replay.
Package engine implements Recall's typed memory, event histories, and audit replay.
recallhome
Package recallhome says where Recall keeps its own files on this machine.
Package recallhome says where Recall keeps its own files on this machine.
recallsetup
Package recallsetup holds the private on-disk configuration shared by the Recall launcher and the local server.
Package recallsetup holds the private on-disk configuration shared by the Recall launcher and the local server.
telemetry
Package telemetry sends a fixed-schema, anonymous usage heartbeat unless it is turned off.
Package telemetry sends a fixed-schema, anonymous usage heartbeat unless it is turned off.
Package model is a recall.Extractor backed by a language model, so that RememberText can be given text alone and work out the statements in it.
Package model is a recall.Extractor backed by a language model, so that RememberText can be given text alone and work out the statements in it.
Package polign implements Recall's context-aware Backend over the Polign HTTP API.
Package polign implements Recall's context-aware Backend over the Polign HTTP API.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL