> ## Documentation Index
> Fetch the complete documentation index at: https://docs.onelamp.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Context memory

> A durable, shared context layer every AI tool can read and write.

Context memory is the heart of OneLamp: a durable store of the facts, events,
instructions, and tasks worth remembering across every tool and session. A small
tool surface sits on top of it — `save_context`, `save_session`, `get_context`,
`list_context`, `resume_session`, and `forget_context` — and every client you
connect shares the same store.

## Where it lives

Each user gets their **own private store** (a per-user Durable Object). Your
context is the source of truth; it isn't pooled with anyone else's, and it
isn't buried inside a single AI provider's chat history. Every tool call is scoped to the
signed-in user — the user identity is derived server-side from the OAuth token,
never from client input.

## Saving — durable facts, not transcripts

`save_context` is for **durable** knowledge: a convention, a decision, a
preference, a fact that should outlive the current conversation. It is designed to
stay clean over time:

<CardGroup cols={3}>
  <Card title="Idempotent" icon="copy">
    Saving the same content twice returns the same id with `deduped: true`. A
    repeated save is harmless.
  </Card>

  <Card title="Topic supersession" icon="rotate">
    Pass a stable `topic` and a newer entry replaces the older one — so a changed
    preference updates in place instead of piling up.
  </Card>

  <Card title="Typed" icon="tag">
    Each entry has a `memory_type` — `fact`, `event`, `instruction`, or `task` —
    that drives retrieval, plus a display `kind`, tags, and a `source_surface`.
  </Card>
</CardGroup>

### Memory types — and ephemeral tasks

Every entry carries a **`memory_type`**: a `fact` (stable knowledge), an `event`
(something that happened), an `instruction` (a procedure or runbook), or a
`task` (what you're working on right now). Tasks are **ephemeral** — they expire
after a short TTL and are swept automatically, so "what I'm doing now" never
calcifies into stale knowledge. While a task is live it's embedded and
retrievable like anything else; `get_context` can also filter to specific types
(e.g. just your `instruction`s).

You rarely set this by hand: `save_session` distills a transcript and classifies
each item's type for you.

## Retrieving — a ranked pack, never an answer

`get_context` is **retrieval, not generation**. It returns a ranked pack of
context chunks — your own source material — for the tool to reason over. It never
synthesizes an answer on the query path, so what comes back is always grounded in
what you actually saved.

Ranking fuses four signals with weighted Reciprocal Rank Fusion:

* **Semantic** — embedding similarity to your query. At save time OneLamp also
  generates a few likely questions and folds them into what's embedded, so a fact
  stored declaratively ("prefers dark mode") still matches an interrogative query
  ("what theme?").
* **Keyword** — full-text search with stemming, so "deploying" matches a saved
  "deploy".
* **Fact-key** — when your query names a known topic, that exact entry is a
  high-precision direct hit.
* **Recency** — newer entries break ties, so fresh context surfaces without
  burying older but relevant facts.

They're combined so results are relevant even when wording differs. An empty
store returns an empty pack — never an error — so a brand-new user's first call
just proceeds cleanly.

Each chunk in the pack carries its `kind`, `memory_type`, `source_surface`,
timestamp, and a relevance `score`, so the tool can weigh and cite what it uses.

## Exporting — your data, always portable

From your **Account** in the OneLamp web app you can export your **entire** store
as portable JSON. There's no lock-in and no export queue: export from the
dashboard and you get everything back, any time.

## In practice

```text theme={null}
You (in Claude Code):  "Remember we use pnpm, never npm."
  → save_context(content: "Use pnpm, never npm", kind: "preference",
                 topic: "package-manager")

You (later, in Codex): "Add the dependency."
  → get_context(query: "package manager")
  → pack includes "Use pnpm, never npm" → Codex runs pnpm add
```

The fact saved from one tool is retrieved by another. That's the whole point:
**one context layer, every tool — teach one, they all learn.**

<Note>
  For exact parameters and return shapes, see the
  [context tools reference](/tools/context).
</Note>
