Give Each Person Their Own Memory¶
Alpha channel only
The prerelease channel carries this content. A stable or testing install
does not have it, and a plain pip install does not get it: the install
needs --pre. Read Release Channels before you
mix channels.
This page sets up one assistant for several people, with a separate history and separate recalled facts for each person. Several people in a home or a team share one assistant.
What the setup includes¶
- A separate history for each session. On
ovos-persona-server, the OpenAIuserfield selects the session. - Retrieval memories that recall only the caller's own exchanges, with
scopeset tosession.
Separate histories on the persona server¶
Community servers are best-effort demos
The public OVOS servers exist for easy onboarding and demos only. They are best-effort, not optimized, carry no uptime guarantees, and may vanish at any time. OVOS will be slow and unreliable if you rely on them. The official recommendation is to self-host — or skip servers entirely: fully offline plugins exist for everything.
-
Install the packages:
-
Save a persona as
~/personas/ada.json: -
Start the server with server-side memory:
-
Send requests for two users:
ask() { curl -s localhost:8337/openai/v1/chat/completions \ -H 'content-type: application/json' \ -d "{\"model\":\"$1\",\"user\":\"$2\",\"messages\":[{\"role\":\"user\",\"content\":\"$3\"}]}" | python3 -c 'import sys,json; print(json.load(sys.stdin)["choices"][0]["message"]["content"])' } ask ada alice "Remember this: my cat is called Pixel. Reply only with OK." ask ada bob "Remember this: my favourite colour is green. Reply only with OK." ask ada alice "What is my cat called? Answer with the name only." ask ada bob "What is my cat called? If you do not know, say UNKNOWN."
Output of a run:
Alice gets her answer. Bob does not get Alice's answer. A request with no user field uses one shared default session, so send a user value for each person.
The server trusts the user value and does not check it, so this setup fits trusted clients only. On a server that untrusted clients share, keep CHAT_MEMORY off. See Memory, RAG & embeddings.
Keep recalled facts private¶
The lexical and local-rag memories store the exchanges of all sessions in one index. Their default scope is global, which recalls documents from every session. Set scope to session when several people share the assistant.
This script needs no chat server. It shows the difference between the two values:
from ovos_plugin_manager.templates.agents import AgentMessage, MessageRole
from ovos_memory_plugins.lexical import LexicalMemory
def remember(mem, user, said, answer):
mem.update_history([AgentMessage(MessageRole.USER, said),
AgentMessage(MessageRole.ASSISTANT, answer)], user)
for scope in ("global", "session"):
mem = LexicalMemory(config={"db_path": ":memory:", "scope": scope})
remember(mem, "alice", "my door code is 4711", "noted, the door code is 4711")
remember(mem, "bob", "what time is it", "it is noon")
print(scope, "bob:", [h.content for h in mem.search("door code", session_id="bob")])
print(scope, "alice:", [h.content for h in mem.search("door code", session_id="alice")])
mem.close()
Output:
global bob: ['Q: my door code is 4711\nA: noted, the door code is 4711']
global alice: ['Q: my door code is 4711\nA: noted, the door code is 4711']
session bob: []
session alice: ['Q: my door code is 4711\nA: noted, the door code is 4711']
With global, Bob's search finds Alice's door code. With session, it does not.
In a persona file, set the key in the memory block:
{
"memory_module": "ovos-memory-plugin-lexical",
"ovos-memory-plugin-lexical": {"db_path": "~/.local/share/ovos/family.db", "scope": "session"}
}
Troubleshooting¶
| Problem | Cause | Fix |
|---|---|---|
| One user hears another user's facts | A retrieval memory runs with scope: global |
Set scope to session |
| All users share one history | The client sends no user field |
Send a different user value for each person |
| The server forgets between requests | CHAT_MEMORY is not transparent |
Start the server with CHAT_MEMORY=transparent |