worked example · agent memory

One conversation becomes memory you can inspect.

Alice is planning a billing migration. In three short messages she explains the migration and its safety rules. Watch those exact words become reusable memory, then see how that memory changes the answer to a risky request.

Simulation · example walkthrough. This page steps through an invented conversation and illustrative memory records. It demonstrates the flow; it is not a live agent session or customer history.

See memory change the answer

this example · 3 messages → 4 atoms → 1 scene → 1 trait

memory ladder · source to context 4 layers
L0
MESSAGESWhat Alice said
3
L1
MEMORIESFour atomic claims
4
L2
SCENESBilling context
1
L3
PERSONAOne durable trait
1

Every derived layer points back to the evidence below it.

00 · the problem

Told the rule on Monday. Breaks it on Friday. Why?

Because the rule was only ever a sentence in a chat window. By Friday the conversation is too long to send again, and a summary of it keeps the gist while losing the one line that mattered: never ship billing without my approval. A chat log is a record of talking, not a set of rules an agent can be held to.

the usual options

Resend the transcript, or summarise it.

  • Send it all again. The conversation outgrows the prompt, and the bill grows with it.
  • Send a summary. “Alice cares about release quality” is not a rule an agent can obey.
  • Either way, no receipts. You cannot see who set a rule, or when.
with memseek

Keep the words and the rule — separately.

  • The three messages are kept word for word.
  • The rule is stored separately, as a hard instruction the agent always gets.
  • Every claim links back to the sentence it came from.
  1. monday

    Alice explains a billing migration in three short messages. One of them is a rule.

    “Never deploy billing changes without my explicit approval. Writing the code is fine; shipping it is not.”
  2. a second later

    The messages are kept word for word. The rule is also written down on its own.

    Billing deploys need Alice’s explicit approval. It keeps a link to the message it came from, so you can always check it.
  3. weeks later

    Someone asks the agent to ship tonight. It still has the rule, so it says no.

    “I can prepare the rewrite, but I can’t deploy it — a production billing deploy needs your approval.”
  4. what you write

    One call per message. You never ask for the rule to be extracted.

    await memseek.records.ingest(
        collection="messages", entity="user:alice",
        text="Never deploy billing without my approval.",
    )
3 messages in, one standing rule outIt survives on its own, long after the conversation is gone.
A “deploy tonight” request is refusedAnd the refusal says why: production billing needs Alice’s approval.
Every claim opens to its evidenceRefusal → rule → the sentence in the chat. No dead ends.

New to Memseek? You write one small configuration file describing what your application should remember. After that your application only appends what happened; Memseek does the deriving, keeps every conclusion linked to the evidence underneath it, and hands your agent a bounded briefing instead of a pile of text. Everything below is that file and what it produces — how it works.

the words the rest of this page usesplain english
L0 – L3
Four kinds of memory, raw to durable: what was said, single facts, project notes, and how this person works.
collection
A table of records. Messages go in one, extracted facts in another.
derivation
An automatic step that reads new records and writes new ones. You describe it in a small config file; nothing schedules it by hand.
citation
The receipt — a stored link from a conclusion to the record it came from.
1
step 1 · keep the words (L0)

The evidence layer stores messages without interpreting them.

Alice explains the migration, the compatibility gate, and the approval rule. Each message is an independent event with session order. This layer exists so every later summary or trait can be opened back to exact words rather than a model’s paraphrase.

Alice · message 3“Never deploy billing changes without my explicit approval. Writing the code is fine; shipping it is not.”
collections/messages.yamlL0 contract
- name: messages
  mode: event
  schema:
    required: [text, role, session_id, ordinal]
  fields:
    session_id: {filter: true, project: true}
    ordinal: {filter: true, sort: true,
              project: true}
  required_processors: [embedding_v1]
mode: event

Append every message as immutable evidence. Later processing may supersede a claim, but it never rewrites what Alice said.

session_id + ordinal

Reconstruct one conversation in exact order without pretending that order applies across all sessions.

embedding_v1

Allow relevant background messages to be found later while preserving the original text byte-for-byte.

writes now

Three messages records, stored word for word — including “Never deploy billing changes without my explicit approval.” No fact, scene, or persona claim exists yet.

2
step 2 · pull out the claims (L1)

One pass reads the conversation; another decides whether each claim is new.

The first model call splits Alice’s messages into standalone facts and instructions, assigns a kind and priority, and cites the source messages. Search then finds similar active memory. A final pass chooses store, merge, or skip; skipped duplicates are not written.

message 1 Alice
“New Node services use Fastify. Billing stays on Express until mobile drops the old response fields.”
message 2 Alice
“Never deploy billing changes without my explicit approval.”
message 3 Alice
“Before removing compatibility, show me telemetry proving the old fields have zero traffic.”
l1_extract
extract → search → decide
memory · persona priority 80

New Node services use Fastify.

memory · episodic priority 85

Billing stays on Express while mobile depends on the old response fields.

memory · instruction priority 100

Billing changes require Alice’s explicit approval before production deployment.

memory · instruction priority 95

Remove compatibility only after telemetry shows zero traffic.

Visible effect: 3 immutable inputs → 4 independently retrievable claims. Each output cites the message that supports it.

derivations/l1_extract.yamlL0 → L1
trigger:
  write: {collections: [messages]}
sources:
  new_messages: {kind: changes}
  background: {kind: view,
               view: recent_messages@1}
tasks:
  - {id: claims, use: llm}
  - {id: existing, use: search}
  - {id: result, use: llm}
emit:
  collection: memories
  type: memory
claims

Extract one reusable statement per record. “Never deploy…” becomes an instruction with priority 100, not a vague conversation summary.

existing

Retrieve what memory already says before deciding. This is what makes repeat → skip and changed fact → merge possible.

result

Copy or reconcile claims after retrieval. Separating the calls prevents deduplication from collapsing a rich conversation into one sentence.

writes next

Four memories events, one sentence each: “New Node services use Fastify” (persona, p80) · “Billing stays on Express while mobile depends on the old response fields” (episodic, p85) · “Billing changes require Alice’s explicit approval before production deployment” (instruction, p100) · “Remove compatibility only after telemetry shows zero traffic” (instruction, p95). Each cites the message it came from. A repeated rule would write nothing.

3
step 3 · the project note, and the habit (L2, L3)

Project facts stay in the project; stable behavior rises into persona.

The scene derivation folds the four claims into one keyed Markdown block named billing-api-compatibility. It keeps state, constraints, evidence, and open questions together. A separate persona derivation reads changed scene blocks and emits only cross-context patterns—never a dated release fact.

derivations/scene_synthesis.yamlL1 → L2
sources:
  new_memories: {kind: changes}
  standing_memories:
    kind: view
    view: memory_audit@1
  current_scenes: {kind: current}
emit:
  collection: scenes
  type: scene_block
  dynamic_keys: true
  max_active_keys: 15
standing_memories

Keep older still-valid claims in the rewritten scene instead of summarizing only the latest suffix.

current_scenes

Update the existing project block when possible; create a new key only for a genuinely distinct durable context.

max_active_keys

Bound the number of live scenes. At capacity, the prompt must merge related blocks instead of growing forever.

writes next

One current scenes/billing-api-compatibility block — “Billing stays on Express while mobile depends on the legacy response fields; compatibility may be removed only after telemetry shows zero traffic; production deploys need Alice’s approval” — citing the four claims. Then one persona/interaction_protocol trait citing that scene: “Writing code and shipping it are separate approvals.”

4
step 4 · answer the risky request

The later request receives stable traits, project context, hard rules, and relevant memory in separate budgets.

Weeks later, “Rewrite billing in Fastify and deploy it tonight” renders agent_context. Persona says how Alice works, the scene preserves the migration state, standing instructions carry the priority-100 approval gate, and recall finds task-specific evidence. A long scene cannot crowd out the hard rule.

new request
“Rewrite billing in Fastify and deploy it tonight.”
without memory

A generic coding agent can interpret this as authorization to implement and ship.

render
agent_context
produced context

Express compatibility is still required · zero-traffic telemetry first · Alice must approve production.

agent effect

Do not rewrite or deploy tonight. Keep compatibility until telemetry shows zero traffic, then request Alice’s explicit approval.

artifacts/agent_context.yamlmemory → action
blocks:
  persona: {max_tokens: 1200}
  scenes: {max_tokens: 2500}
  instructions:
    view: standing_instructions@1
    args: {min_priority: 80}
    max_tokens: 1500
  memory:
    view: memory_recall@1
    max_tokens: 2500
template: |
  WHO YOU ARE WORKING WITH: {{persona}}
  PROJECT CONTEXT: {{scenes}}
  STANDING RULES: {{instructions}}
  RELEVANT MEMORY: {{memory}}
separate blocks

Give each memory timescale its own budget and provenance manifest instead of concatenating one opaque “memory” string.

min_priority: 80

Always retrieve hard standing rules above the declared threshold, even if semantic recall ranks something else higher.

template

State how retrieved data may influence the model and mark the request itself as untrusted data.

final state

The render writes one prompt snapshot for audit, and the agent answers: “I can prepare the rewrite, but I can’t deploy it. Billing stays on Express until telemetry shows zero traffic on the legacy fields, and a production billing deploy needs your explicit approval.”

Play the condensed conversation and inspect every stored layer →

01 · follow the memory build

See the input, the computation, and the stored record.

Press play for the sequence, or select any level to inspect its example output. The three messages are a condensed simulation of the fuller runnable example.

Ready
INPUT · MESSAGES COLLECTION

Alice · platform review

02 · open the collections

Four levels become four ordinary collections.

The levels are not hidden inside one opaque memory object. Each writes a record shaped for a different job, and each derived record keeps a citation to the evidence below it.

eventHistory grows. New messages and claims append; earlier claims remain available for audit.

keyedCurrent truth stays easy to read. Each scene or trait has one named current version, with older versions kept in history.

LevelCollectionRecord shapeHow it changesThis simulation
L0sourcemessagesExact text, role, session, orderAppend only3 message records
L1atomsmemoriesOne claim, kind, priority, citationsStore, merge, or skip4 active claims
L2scenescenesOne Markdown block per context keyNew current versionbilling-api-compatibility
L3personapersonaOne stable trait per profile keyOnly changed keys updateinteraction_protocol
THE NEXT CONVERSATION

New input does not mean “append everything.”

The runnable example sends three follow-up messages through the same L1 decision step.

MERGE · WRITES 1

A plan moved.

Mobile release 7 becomes release 8 in October. A new current claim cites the new message and the earlier claim it supersedes.

decision: merge
supersedes: [earlier-memory]
SKIP · WRITES 0

A rule was repeated.

Alice restates the production approval rule. Search finds the same active claim, so no duplicate record is written.

decision: skip
collection change: none
STORE · WRITES 1

A safeguard is new.

Alice requires a rollback plan for billing deploys. It becomes a new instruction with its own priority and source citation.

decision: store
memory_kind: instruction
ONE MEMORY · END TO END

Open any conclusion back to Alice’s words.

illustrative labels · stored UUIDs omitted
L0 · messagesmessage · 09:02

“Never deploy billing changes without my explicit approval. Writing the code is fine; shipping it is not.”

L1 · memoriesinstruction · p100

Billing production deploys require Alice’s explicit approval.

L2 · scenesbilling-api-compatibility

The approval gate is retained in the current working scene.

L3 · personainteraction_protocol

Writing code and shipping it are separate approvals.

The stored citation direction points downward—from L3 to L2 to L1 to L0—so the interface can walk the chain back to evidence.

03 · see why recall matters

Memory changes the answer.

The request sounds simple. The remembered rules make the safe next step obvious.

REQUEST

Rewrite billing in Fastify and deploy it tonight.

Needs explicit approval Billing remains on Express Wait for zero-traffic telemetry
MEMORY-AWARE ANSWER

Ready to check the request against memory.

04 · optional live connection

Load a real Memseek run.

The demo works on its own. Connect only when you want to inspect records created by agent_memory.py.

Run locally

The complete guide covers the database, real model, worker, workspace key, and CORS.

Open the setup guide →
LIVE SNAPSHOT

Connect to Memseek

Offline

Your key stays in this tab and is never saved.