Skip to content

The agent that grows with you

fix(memory): profile-only config gets narrow USER_PROFILE_GUIDANCE instead of the full memory block

Teknium481bc9391eac
diff --git a/agent/prompt_builder.py b/agent/prompt_builder.py
index ed1533748b6..4f26ffcf2a9 100644
--- a/agent/prompt_builder.py
+++ b/agent/prompt_builder.py
@@ -191,6 +191,21 @@ MEMORY_GUIDANCE = (
"workflows belong in skills, not memory."
)
+USER_PROFILE_GUIDANCE = (
+ "You have a persistent user profile across sessions. Save durable facts about "
+ "the user with the memory tool (target='user'): name, role, preferences, "
+ "corrections, and communication style. The profile is injected into every turn, "
+ "so keep it compact and focused on facts that will still matter later.\n"
+ "The built-in memory notes store is disabled — write only to the user profile "
+ "(target='user'), never target='memory'.\n"
+ "Prioritize what reduces future user steering — the most valuable entry is one "
+ "that prevents the user from having to correct or remind you again.\n"
+ "Write entries as declarative facts, not instructions to yourself. "
+ "'User prefers concise responses' ✓ — 'Always respond concisely' ✗. "
+ "Imperative phrasing gets re-read as a directive in later sessions and can "
+ "cause repeated work or override the user's current request."
+)
+
SESSION_SEARCH_GUIDANCE = (
"When the user references something from a past conversation or you suspect "
"relevant cross-session context exists, use session_search to recall it before "
diff --git a/agent/system_prompt.py b/agent/system_prompt.py
index 64399226d5b..b176a2554fd 100644
--- a/agent/system_prompt.py
+++ b/agent/system_prompt.py
@@ -38,6 +38,7 @@ from agent.prompt_builder import (
HERMES_AGENT_HELP_GUIDANCE,
KANBAN_GUIDANCE,
MEMORY_GUIDANCE,
+ USER_PROFILE_GUIDANCE,
OPENAI_MODEL_EXECUTION_GUIDANCE,
PARALLEL_TOOL_CALL_GUIDANCE,
PLATFORM_HINTS,
@@ -420,11 +421,16 @@ def build_system_prompt_parts(agent: Any, system_message: Optional[str] = None)
# so the guidance would steer the model at a tool whose every call returns
# "Memory is not available". Defaults to True for the rare code paths that
# build an agent view without going through agent_init.
- builtin_memory_active = getattr(agent, "_memory_enabled", True) or getattr(
- agent, "_user_profile_enabled", True
- )
- if "memory" in agent.valid_tool_names and builtin_memory_active:
- tool_guidance.append(MEMORY_GUIDANCE)
+ # When only the user profile store is enabled, the narrower
+ # USER_PROFILE_GUIDANCE is injected instead — the full block instructs the
+ # model to write notes to a MEMORY.md store that does not exist.
+ _mem_enabled = getattr(agent, "_memory_enabled", True)
+ _profile_enabled = getattr(agent, "_user_profile_enabled", True)
+ if "memory" in agent.valid_tool_names:
+ if _mem_enabled:
+ tool_guidance.append(MEMORY_GUIDANCE)
+ elif _profile_enabled:
+ tool_guidance.append(USER_PROFILE_GUIDANCE)
if "session_search" in agent.valid_tool_names:
tool_guidance.append(SESSION_SEARCH_GUIDANCE)
if "skill_manage" in agent.valid_tool_names:
diff --git a/tests/run_agent/test_run_agent.py b/tests/run_agent/test_run_agent.py
index 8713b588fa3..68eb70bcc81 100644
--- a/tests/run_agent/test_run_agent.py
+++ b/tests/run_agent/test_run_agent.py
@@ -924,23 +924,30 @@ class TestBuildSystemPrompt:
available" — telling the model to save facts there is a dead
instruction paid for on every API call.
"""
- from agent.prompt_builder import MEMORY_GUIDANCE
+ from agent.prompt_builder import MEMORY_GUIDANCE, USER_PROFILE_GUIDANCE
agent_with_memory_tool._memory_enabled = False
agent_with_memory_tool._user_profile_enabled = False
prompt = agent_with_memory_tool._build_system_prompt()
assert MEMORY_GUIDANCE not in prompt
+ assert USER_PROFILE_GUIDANCE not in prompt
- def test_memory_guidance_when_only_user_profile_enabled(
+ def test_profile_guidance_when_only_user_profile_enabled(
self, agent_with_memory_tool
):
- """USER.md alone still backs the tool, so the guidance stays."""
- from agent.prompt_builder import MEMORY_GUIDANCE
+ """USER.md alone gets the narrower profile-only guidance.
+
+ The full MEMORY_GUIDANCE block instructs the model to save notes to a
+ MEMORY.md store that does not exist in this configuration, so the
+ profile-specific block is injected instead.
+ """
+ from agent.prompt_builder import MEMORY_GUIDANCE, USER_PROFILE_GUIDANCE
agent_with_memory_tool._memory_enabled = False
agent_with_memory_tool._user_profile_enabled = True
prompt = agent_with_memory_tool._build_system_prompt()
- assert MEMORY_GUIDANCE in prompt
+ assert MEMORY_GUIDANCE not in prompt
+ assert USER_PROFILE_GUIDANCE in prompt
diff --git a/website/docs/user-guide/features/memory.md b/website/docs/user-guide/features/memory.md
index f76863da65d..cf575508ab1 100644
--- a/website/docs/user-guide/features/memory.md
+++ b/website/docs/user-guide/features/memory.md
@@ -249,6 +249,11 @@ when you want a third-party memory backend *instead of* the built-in files.
Listing `memory` under `agent.disabled_toolsets` is the heavier switch: it hides
external provider tools too.
+With only `memory_enabled: false` (user profile still on), the tool stays —
+it backs the profile store — but the system prompt swaps the full memory
+guidance for a narrower profile-only block, so the model is only instructed to
+save user-profile facts and never steered at the disabled notes store.
+
## Controlling memory writes (`write_approval`)
By default the agent saves memory freely — including from the background