pinecallDocs
Key concepts / Memory

Memory

What the agent keeps about a contact between calls, and when it recalls it.

Memory is what the agent keeps about one contact between calls: that they prefer mornings, who their usual doctor is, that they are allergic to penicillin. The next call recalls it, so the agent does not ask again.

What is memory?#

Memory is a list of facts per contact, each filed under a category in your own words. The facts belong to your org, not to one agent: every agent of the org with a memory policy recalls what any of them learned about that contact. Three parts make it work:

Write a policy#

An agent remembers nothing until it has a policy. The policy is one field of the agent's settings, so it changes without a deploy, and a supervisor can edit it in the console, on the agent's Configure ▸ Memory. A class that declares memory sets the policy itself: its declaration wins, and the setting is refused until the class lets go of it.

Terminal
pinecall memory policy \
  --remember "how they like to be addressed" --remember "allergies" --remember "their usual doctor" \
  --forget "payments"

--remember and --forget take one phrase each and are repeated.

list means
--remember the categories worth keeping, in your words. Each fact is filed under one of them, exactly as you wrote it
--forget categories never written: a fact the model files under one is refused

With no list, the verb prints the policy in your settings, the team's and production's. --team writes the team's; --agent <slug> names the agent in a project of several. Each list you type replaces that list and keeps the other: --forget alone leaves --remember as it was. pinecall agent clear memory takes yours out, so the team's holds again.

Who a contact is#

A contact is the id your app named for the caller when it named one, else the number the call came from. On the phone and on WhatsApp, the number is the identity. A web visitor nobody named is nobody, and the agent remembers nothing of them.

To try memory from your terminal, say who is calling:

Terminal
pinecall chat --as +34600123456

How a call is remembered#

After the call ends and before its summary is written, the platform makes one model call, on the agent's own model and the keys its calls run on (your org's own, or the ones your plan lends). It reads the call's turns and the facts already held, and answers what to add, what to update and what no longer holds. Then:

  • a fact filed under a --forget category is refused. The category is matched as a word, ignoring case;
  • every other fact is filed under one of your --remember words, exactly as you wrote it: the model is told to copy one, and the word it answers with is read against your list, ignoring case and spacing. A word that is not on the list, or none, files the fact under other: with their usual doctor on your list, a fact the model files under usual doctor is written as other;
  • a fact that holds a word of one of the agent's tools' names is refused, since it could grant the agent a permission ("book without asking"). Every word of four letters or more counts, a camelCase or snake_case name split into its words, and a plural or a stem matches: with a tool listOrders, "Their usual order is a mocha." is refused for order. The rule is wide on purpose; if a category you keep shares a word with a tool, rename the tool or the category. pinecall remember prints each refusal with its reason;
  • an updated fact is a new row that supersedes the old one. Nothing is deleted except by forget.

Each fact is one short sentence in the third person (Allergic to penicillin., Prefers mornings.), written in the language the caller spoke on that call, whatever language your categories or the agent's own lines are in: the language the speech recognizer heard from them, else the language their own lines are written in. Only when those say nothing clearly (a line or two of a few words) does the agent's language setting stand in. A written call of an agent set to es whose caller writes English keeps English facts. A later call recalls the fact unchanged, so an English caller's facts reach the next call in English.

That model call is billed with the call. It has 8 seconds; past them, or if it fails, the log carries a recoverable remember_failed and the call ends normally. An org at its memory_facts quota writes nothing new, but its memory is still read.

How a turn recalls#

When the agent has a policy and the caller is known, recall runs beside the knowledge search on every turn. It ranks the contact's current facts by meaning and by words, then by recency and the confidence the extraction gave them, and hands the model the best six, each with the call that taught it and the date it was first held. It asks no language model: it costs one embedding of the caller's words and a query.

The contact recalled is always the one the platform knows is on the line, never one the model named.

Use it in your class#

remembers(text) is true once memory has told this call something under that category, or a fact containing that text. Use it in render() to change what the agent does:

agents/clinica-norte/agent.tsx
{this.remembers("usual doctor") && <p>Offer their usual doctor's free slots first.</p>}

It is false until a fact arrives, which is exactly how a caller nobody has met looks.

Each SDK calls a hook with what memory read or wrote, after the view already saw it: onMemory(ops, call) in TypeScript, on_memory(ops, call) in Python and Ruby. Each op says op (recall, remember, forget) and its facts.

Read and erase a contact#

Terminal
pinecall memory +34600123456          # current facts first, then the superseded ones with the date they stopped holding
pinecall memory forget +34600123456   # erase everything kept about them

forget asks once on a terminal and prints how many facts went. Without a terminal (a script, CI) it erases only with --yes. It always works, on any plan.

Test it#

what you ask how
does the agent use what it remembers? a golden with a memory list: the facts are handed to recall for that call only (Goldens)
does a call teach the right facts? pinecall remember, cases in agents/<agent>/test/memory/, one model call each
does recall bring back the right facts? pinecall memory eval, the golden agents/<agent>/test/goldens/memory.json, no model

Testing knowledge & memory walks all three.

Next steps#