Skip to main content
Use Priors for continual memory storage and retrieval while your own language model writes every reply. The per-turn loop:
  1. Call observe-and-recall (to learn the user’s message and fetch memories) or recall (read-only, no learning).
  2. Format the returned memories into your system prompt.
  3. Call your own language model and return its reply.
  4. Optionally store your model’s reply with observe if later turns must remember what your assistant committed to.

Before you start

Create an agent and a thread as in walkthrough 1. Remember the core rule: each agent’s memory is its own; everyone who talks to one agent shares what it learns. Give each customer their own agent if you learn from their messages. See A5. Bring your own model.

Step 1: retrieve memories with observe-and-recall (or recall)

Use observe-and-recall when the agent should learn from this message (for example, a sales agent per prospect). Use recall when the agent must not learn from user messages (for example, an inbound support line answering from fixed manuals).
Success: status 200. Memories arrive in the order the search found them. Each memory is the turn it was made from.
  • text: what was said, word for word.
  • timestamp: when the turn was said (the timestamp sent with it, or else when Priors received it).
  • speaker, speaker_id, metadata: who said it and the metadata you stored on the turn.
  • turn_id: the turn’s id, as the agent’s memory list shows it.
  • observation_id: the learning of this message. Poll it with GET…/observe/. It is null on recall.
An empty memories array is a normal 200 success for a new agent; let your model answer from the user message alone. If it fails:
  • 429 rate_limit_exceeded: wait Retry-After seconds (20 calls/min or 2 concurrent calls per subject).
  • 503 service_unavailable: retry with the same Idempotency-Key, or fall back to answering without memory for that turn.

Step 2: inject memories into your prompt

Pass the dated memories in your system prompt, keeping each memory’s date and speaker visible so your model reasons cleanly when facts change over time:

Step 3: optionally store your model’s reply

observe-and-recall learned the user’s message, not your model’s reply. If your assistant makes a promise, quotes a price, or confirms a booking that future turns must remember, send the reply with observe:
Set speaker to your assistant’s name so Priors keeps assistant commitments distinct from user statements.

Cost and concurrency notes

  • observe-and-recall bills input words (learning the user message) plus output words (the recalled memory text).
  • recall bills output words only (no learning).
  • If one user message triggers multiple internal model calls on your backend, call Priors once and reuse the same memories list across all of them.