A budget and a paper trail
Every line comes with a reason and a price. Nothing enters the prompt unattributed.
You cannot budget what has no price. Cognitive Memory files what an agent is told into four tiers — a gist line by default, a full body only where something concrete earned it — and returns the reason and the token cost of every line it injects.
Self-hosted SQLite · REST API · TypeScript SDK · learns with no model key set
staging build ID is ZQ7X4M2K
One line. Nothing in the message asked for it.
files are named in kebab-case
One line. Held since the last session.
internal staging host is internal-hbr-2291.example
Full body. The message named a host not in the transcript.
“We deploy on Fridays” vs “We never deploy on Fridays”
Full body. Two stored claims cannot both be true.
5.0 ms
recall p50
Deterministic ranked lookup over 200 stored memories. No model in the path, so it does not move when a provider does.
2.9 ms
context build p50
The whole prompt block — index lines, triggered bodies, contradictions and weak domains — assembled before the model is called.
77%
fewer tokens
Indexing 200 memories costs 1.3k tokens. Injecting all 200 bodies costs 3.6k. Bodies are spent only where something earned them.
0
models required
Deterministic extraction runs first. A deployment with no model key still learns plainly-stated facts.
What this is
A memory store that tells you what it cost
Keeping facts is the easy half. The part that decides whether an agent is usable in production is everything around them: what a stored fact costs per turn, which line earned its place, what was refused, and why a recall came back empty.
Every line has a reason attached
A gist line for everything held, a full body only for an identifier you named, a contradiction, or a domain the agent has been unreliable in. The rule that selected each line is stored with it, so a bad prompt is a thing you can read rather than a thing you can only feel.
There is no published benchmark for pre-inject versus on-demand retrieval, so the honest way to tune the tradeoff is to watch it happen.
The window stays yours
A similarity search returns k results, and k is whatever the caller passed. Here the per-turn budget is a setting, and a full body is spent only where something concrete earned it — so what your agent reads does not grow with everything you have ever told it.
When the ceiling bites, the report says truncated: true. It does not quietly drop the tail and let you assume the rest was irrelevant.
A disagreement is a record, not a coin toss
Two claims that cannot both be true are stored as a pair, with the question that would settle it, and pinned into every prompt until somebody answers. Nothing is silently reconciled away, and no model is asked to adjudicate.
A list of strings has nowhere to put “these disagree”. It stores both, or it quietly drops one — and the agent cannot tell you which happened.
Nothing lands without a reason
A rejection comes back with the reason it was rejected, so a client that sent ten statements and got three back is told which seven did not land. Corrections in the incoming message are caught synchronously and a recall that matches nothing returns empty rather than a plausible guess.
Deterministic extraction runs first, so a plainly-stated fact is learned even with no model configured at all.
Read on
Four pages, and then the reference
Integration
Two calls, in any language
Build context before the model runs. Record the turn after it finishes. There is one official SDK, and it is the only one you need to install — everything else is JSON over HTTP.
import { createClient, runTurn } from "cogmemory"const memory = createClient({ apiKey: process.env.COGNITIVE_MEMORY_KEY!, baseUrl: "https://cogmem.astracollab.app",})// context before the model, learning after itconst { context, learning, learningSkipped } = await runTurn( memory, { userMessage, run: (block) => callYourModel(block, userMessage) }, { domain: "database" })context.totalTokens // what this turn costcontext.entries // every line, with its reasonlearning?.counts // stored, merged, rejected, tensions# what the agent should know before it answerscurl -X POST https://cogmem.astracollab.app/api/v1/context \ -H "Authorization: Bearer $COGNITIVE_MEMORY_KEY" \ -H "content-type: application/json" \ -d '{"userMessage":"deploy ZQ7X4M2K to staging"}'# what it should remember from the finished turncurl -X POST https://cogmem.astracollab.app/api/v1/turns \ -H "Authorization: Bearer $COGNITIVE_MEMORY_KEY" \ -H "content-type: application/json" \ -d '{"userMessage":"...","assistantResponse":"..."}'The SDK is ~3kB gzipped, ESM-first, and depends on one small fetch wrapper. It also ships the deterministic engine, so the same ranking and tiering can run in-process with no service at all. Integrating with an agent →
Give every token your agent spends a receipt.
Create an account, make an organisation, and mint a key. The secret is shown once, because only a hash is stored.