From b59e5e42ac58d6357c5a454572594a6e29c8ba94 Mon Sep 17 00:00:00 2001 From: Mruthunjai Govindaraju Date: Sun, 22 Nov 2026 22:19:39 +0530 Subject: [PATCH 1/4] fix(agent): keep the user's name from SOUL.md out of a turn without memory (#552) --- changes/552.fixed.md | 4 ++++ docs/API.md | 6 ++++-- sentient/agent/loop.py | 7 ++++--- sentient/memory/workspace.py | 15 +++++++++++++++ tests/test_incognito.py | 20 ++++++++++++++++++-- tests/test_openai_api.py | 16 ++++++++++++++++ 6 files changed, 61 insertions(+), 7 deletions(-) create mode 100644 changes/552.fixed.md diff --git a/changes/552.fixed.md b/changes/552.fixed.md new file mode 100644 index 000000000..ae003ca31 --- /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 05217f617..1f621889b 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 8dfc39011..6fb0cf2d9 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,9 @@ 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) + 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 658fe0955..208323a9b 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,20 @@ """ +def without_user(text: str, user_name: str) -> str: + """SOUL.md for a turn without memory (#552): the persona stays and the user's name goes. Setup and the personality + presets write the name into it ("You are Sentient, Maya Rao's chief of staff"), so the full name in any case, then + each part of it written as configured ("Maya", not "maya"), becomes "the user", as in a home with no name.""" + words = user_name.split() + if not words: + return text + full = re.compile(r"(?= 2}, key=len, reverse=True): + text = re.sub(r"(? Date: Mon, 23 Nov 2026 00:27:53 +0530 Subject: [PATCH 2/4] fix(agent): match a one-word user name as written in a turn without memory A one-word name such as "Will" was matched in any case, so the persona's "what you will try next" became "what you the user try next". Only a name of two or more words is matched in any case now. --- sentient/memory/workspace.py | 9 ++++++--- tests/test_incognito.py | 1 + 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/sentient/memory/workspace.py b/sentient/memory/workspace.py index 208323a9b..e309a6206 100644 --- a/sentient/memory/workspace.py +++ b/sentient/memory/workspace.py @@ -52,12 +52,15 @@ def without_user(text: str, user_name: str) -> str: """SOUL.md for a turn without memory (#552): the persona stays and the user's name goes. Setup and the personality - presets write the name into it ("You are Sentient, Maya Rao's chief of staff"), so the full name in any case, then - each part of it written as configured ("Maya", not "maya"), becomes "the user", as in a home with no name.""" + presets write the name into it ("You are Sentient, Maya Rao's chief of staff"), so the full name, then each part of + it written as configured ("Maya", not "maya"), becomes "the user", as in a home with no name. Only a name of two or + more words is matched in any case: a one-word name such as "Will" is also an ordinary word ("what you will try + next"), so it is matched as configured, like the parts.""" words = user_name.split() if not words: return text - full = re.compile(r"(? 1 else 0 + full = re.compile(r"(?= 2}, key=len, reverse=True): text = re.sub(r"(? Date: Mon, 23 Nov 2026 23:29:39 +0530 Subject: [PATCH 3/4] fix(agent): take the user's name out of a turn without memory in any case Matching a one-word name only as written let a hand-typed "maya" through. Any case counts again, for the name and each part of it, except for a word Sentient's own personas use: for someone called Will, "what you will try next" stays and only "Will" goes. --- sentient/memory/workspace.py | 24 ++++++++++++++++-------- tests/test_incognito.py | 4 +++- 2 files changed, 19 insertions(+), 9 deletions(-) diff --git a/sentient/memory/workspace.py b/sentient/memory/workspace.py index e309a6206..e19e0ac51 100644 --- a/sentient/memory/workspace.py +++ b/sentient/memory/workspace.py @@ -50,20 +50,28 @@ """ +def _persona_words() -> set[str]: + """The lowercase words of Sentient's own persona texts, which are not a name when someone is called that.""" + from sentient.memory.personas import PERSONAS + + texts = [DEFAULT_SOUL, *(p["soul_md"] for p in PERSONAS)] + return set(re.findall(r"\b[a-z]+\b", " ".join(texts))) + + def without_user(text: str, user_name: str) -> str: """SOUL.md for a turn without memory (#552): the persona stays and the user's name goes. Setup and the personality presets write the name into it ("You are Sentient, Maya Rao's chief of staff"), so the full name, then each part of - it written as configured ("Maya", not "maya"), becomes "the user", as in a home with no name. Only a name of two or - more words is matched in any case: a one-word name such as "Will" is also an ordinary word ("what you will try - next"), so it is matched as configured, like the parts.""" + it, becomes "the user", as in a home with no name. Any case counts ("maya"), except for a single word that the + personas use themselves: for someone called Will, "what you will try next" stays and only "Will" goes.""" words = user_name.split() if not words: return text - flags = re.IGNORECASE if len(words) > 1 else 0 - full = re.compile(r"(?= 2}, key=len, reverse=True): - text = re.sub(r"(?= 2}, key=len, reverse=True))] + for name in names: + as_written = len(name) == 1 and name[0].lower() in ordinary + pattern = r"(? Date: Wed, 25 Nov 2026 18:45:32 +0530 Subject: [PATCH 4/4] fix(agent): keep Sentient's own persona lines whole in a turn without memory A line of SOUL.md that is still as setup wrote it is written again without the user's name, so a name that is also a persona word ("will") or the assistant's name no longer changes anything else. In a line edited by hand, the name and each part of it go in any case. --- sentient/agent/loop.py | 4 +++- sentient/memory/workspace.py | 36 ++++++++++++++++++------------------ tests/test_incognito.py | 18 ++++++++++++++++-- 3 files changed, 37 insertions(+), 21 deletions(-) diff --git a/sentient/agent/loop.py b/sentient/agent/loop.py index 6fb0cf2d9..bbca5581e 100644 --- a/sentient/agent/loop.py +++ b/sentient/agent/loop.py @@ -795,7 +795,9 @@ async def _system_prompt_with_sources( sources.add_insights(insights) snapshot = self.workspace.snapshot() 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) + 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 = { diff --git a/sentient/memory/workspace.py b/sentient/memory/workspace.py index e19e0ac51..728e42851 100644 --- a/sentient/memory/workspace.py +++ b/sentient/memory/workspace.py @@ -50,29 +50,29 @@ """ -def _persona_words() -> set[str]: - """The lowercase words of Sentient's own persona texts, which are not a name when someone is called that.""" - from sentient.memory.personas import PERSONAS - - texts = [DEFAULT_SOUL, *(p["soul_md"] for p in PERSONAS)] - return set(re.findall(r"\b[a-z]+\b", " ".join(texts))) +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 -def without_user(text: str, user_name: str) -> str: - """SOUL.md for a turn without memory (#552): the persona stays and the user's name goes. Setup and the personality - presets write the name into it ("You are Sentient, Maya Rao's chief of staff"), so the full name, then each part of - it, becomes "the user", as in a home with no name. Any case counts ("maya"), except for a single word that the - personas use themselves: for someone called Will, "what you will try next" stays and only "Will" goes.""" words = user_name.split() if not words: return text - ordinary = _persona_words() - names = [words, *([w] for w in sorted({w for w in words if len(w) >= 2}, key=len, reverse=True))] - for name in names: - as_written = len(name) == 1 and name[0].lower() in ordinary - pattern = r"(?= 2}, key=len, reverse=True) + names = [r"\s+".join(map(re.escape, words)), *map(re.escape, parts)] + name = re.compile(rf"(?