diff --git a/changes/552.fixed.md b/changes/552.fixed.md new file mode 100644 index 00000000..ae003ca3 --- /dev/null +++ b/changes/552.fixed.md @@ -0,0 +1,4 @@ +**Apps with memory off no longer learn your name from Sentient's personality.** Setup writes your name into the +personality, so an app could still ask for it while "Let connected apps use my memories" was off, and so could an +incognito chat without memory. Now those turns keep the personality with "the user" in place of your name. Your other +chats still use it. diff --git a/docs/API.md b/docs/API.md index 05217f61..1f621889 100644 --- a/docs/API.md +++ b/docs/API.md @@ -555,7 +555,8 @@ when `openai_api.allow_memory` is on too (below). to an older message does not cover newer API input. - **What the key reaches.** Chatting and Sentient's tools, with approvals as above. Memories stay out unless `openai_api.allow_memory` is on (default off, #479): an API turn then gets no recalled memories, user-model - insights, notes or profile files in its prompt (only Sentient's persona, plus a note saying they aren't available), + insights, notes or profile files in its prompt (only Sentient's persona, with the user's configured name in it + written as "the user", #552, plus a note saying they aren't available), and `memory_recall`, `memory_search_by_source`, `memory_search_history`, `history_semantic_search`, `history_time_search`, `user_model_ask` and `memory_forget` are left out of its tools and refused if called anyway. This is the turn's one memory decision (section 10, "Turns without memory"), so the same holds for every helper, @@ -2805,7 +2806,8 @@ Every new tool declares a `Risk`; approvals behave as in section 1. the memory tools (`memory_recall`, `memory_search_by_source`, `memory_search_history`, `history_semantic_search`, `history_time_search`, `user_model_ask`, `memory_forget`) are not offered by `run_loop` whoever built the list, are not listed to scripts, and refuse to run (`{error}`) however they are called. A helper's prompt then leaves out - the user's name too. + the user's name too, and so does the turn's own: SOUL.md stays, with the configured name written as "the user" + (#552). - Limits: `subagents.max_rounds` steps (default 24), `subagents.timeout_minutes` (20), and on cloud models `subagents.max_tokens` (1000000) and `subagents.max_cost_usd` (2.0, when the price is known; `0` = no limit). The repeated-call breaker applies too. Reaching one ends the subagent with `status: "error"` and a plain `error` diff --git a/sentient/agent/loop.py b/sentient/agent/loop.py index 8dfc3901..bbca5581 100644 --- a/sentient/agent/loop.py +++ b/sentient/agent/loop.py @@ -96,7 +96,7 @@ from sentient.memory import scopes as memory_scopes from sentient.memory.facts import FactMemory, keyword_tokens, new_details from sentient.memory.sources import MemorySources -from sentient.memory.workspace import Workspace +from sentient.memory.workspace import Workspace, without_user from sentient.services import cancel_tasks from sentient.skills.loader import SkillLibrary from sentient.store.db import Store, after_watermark, new_id, next_watermark, now_iso @@ -794,8 +794,11 @@ async def _system_prompt_with_sources( sources.add_facts(facts) sources.add_insights(insights) snapshot = self.workspace.snapshot() - if not reads_memory: # only the persona: no profile, memory file or daily notes - snapshot = {k: (v if k == "soul" else "") for k, v in snapshot.items()} + if not reads_memory: # only the persona, without the user's name (#552): no profile, memory file or daily notes + soul = without_user( + snapshot.get("soul") or "", self.config.assistant.user_name, self.config.assistant.name + ) + snapshot = {k: (soul if k == "soul" else "") for k in snapshot} elif not personal: # MEMORY.md, daily notes and USER.md's learned facts come from personal memories (#155) snapshot = { **snapshot, "memory": "", "today": "", "yesterday": "", diff --git a/sentient/memory/workspace.py b/sentient/memory/workspace.py index 658fe095..728e4285 100644 --- a/sentient/memory/workspace.py +++ b/sentient/memory/workspace.py @@ -12,6 +12,7 @@ from __future__ import annotations +import re from collections.abc import Callable from datetime import date, timedelta from pathlib import Path @@ -49,6 +50,31 @@ """ +def without_user(text: str, user_name: str, assistant_name: str = "") -> str: + """SOUL.md for a turn without memory (#552): the persona stays and the user's name goes, as in a home with no name. + + Setup and the personality presets write the name into it ("You are Sentient, Maya Rao's chief of staff"). A line + that is still as they wrote it is written again without the name, so nothing else in it changes. In any other line + (edited by hand) the full name and each part of it become "the user" in any case. That can also take an ordinary + word ("will" for someone called Will): a changed word is better than a name that gets out.""" + from sentient.memory.personas import PERSONAS + + words = user_name.split() + if not words: + return text + written = {} + for template in (DEFAULT_SOUL, *(p["soul_md"] for p in PERSONAS)): + for line in template.splitlines(): + before = line.format(name=assistant_name, user=user_name.strip()) + written[before] = line.format(name=assistant_name, user="the user") + parts = sorted({w for w in words if len(w) >= 2}, key=len, reverse=True) + names = [r"\s+".join(map(re.escape, words)), *map(re.escape, parts)] + name = re.compile(rf"(?