Skip to content

armgit / avibe

Public Imported from GitHub
0

Make your computer a home for your AI partner. Avibe is the local-first Agent OS: Vibey, its built-in AI partner, works out of the box, and Claude Code, Codex & OpenCode run unchanged beside it — reach them from your browser, phone, or any chat app.

feat(memory): add profile enable switch (#1985)

rkrkrkk506d9b0b1d7e
diff --git a/avibe_memory/module.py b/avibe_memory/module.py
index 7919ec614..5b61ae965 100644
--- a/avibe_memory/module.py
+++ b/avibe_memory/module.py
@@ -165,6 +165,7 @@ class MemoryModule:
provider: MemoryProviderPort,
*,
enabled: bool | Callable[[], bool] = False,
+ profile_enabled: bool | Callable[[], bool] = True,
disk_free_bytes: Callable[[], int] | None = None,
provider_root: Path | None = None,
provider_root_owner: ProviderRoot | None = None,
@@ -178,6 +179,7 @@ class MemoryModule:
self._store = store
self._provider = provider
self._enabled_source = enabled
+ self._profile_enabled_source = profile_enabled
self._disk_free_bytes = disk_free_bytes or self._default_free_disk_bytes
self._effective_home = (
paths.get_vibe_remote_dir()
@@ -896,6 +898,7 @@ class MemoryModule:
async with self._lifecycle_lock:
if not self._is_enabled():
return OperationFailed(error="memory_disabled")
+ policy = replace(policy, include_profile=bool(policy.include_profile and self._is_profile_enabled()))
try:
meta = await self._store_call(self._store.ensure_meta)
except Exception:
@@ -1075,7 +1078,7 @@ class MemoryModule:
async def profile(self, *, principal_id: str, project_id: str) -> MemoryResult:
"""Return a bounded provider profile result or one closed error category."""
- if not self._is_enabled():
+ if not self._is_enabled() or not self._is_profile_enabled():
return OperationFailed(error="memory_disabled")
if not is_principal_id(principal_id):
return OperationFailed(error="memory_access_denied")
@@ -1085,7 +1088,7 @@ class MemoryModule:
return OperationFailed(error="memory_operation_in_progress")
async with self._lifecycle_lock:
- if not self._is_enabled():
+ if not self._is_enabled() or not self._is_profile_enabled():
return OperationFailed(error="memory_disabled")
try:
meta = await self._store_call(self._store.ensure_meta)
@@ -1541,6 +1544,17 @@ class MemoryModule:
return False
return bool(value)
+ def _is_profile_enabled(self) -> bool:
+ try:
+ value = (
+ self._profile_enabled_source()
+ if callable(self._profile_enabled_source)
+ else self._profile_enabled_source
+ )
+ except Exception:
+ return False
+ return bool(value)
+
def _root_lifecycle_lock(self) -> asyncio.Lock:
return _ROOT_LIFECYCLE_LOCKS.setdefault(self._provider_root_key, asyncio.Lock())
diff --git a/avibe_memory/process.py b/avibe_memory/process.py
index d913276f9..df21bc34c 100644
--- a/avibe_memory/process.py
+++ b/avibe_memory/process.py
@@ -157,6 +157,7 @@ class EverOSProcessSettings:
multimodal_model: str | None = None
multimodal_api_key: str | None = field(default=None, repr=False)
timezone: str | None = None
+ profile_enabled: bool = True
class _ProcessKind(Enum):
@@ -2169,6 +2170,12 @@ def _write_memory_child_config(
"[strategies.extract_foresight]",
"enabled = false",
"",
+ "[strategies.trigger_profile_clustering]",
+ f"enabled = {str(settings.profile_enabled).lower()}",
+ "",
+ "[strategies.extract_user_profile]",
+ f"enabled = {str(settings.profile_enabled).lower()}",
+ "",
)
)
_validate_generated_config(everos_contents, ome_contents, timezone_name, settings)
diff --git a/avibe_memory/runtime.py b/avibe_memory/runtime.py
index f07c33610..ebe0f8ed4 100644
--- a/avibe_memory/runtime.py
+++ b/avibe_memory/runtime.py
@@ -434,6 +434,7 @@ class MemoryRuntime:
opened,
self._provider,
enabled=lambda: self._config.enabled,
+ profile_enabled=lambda: self._config.profile_enabled,
provider_root=self._provider_root,
provider_root_owner=self._provider_root_owner,
runtime_active=self._runtime_active,
@@ -3000,6 +3001,7 @@ def _provider_kwargs(config: MemoryConfig) -> dict[str, str | None]:
rerank = processing.rerank
multimodal = processing.multimodal
return {
+ "profile_enabled": config.profile_enabled,
"llm_base_url": processing.llm.base_url,
"llm_model": processing.llm.model,
"llm_api_key": processing.llm.api_key,
diff --git a/config/v2_config.py b/config/v2_config.py
index ff2e7f2fd..808529b6b 100644
--- a/config/v2_config.py
+++ b/config/v2_config.py
@@ -963,6 +963,8 @@ def _recovery_field_for_error(section: Optional[str], error: BaseException) -> O
de-duplicating — as a whole, which is what stops the recovery loop.
"""
+ if section == "memory" and "Config 'memory.profile_enabled'" in str(error):
+ return "profile_enabled"
if section == "memory.cloud":
match = re.search(r"Config '([^']+)'", str(error))
if not match:
@@ -1179,6 +1181,9 @@ def _reset_recoverable_config_section(
loss-avoiding recovery path, and the original file is backed up first.
"""
+ if section == "memory" and field_name == "profile_enabled":
+ payload["memory"]["profile_enabled"] = False
+ return True
if section == "runtime" and field_name is not None:
if _recover_runtime_field(payload, field_name):
return True
@@ -1951,6 +1956,7 @@ class MemoryConfig:
"""Persisted local EverOS configuration; credentials are API-write-only."""
enabled: bool = False
+ profile_enabled: bool = True
mode: MemoryMode | None = None
processing: MemoryProcessingConfig = field(default_factory=MemoryProcessingConfig)
cloud: MemoryCloudConfig = field(default_factory=MemoryCloudConfig)
@@ -1962,6 +1968,8 @@ class MemoryConfig:
def validate(self) -> None:
if not isinstance(self.enabled, bool):
raise ValueError("Config 'memory.enabled' must be a boolean")
+ if not isinstance(self.profile_enabled, bool):
+ raise ValueError("Config 'memory.profile_enabled' must be a boolean")
if self.mode is not None and self.mode not in get_args(MemoryMode):
raise ValueError("Config 'memory.mode' must be 'platform', 'custom', or null")
if not isinstance(self.legacy_needs_repair, bool):
@@ -2197,6 +2205,7 @@ def memory_config_to_payload(
processing["multimodal"] = endpoint_payload(memory.processing.multimodal)
payload = {
"enabled": memory.enabled,
+ "profile_enabled": memory.profile_enabled,
"mode": memory.mode,
"processing": processing,
"cloud": {
@@ -2300,6 +2309,7 @@ def memory_config_from_payload(payload: object) -> MemoryConfig:
memory = MemoryConfig(
enabled=payload.get("enabled", False),
+ profile_enabled=payload.get("profile_enabled", True),
mode=payload.get("mode"),
legacy_needs_repair=legacy_needs_repair,
processing=MemoryProcessingConfig(
diff --git a/core/controller.py b/core/controller.py
index 52f729e99..9bafdd30e 100644
--- a/core/controller.py
+++ b/core/controller.py
@@ -1568,6 +1568,8 @@ class Controller:
verified_user_key: str | None,
cli_scope: tuple[str, str] | None,
) -> dict[str, Any]:
+ if not bool(getattr(getattr(self.config, "memory", None), "profile_enabled", True)):
+ return {"status": "failed", "error": "memory_disabled"}
runtime = await self._memory_runtime_for_operation()
scope = await self._memory_scope_for_runtime(
runtime,
diff --git a/core/handlers/session_handler.py b/core/handlers/session_handler.py
index c81380d93..2c250a664 100644
--- a/core/handlers/session_handler.py
+++ b/core/handlers/session_handler.py
@@ -1770,6 +1770,7 @@ class SessionHandler(BaseHandler):
agent_instructions=base_prompt or "",
include_quick_replies=quick_replies_on and platform != "wechat",
memory_enabled=bool(getattr(getattr(self.config, "memory", None), "enabled", False)),
+ profile_enabled=bool(getattr(getattr(self.config, "memory", None), "profile_enabled", True)),
context=context,
fallback_platform=platform,
enabled_agents=get_enabled_agents_for_prompt(self.controller),
diff --git a/core/internal_server.py b/core/internal_server.py
index d7987dc95..52bb319dd 100644
--- a/core/internal_server.py
+++ b/core/internal_server.py
@@ -1503,10 +1503,13 @@ def create_app(
return JSONResponse(status_code=403, content={"status": "failed", "error": "memory_access_denied"})
verified_user_key, cli_scope = owner
try:
- return await controller.memory_profile_payload(
+ payload = await controller.memory_profile_payload(
verified_user_key=verified_user_key,
cli_scope=cli_scope,
)
+ if isinstance(payload, dict) and payload.get("error") == "memory_disabled":
+ return JSONResponse(status_code=409, content=payload)
+ return payload
except MemoryStoreUnavailableError:
return JSONResponse(
status_code=503,
diff --git a/core/system_prompt_injection.py b/core/system_prompt_injection.py
index d3b674aed..36af34863 100644
--- a/core/system_prompt_injection.py
+++ b/core/system_prompt_injection.py
@@ -180,9 +180,14 @@ def _context_block(
*,
fallback_platform: Optional[str] = None,
memory_enabled: bool = False,
+ profile_enabled: bool = True,
) -> RenderedPromptBlock:
if memory_enabled:
- return render_prompt_block("memory-context-prompt")
+ block = render_prompt_block("memory-context-prompt")
+ if not profile_enabled:
+ lines = [line for line in block.text.splitlines() if "vibe memory profile" not in line]
+ block = RenderedPromptBlock(block.module_id, "\n".join(lines) + "\n")
+ return block
platform = resolve_context_platform(context, fallback_platform=fallback_platform, default="<platform>")
return render_prompt_block(
"preferences-context-prompt",
@@ -198,6 +203,7 @@ def build_system_prompt_blocks(
include_codex_generated_images: bool = False,
include_context_guidance: bool = True,
memory_enabled: bool = False,
+ profile_enabled: bool = True,
context: Optional[MessageContext] = None,
fallback_platform: Optional[str] = None,
enabled_agents: Optional[Iterable[Any]] = None,
@@ -250,6 +256,7 @@ def build_system_prompt_blocks(
context,
fallback_platform=fallback_platform,
memory_enabled=memory_enabled,
+ profile_enabled=profile_enabled,
))
if skills is not None:
from core.managed_skills import render_skill_catalog_blocks
diff --git a/docs/CLI.md b/docs/CLI.md
index 5e96a99fe..00cca8c7e 100644
--- a/docs/CLI.md
+++ b/docs/CLI.md
@@ -706,3 +706,5 @@ The web UI (`http://127.0.0.1:5123`) provides the same controls:
- [Slack Setup Guide](SLACK_SETUP.md)
- [Telegram Setup Guide](TELEGRAM_SETUP.md)
- [Codex Setup Guide](CODEX_SETUP.md)
+
+The Memory profile switch can disable profile reads and automatic profile processing without deleting existing memory or changing ordinary search.
diff --git a/docs/CLI_ZH.md b/docs/CLI_ZH.md
index 492aaba18..80d65a755 100644
--- a/docs/CLI_ZH.md
+++ b/docs/CLI_ZH.md
@@ -621,3 +621,5 @@ Web UI (`http://127.0.0.1:5123`) 提供相同的控制功能:
- [Slack 配置指南](SLACK_SETUP_ZH.md)
- [Telegram 配置指南](TELEGRAM_SETUP_ZH.md)
- [Codex 配置指南](CODEX_SETUP.md)
+
+Memory 画像开关关闭后会保留既有画像和普通搜索,但暂停画像读取及自动画像处理;重新开启即可恢复。
diff --git a/docs/MEMORY.md b/docs/MEMORY.md
index a004ddecb..72b4c5547 100644
--- a/docs/MEMORY.md
+++ b/docs/MEMORY.md
@@ -345,3 +345,6 @@ model-call and token ceilings, so those policy fields remain a declarative
envelope rather than an independently enforced provider budget.
Current-session overlay can only use the trusted caller session supplied by the
runtime; callers cannot provide arbitrary provider filters or session IDs.
+
+### Profile switch
+The Memory settings profile switch is enabled by default. Turning it off preserves existing profile data and ordinary capture/search, while profile reads and automatic profile processing are disabled until it is enabled again.
diff --git a/docs/plans/memory-profile-toggle.md b/docs/plans/memory-profile-toggle.md
new file mode 100644
index 000000000..e9555f18d
--- /dev/null
+++ b/docs/plans/memory-profile-toggle.md
@@ -0,0 +1,61 @@
+# Memory profile switch
+
+Approved scope, consolidated after PM simplicity review on 2026-09-14.
+Inspected base: origin/master ab8c22867e58cf8a98d6815c9737ea2ce74fc9c8.
+
+## Product contract
+
+Add one persisted boolean, `memory.profile_enabled`, default true (including old configurations without the field). Use the existing Memory settings toggle/save flow. When Memory itself is disabled, retain the preference but do not activate any Memory work.
+
+Disk loading recovers a malformed explicit profile flag to false through the existing field recovery/warning path, preserving other valid Memory settings and the original file. Direct parsing and API writes remain strict. Confirmed cloud transition patches accept and persist a profile delta alongside acknowledgement and loss confirmation.
+
+OFF means:
+1. Hide only the profile tab. Filter the existing tab array and reuse existing `activeTab` fallback to `processingRecord`. No new effect, navigation, state synchronization or persisted tab preference. Keep search/settings and admin gating unchanged.
+2. Omit profile-specific command guidance/content from newly constructed Agent prompts. Do not add a prohibition sentence. Keep all ordinary Memory guidance. Do not attempt to remove historical transcript text or arbitrary user-supplied references to profiles.
+3. Stop future automatic EverOS profile clustering and extraction. Preserve ordinary capture/search and historical profile data. Already-running jobs may finish; no cancellation framework.
+4. Shared profile-read entry returns existing `memory_disabled` closed-error result (HTTP409 at the UI boundary), including CLI access. Ordinary search clamps `include_profile` to requested value AND profile_enabled. This is feature policy, not a new permission system.
+
+ON restores profile tab, guidance, reads and future processing. No automatic regeneration/migration or deletion of historical data.
+
+## Minimal implementation
+
+- Configuration: extend MemoryConfig and existing validation/serialization/atomic update in `config/v2_config.py`; carry through `vibe/ui_memory_routes.py` settings projection/patch/apply and existing reconciliation. Update UI types in `ui/src/context/ApiContext.tsx`.
+- UI: existing Toggle in `ui/src/components/settings/memory/MemorySettingsPanel.tsx`, tab filtering only in `ui/src/components/settings/SettingsMemoryPage.tsx`; English/Chinese copy in `ui/src/i18n/en.json` and `zh.json`. Approved sketch: one 'Enable profile' toggle; existing tabs processingRecord/profile/search/settings minus profile when off. No new UI component or design system.
+- Prompt: `core/prompts/memory-context.md:15` currently advertises `vibe memory profile --json`. Make that profile-only guidance conditional using the existing registry/template composition (`core/prompt_registry.py`, `core/system_prompt_injection.py`). Prefer a small conditional block/slot over duplicated templates or text replacement after rendering. Pass the single boolean through existing caller paths; no generic policy service, extra cache or event bus.
+- Consumers: propagate the preference through actual controller/runtime settings and enforce shared profile-read/recall policy at the existing shared entry points, not individually at every transport. Search currently maps episodes/facts, so include_profile=true is not evidence that stored profiles were injected.
+- EverOS: extend existing process settings and `_write_memory_child_config` in `avibe_memory/process.py`. Explicitly generate `[strategies.trigger_profile_clustering] enabled=<flag>` and `[strategies.extract_user_profile] enabled=<flag>`; retain all other settings. Update the managed configuration via the existing supervisor/reconcile path, and regenerate from persisted preference on startup. Do not edit EverOS/EverAlgo source or change pins/manifests.
+- Reuse existing reload/reconciliation mechanism. Validate pinned EverOS1.2.3 OME reload behavior before claiming immediate effect. If the existing path needs a Memory-only restart, make that behavior explicit; never introduce a second host restart or a new lifecycle framework just for this toggle. Report a real unsupported boundary to PM before expanding scope.
+
+## Verified prompt refresh seams
+
+`core/system_prompt_injection.py:_context_block` selects registry block memory-context-prompt; `build_system_prompt_blocks` composes it (194-274 at base).
+OpenCode `modules/agents/opencode/agent.py:1564` and Codex `modules/agents/codex/agent.py:2605` build per-request injection.
+Claude `core/handlers/session_handler.py:1741-1787` rebuilds the system prompt; 498-507 compares bytes and recreates cached SDK clients when changed.
+Thus the next newly constructed request after effective policy reconciliation uses the new guidance. Already-running requests/native transcript history remain intact. OpenCode caller-context refresh is separate from this prompt path.
+
+## Evidence required
+
+Use existing tests and synthetic fixtures to cover legacy default/false round-trip, settings save/read/restart persistence, OFF/ON tab filtering and fallback, preserved ordinary prompt content with profile guidance absent when off and restored when on, all backend callers passing current flag, shared CLI/UI disabled reads, search clamping, generated OME flags and preserved non-profile settings, ordinary capture/search independence. Test actual supported OME reload in hermetic environment if available and accurately report the layer verified. Check toggle UI on mobile/desktop with synthetic data. Run focused tests, changed-file lint, UI build, then normal exact-head Codex/CI PR gates.
+
+## Explicit exclusions
+
+No generalized policy helper unless existing shared code already owns this value; no watcher for tab changes; no auth redesign, migrations, deletion, identity unification, prompt wording redesign, dependency upgrade, or background cancellation framework. No current-host deployment/config changes are authorized by implementation alone.
+
+## Profile draft ownership matrix
+| Path | Profile draft behavior |
+|---|---|
+| Normal Save | Submit profile delta with existing endpoint/mode deltas. |
+| Memory immediate toggle | Submit `enabled` plus profile delta only; never endpoint drafts. |
+| `usePlatformMode` / organization transition | Include profile delta in the transition patch. |
+| Confirm-loss | Preserve profile delta alongside `confirm_loss`. |
+| Success snapshot | Accept returned profile value as the new draft baseline. |
+| Validation failure | Keep all drafts unchanged. |
+| Throw/nonvalidation failure + reload | Refresh status/runtime, but retain local profile draft until an authoritative success snapshot. |
+
+## Implementation evidence and limits
+
+Round-four regressions exercise HTTP PATCH through candidate validation, simulated controller reconfiguration and real test-owned persistence for both organization and platform transitions. Load tests cover malformed values, endpoint preservation, `load_warnings`, legacy default, boolean round-trips and strict parser/API rejection.
+
+The managed runtime applies the setting through the existing locked reconcile path: it stops the supervised Memory child and wakes a child with the new process settings; generated OME configuration is rewritten from that preference. Tests use fake child processes and temporary directories. They do not claim a live EverOS hot-reload experiment or a host restart.
+
+Synthetic Playwright evidence at UI head `eb21b6839f61fb54edd6c26989d0e598366ce175` covers the actual MemorySettingsPanel with API/CSRF interception and a stateful parent: desktop/mobile, light/dark `data-theme`, OFF/ON Save interaction and horizontal overflow checks (four passing cases). Tab fallback is covered by the mounted SettingsMemoryPage component test, not this browser fixture. Evidence is retained in `/tmp/avibe-pr1985-evidence-sesgeabagce3w`; no live profile, service or user configuration was used. Unit and contract tests do not erase existing native transcript content or prove live model/provider integration.
diff --git a/modules/agents/codex/agent.py b/modules/agents/codex/agent.py
index f298fabff..82bc2412b 100644
--- a/modules/agents/codex/agent.py
+++ b/modules/agents/codex/agent.py
@@ -2607,9 +2607,12 @@ class CodexAgent(BaseAgent):
include_quick_replies=getattr(self.controller.config, "reply_enhancements", True)
and platform != "wechat",
include_codex_generated_images=True,
- memory_enabled=bool(
- getattr(getattr(self.controller.config, "memory", None), "enabled", False)
- ),
+ memory_enabled=bool(
+ getattr(getattr(self.controller.config, "memory", None), "enabled", False)
+ ),
+ profile_enabled=bool(
+ getattr(getattr(self.controller.config, "memory", None), "profile_enabled", True)
+ ),
context=request.context,
fallback_platform=platform,
enabled_agents=get_enabled_agents_for_prompt(self.controller),
diff --git a/modules/agents/opencode/agent.py b/modules/agents/opencode/agent.py
index 166528a2a..3b793ba8e 100644
--- a/modules/agents/opencode/agent.py
+++ b/modules/agents/opencode/agent.py
@@ -1569,6 +1569,9 @@ class OpenCodeAgent(OpenCodeMessageProcessorMixin, BaseAgent):
memory_enabled=bool(
getattr(getattr(self.controller.config, "memory", None), "enabled", False)
),
+ profile_enabled=bool(
+ getattr(getattr(self.controller.config, "memory", None), "profile_enabled", True)
+ ),
context=request.context,
fallback_platform=platform,
enabled_agents=get_enabled_agents_for_prompt(self.controller),
diff --git a/tests/test_memory_config.py b/tests/test_memory_config.py
index 21bd1d1d3..caebef7b5 100644
--- a/tests/test_memory_config.py
+++ b/tests/test_memory_config.py
@@ -274,6 +274,60 @@ def test_malformed_released_recovery_field_recovers_memory_section_on_load(
assert any("memory.recovery_intent" in warning for warning in loaded.load_warnings)
[email protected]("invalid", ["false", None, 0, [], {}])
+def test_malformed_profile_flag_load_preserves_memory(
+ tmp_path: Path,
+ invalid: object,
+ caplog: pytest.LogCaptureFixture,
+) -> None:
+ memory = {
+ "enabled": True,
+ "mode": "custom",
+ "profile_enabled": invalid,
+ "processing": _complete_processing(),
+ }
+ path = tmp_path / "config.json"
+ path.write_text(json.dumps(_payload(memory)), encoding="utf-8")
+
+ loaded = V2Config.load(path)
+
+ assert loaded.memory.profile_enabled is False
+ assert loaded.memory.enabled is True
+ assert loaded.memory.mode == "custom"
+ for name, endpoint in memory["processing"].items():
+ assert getattr(loaded.memory.processing, name) == MemoryEndpointConfig(**endpoint)
+ assert loaded.recovered_sections == ("memory.profile_enabled",)
+ assert any("memory.profile_enabled" in warning for warning in loaded.load_warnings)
+ assert "Started with a recovered config" in caplog.text
+ assert json.loads(path.read_text(encoding="utf-8"))["memory"] == memory
+
+
+ "profile_patch, expected",
+ [({}, True), ({"profile_enabled": True}, True), ({"profile_enabled": False}, False)],
+)
+def test_profile_flag_load_defaults_and_roundtrip(
+ tmp_path: Path,
+ profile_patch: dict,
+ expected: bool,
+) -> None:
+ path = tmp_path / "config.json"
+ path.write_text(
+ json.dumps(_payload({"enabled": True, "processing": _complete_processing(), **profile_patch})),
+ encoding="utf-8",
+ )
+ loaded = V2Config.load(path)
+ assert loaded.memory.profile_enabled is expected
+ assert not loaded.load_warnings
+ loaded.save(path)
+ assert V2Config.load(path).memory.profile_enabled is expected
+
+
+def test_invalid_profile_flag_remains_rejected_by_direct_parser() -> None:
+ with pytest.raises(ValueError, match="memory.profile_enabled"):
+ V2Config.from_payload(_payload({"profile_enabled": "false"}))
+
+
def test_released_optional_endpoint_shapes_remain_stable(tmp_path: Path) -> None:
config = V2Config.from_payload(
_payload({"enabled": True, "processing": _complete_processing()})
diff --git a/tests/test_memory_module.py b/tests/test_memory_module.py
index 9cda9e2bc..136e017ab 100644
--- a/tests/test_memory_module.py
+++ b/tests/test_memory_module.py
@@ -29,6 +29,7 @@ from avibe_memory.types import (
MemoryProfile,
MemoryProfileExplicitInfo,
MemoryProfileTrait,
+ RecallPolicy,
OperationFailed,
ProviderSearchItem,
)
@@ -815,3 +816,24 @@ async def test_disabled_capture_is_closed(tmp_path: Path) -> None:
module, _store, _provider = _module(tmp_path)
module._enabled_source = False
assert await module.capture(_request()) == CaptureSkipped(reason="memory_disabled")
+
[email protected]("enabled_after_wait", [False, True])
+async def test_recall_clamps_profile_inside_lifecycle_lock_after_disable(tmp_path: Path, enabled_after_wait: bool) -> None:
+ module, store, provider = _module(tmp_path)
+ enabled = enabled_after_wait
+ module._profile_enabled_source = lambda: enabled
+ seen: list[bool] = []
+ original = provider.search
+ async def search(*args, **kwargs):
+ seen.append(kwargs["include_profile"])
+ return await original(*args, **kwargs)
+ provider.search = search
+ await module._lifecycle_lock.acquire()
+ enabled = False if enabled_after_wait else True
+ task = asyncio.create_task(module.recall("q", policy=RecallPolicy(mode="keyword", include_profile=True), principal_id=PRINCIPAL, project_id="default"))
+ await asyncio.sleep(0)
+ enabled = enabled_after_wait
+ module._lifecycle_lock.release()
+ await task
+ assert seen == [enabled_after_wait, enabled_after_wait]
diff --git a/tests/test_memory_process.py b/tests/test_memory_process.py
index ea08b57f9..3b97cd0bb 100644
--- a/tests/test_memory_process.py
+++ b/tests/test_memory_process.py
@@ -597,3 +597,19 @@ async def test_released_sync_reaper_preserves_record_on_nonce_mismatch(
assert host.signals == []
assert path.exists()
+
[email protected]("profile_enabled", [True, False])
+def test_generated_ome_profile_strategies_follow_switch(tmp_path: Path, profile_enabled: bool) -> None:
+ from avibe_memory.process import _write_memory_child_config
+ import tomllib
+ memory_dir = tmp_path / "memory"
+ provider_root = tmp_path / "provider"
+ attachments = tmp_path / "attachments"
+ memory_dir.mkdir(parents=True); (memory_dir / "generated").mkdir(); provider_root.mkdir(parents=True); attachments.mkdir(parents=True)
+ _write_memory_child_config(memory_dir=memory_dir, provider_root=provider_root, attachments_root=attachments, settings=EverOSProcessSettings(profile_enabled=profile_enabled))
+ ome = tomllib.loads((provider_root / "ome.toml").read_text())
+ strategies = ome["strategies"]
+ assert strategies["trigger_profile_clustering"]["enabled"] is profile_enabled
+ assert strategies["extract_user_profile"]["enabled"] is profile_enabled
+ assert strategies["reflect_episodes"]["enabled"] is False
+ assert strategies["extract_foresight"]["enabled"] is False
diff --git a/tests/test_memory_profile_prompt_toggle.py b/tests/test_memory_profile_prompt_toggle.py
new file mode 100644
index 000000000..dc9eb2fd1
--- /dev/null
+++ b/tests/test_memory_profile_prompt_toggle.py
@@ -0,0 +1,26 @@
+from core.system_prompt_injection import build_system_prompt_blocks
+
+
+def _memory_prompt(*, memory_enabled: bool, profile_enabled: bool = True) -> str:
+ return "\n".join(
+ block.text
+ for block in build_system_prompt_blocks(
+ memory_enabled=memory_enabled,
+ profile_enabled=profile_enabled,
+ )
+ if block.module_id == "memory-context-prompt"
+ )
+
+
+def test_profile_off_omits_only_profile_command_and_preserves_memory_guidance():
+ off = _memory_prompt(memory_enabled=True, profile_enabled=False)
+ on = _memory_prompt(memory_enabled=True, profile_enabled=True)
+ assert "vibe memory profile" not in off
+ for text in ("vibe memory search", "vibe memory status", "vibe memory remember", "safety"):
+ assert text in off.lower()
+ assert "vibe memory profile" in on
+
+
+def test_memory_disabled_does_not_render_memory_prompt():
+ blocks = build_system_prompt_blocks(memory_enabled=False, profile_enabled=False)
+ assert all(block.module_id != "memory-context-prompt" for block in blocks)
diff --git a/tests/test_memory_wake.py b/tests/test_memory_wake.py
index 598d8eb1b..9bb0967d0 100644
--- a/tests/test_memory_wake.py
+++ b/tests/test_memory_wake.py
@@ -780,3 +780,14 @@ async def test_wake_reopens_store_after_environmental_fault_is_corrected(
assert result == {"ok": True, "state": "running"}
assert runtime.available is True
+
+async def test_reconcile_profile_toggle_restarts_supervisor_with_false(tmp_path: Path, memory_runtime_factory) -> None:
+ processes = FakeEverOSProcessFactory()
+ runtime = memory_runtime_factory(_config(), artifact_manager=FakeMemoryArtifactManager(python=Path(sys.executable)), process_factory=processes, effective_home=tmp_path)
+ await runtime.reconcile(_config())
+ off = _config(); off.profile_enabled = False
+ result = await runtime.reconcile(off)
+ assert result["ok"] is True
+ assert processes.supervised
+ assert processes.supervised[-1].settings.profile_enabled is False
diff --git a/tests/test_ui_memory_routes.py b/tests/test_ui_memory_routes.py
index f36b0efdb..4a2440095 100644
--- a/tests/test_ui_memory_routes.py
+++ b/tests/test_ui_memory_routes.py
@@ -20,6 +20,7 @@ from config.v2_config import (
)
from tests.ui_server_test_helpers import csrf_headers
from vibe import internal_client, ui_memory_routes
+from vibe.api import save_memory_config
from vibe.ui_server import app
@@ -142,6 +143,87 @@ def test_platform_embedding_transition_accepts_confirmed_data_loss() -> None:
assert target["cloud"]["organization_attached"] is False
[email protected]("scope", ["organization", "platform"])
+def test_confirmed_cloud_transition_persists_profile_disable(
+ monkeypatch: pytest.MonkeyPatch,
+ tmp_path: Path,
+ scope: str,
+) -> None:
+ monkeypatch.setenv("AVIBE_HOME", str(tmp_path))
+ _save_config(MemoryConfig(
+ enabled=True,
+ mode="custom" if scope == "organization" else "platform",
+ profile_enabled=True,
+ processing=MemoryProcessingConfig(
+ llm=MemoryEndpointConfig("https://llm.example.test/v1", "chat", "llm-key"),
+ embedding=MemoryEndpointConfig("https://embed.example.test/v1", "embed", "embed-key"),
+ ),
+ cloud=MemoryCloudConfig(
+ scope=scope,
+ capabilities=MemoryCloudCapabilities(chat=True, embedding=True),
+ embedding_identity="emb-v2",
+ applied_embedding_identity="emb-v1",
+ transition_notice_pending=True,
+ model_access_key="mak_synthetic",
+ proxy_base_url="https://backend.example.test/v1/model",
+ source_instance_id="instance-1",
+ ),
+ ))
+ reconfigured = []
+
+ async def preflight(**_kwargs):
+ return {"status_code": 200, "body": {"ok": True}}
+
+ async def reconfigure(*, confirm_loss, memory, expected_memory, user_key):
+ assert confirm_loss is True
+ assert expected_memory["profile_enabled"] is True
+ assert memory["profile_enabled"] is False
+ assert memory["cloud"]["transition_notice_pending"] is False
+ reconfigured.append(memory)
+ # Stand in for the controller's accepted reconfiguration; use the real
+ # persistence seam against this test's AVIBE_HOME.
+ save_memory_config(memory)
+ return {"status_code": 200, "body": {"ok": True}}
+
+ monkeypatch.setattr(internal_client, "memory_preflight", preflight)
+ monkeypatch.setattr(internal_client, "memory_reconfigure", reconfigure)
+ client = app.test_client()
+ response = client.patch(
+ "/api/memory/settings",
+ json={"acknowledge_transition": True, "confirm_loss": True, "profile_enabled": False},
+ headers=csrf_headers(client, BASE_URL),
+ **_request_options(),
+ )
+ assert response.status_code == 200, response.get_json()
+ assert response.get_json()["status"] == "ok"
+ assert response.get_json()["profile_enabled"] is False
+ assert len(reconfigured) == 1
+ loaded = V2Config.load()
+ assert loaded.memory.profile_enabled is False
+ assert loaded.memory.enabled is True
+ assert loaded.memory.cloud.transition_notice_pending is False
+ assert loaded.memory.cloud.applied_embedding_identity == "emb-v2"
+ assert loaded.memory.cloud.organization_attached is (scope == "organization")
+
+
[email protected]("invalid", ["false", None, 0, [], {}])
+def test_settings_patch_rejects_invalid_profile_flag(
+ monkeypatch: pytest.MonkeyPatch,
+ tmp_path: Path,
+ invalid: object,
+) -> None:
+ monkeypatch.setenv("AVIBE_HOME", str(tmp_path))
+ _save_config()
+ client = app.test_client()
+ response = client.patch(
+ "/api/memory/settings", json={"profile_enabled": invalid},
+ headers=csrf_headers(client, BASE_URL), **_request_options(),
+ )
+ assert response.status_code == 400
+ assert response.get_json() == {"status": "failed", "error": "memory_invalid_input"}
+ assert V2Config.load().memory.profile_enabled is True
+
+
def test_memory_settings_get_is_no_store_and_never_projects_secrets(
monkeypatch: pytest.MonkeyPatch,
tmp_path,
diff --git a/ui/src/components/settings/SettingsMemoryPage.test.tsx b/ui/src/components/settings/SettingsMemoryPage.test.tsx
index 0f57d5a5c..de0dc7d7f 100644
--- a/ui/src/components/settings/SettingsMemoryPage.test.tsx
+++ b/ui/src/components/settings/SettingsMemoryPage.test.tsx
@@ -6,6 +6,7 @@ import type { ReactNode } from 'react';
import { MemoryRouter } from 'react-router-dom';
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
+import type { MemorySettingsResult } from '../../context/ApiContext';
import { InstanceAuthorizationContext } from '../../context/InstanceAuthorizationContext';
import { ToastProvider } from '../../context/ToastProvider';
import { OWNER_INSTANCE_CAPABILITIES } from '../../lib/sessionInfo';
@@ -21,6 +22,7 @@ const api = vi.hoisted(() => ({
repairMemory: vi.fn(),
wakeMemory: vi.fn(),
}));
+const savedSettings = vi.hoisted(() => ({ current: null as null | ((next: typeof settings) => void) }));
const translate = vi.hoisted(() => (key: string) => key);
vi.mock('react-i18next', () => ({
@@ -44,14 +46,14 @@ vi.mock('../ui/confirm-dialog', () => ({
}));
vi.mock('./memory/MemoryProcessingRecordPanel', () => ({
- MemoryProcessingRecordPanel: () => null,
+ MemoryProcessingRecordPanel: () => <div data-testid="processing-record-panel">processing-record</div>,
}));
vi.mock('./memory/MemoryProfilePanel', () => ({ MemoryProfilePanel: () => null }));
vi.mock('./memory/MemorySearchPanel', () => ({ MemorySearchPanel: () => null }));
vi.mock('./memory/MemorySettingsPanel', () => ({
- MemorySettingsPanel: ({ onDeleteData }: { onDeleteData: () => void }) => (
+ MemorySettingsPanel: ({ onDeleteData, onSaved }: { onDeleteData: () => void; onSaved?: (next: Extract<MemorySettingsResult, { status: 'ok' }>) => void }) => { savedSettings.current = onSaved ?? null; return (
<button type="button" onClick={onDeleteData}>open-delete</button>
- ),
+ ); },
}));
vi.mock('./memory/MemoryStatusPanel', () => ({
@@ -78,6 +80,7 @@ vi.mock('./memory/MemoryStatusPanel', () => ({
const settings = {
status: 'ok' as const,
enabled: true,
+ profile_enabled: true,
mode: 'custom' as const,
processing: {
llm: { base_url: null, model: null, api_key: null, has_api_key: false },
@@ -158,6 +161,24 @@ afterEach(() => {
vi.clearAllMocks();
});
+describe('SettingsMemoryPage profile transition', () => {
+ it('falls back to processingRecord when active profile is disabled', async () => {
+ const user = userEvent.setup();
+ renderPage();
+ await waitFor(() => expect(screen.getByRole('radio', { name: 'memory.tabs.settings' })).toBeTruthy());
+ await user.click(screen.getByRole('radio', { name: 'memory.tabs.settings' }));
+ expect(savedSettings.current).toBeTruthy();
+ await user.click(screen.getByRole('radio', { name: 'memory.tabs.profile' }));
+ const off = { ...settings, profile_enabled: false };
+ api.getMemorySettings.mockResolvedValue(off);
+ act(() => savedSettings.current?.(off));
+ await waitFor(() => {
+ expect(screen.queryByRole('radio', { name: 'memory.tabs.profile' })).toBeNull();
+ expect(screen.getByRole('radio', { name: 'memory.tabs.processingRecord' }).getAttribute('aria-checked')).toBe('true');
+ });
+ });
+});
+
describe('SettingsMemoryPage', () => {
it('inspects only the Memory dependency owner', async () => {
renderPage();
diff --git a/ui/src/components/settings/SettingsMemoryPage.tsx b/ui/src/components/settings/SettingsMemoryPage.tsx
index 270e2f24d..ea5213180 100644
--- a/ui/src/components/settings/SettingsMemoryPage.tsx
+++ b/ui/src/components/settings/SettingsMemoryPage.tsx
@@ -188,10 +188,10 @@ export const SettingsMemoryPage: React.FC = () => {
const tabs = useMemo(() => [
{ id: 'processingRecord' as const, label: t('memory.tabs.processingRecord') },
- { id: 'profile' as const, label: t('memory.tabs.profile') },
+ ...(settings?.profile_enabled !== false ? [{ id: 'profile' as const, label: t('memory.tabs.profile') }] : []),
{ id: 'search' as const, label: t('memory.tabs.search') },
...(canAdminister ? [{ id: 'settings' as const, label: t('memory.tabs.settings') }] : []),
- ], [canAdminister, t]);
+ ], [canAdminister, settings?.profile_enabled, t]);
const activeTab = tabs.some((entry) => entry.id === tab) ? tab : 'processingRecord';
const runtimeAction = runtimeRequired === false && !remoteUnavailable && canAdminister && settings?.enabled === true
? runtimeState === 'degraded' ? (
diff --git a/ui/src/components/settings/memory/MemorySettingsPanel.test.tsx b/ui/src/components/settings/memory/MemorySettingsPanel.test.tsx
index d8d50c8dc..c72af4cf7 100644
--- a/ui/src/components/settings/memory/MemorySettingsPanel.test.tsx
+++ b/ui/src/components/settings/memory/MemorySettingsPanel.test.tsx
@@ -43,6 +43,7 @@ const endpoint = (baseUrl: string, model: string) => ({
const settings: MemorySettings = {
status: 'ok',
enabled: true,
+ profile_enabled: true,
mode: 'custom',
im_attachment_capture_available: false,
processing: {
@@ -63,8 +64,8 @@ const renderPanel = (overrides: Partial<React.ComponentProps<typeof MemorySettin
deleting: false,
...overrides,
};
- render(<MemorySettingsPanel {...props} />);
- return props;
+ const view = render(<MemorySettingsPanel {...props} />);
+ return { props, view };
};
beforeEach(() => {
@@ -77,6 +78,20 @@ afterEach(() => {
});
describe('MemorySettingsPanel', () => {
+ it('follows a clean parent snapshot update for profile', async () => {
+ const { view } = renderPanel();
+ view.rerender(<MemorySettingsPanel {...({ settings: { ...settings, profile_enabled: false }, maintenance: { status: 'ok', data_exists: true, can_delete_data: true }, maintenanceError: null, onSaved: vi.fn(), onReloadSettings: vi.fn(), onReloadMaintenance: vi.fn(), onDeleteData: vi.fn(), deleting: false } as React.ComponentProps<typeof MemorySettingsPanel>)} />);
+ await waitFor(() => expect(screen.getByRole('switch', { name: 'memory.settings.profileEnableLabel' }).getAttribute('aria-checked')).toBe('false'));
+ });
+ it('retains dirty profile draft across persisted parent reload', async () => {
+ const user = userEvent.setup(); const { view } = renderPanel();
+ await user.click(screen.getByRole('switch', { name: 'memory.settings.profileEnableLabel' }));
+ api.saveMemorySettings.mockRejectedValueOnce(new Error('rejected'));
+ view.rerender(<MemorySettingsPanel {...({ settings: { ...settings, profile_enabled: true }, maintenance: { status: 'ok', data_exists: true, can_delete_data: true }, maintenanceError: null, onSaved: vi.fn(), onReloadSettings: vi.fn(), onReloadMaintenance: vi.fn(), onDeleteData: vi.fn(), deleting: false } as React.ComponentProps<typeof MemorySettingsPanel>)} />);
+ expect(screen.getByRole('switch', { name: 'memory.settings.profileEnableLabel' }).getAttribute('aria-checked')).toBe('false');
+ });
+
+
it('keeps configuration enablement reachable while Memory is disabled', async () => {
const user = userEvent.setup();
renderPanel({ settings: { ...settings, enabled: false } });
@@ -90,7 +105,7 @@ describe('MemorySettingsPanel', () => {
});
it('exposes one explicit Delete data action', async () => {
- const props = renderPanel();
+ const { props } = renderPanel();
await userEvent.click(screen.getByRole('button', { name: 'memory.deleteData.button' }));
expect(props.onDeleteData).toHaveBeenCalledOnce();
expect(screen.queryByText(/Clear Memory|Factory Reset|Rebuild/i)).toBeNull();
@@ -120,6 +135,60 @@ describe('MemorySettingsPanel', () => {
});
});
+
+ it('hosted profile-only toggle exposes Save and submits exact patch', async () => {
+ const user = userEvent.setup(); renderPanel({ settings: { ...settings, mode: 'platform', profile_enabled: true } });
+ await user.click(screen.getByRole('switch', { name: 'memory.settings.profileEnableLabel' }));
+ const save = screen.getByRole('button', { name: 'memory.settings.save' });
+ expect((save as HTMLButtonElement).disabled).toBe(false);
+ await user.click(save);
+ await waitFor(() => expect(api.saveMemorySettings).toHaveBeenCalledWith({ profile_enabled: false }));
+ });
+
+ it('includes pending profile draft in hosted Memory toggle save', async () => {
+ const user = userEvent.setup();
+ renderPanel({ settings: { ...settings, mode: 'platform', profile_enabled: true } });
+ await user.click(screen.getByRole('switch', { name: 'memory.settings.profileEnableLabel' }));
+ await user.click(screen.getByRole('switch', { name: 'memory.settings.enableLabel' }));
+ await waitFor(() => expect(api.saveMemorySettings).toHaveBeenCalledWith({ enabled: false, profile_enabled: false }));
+ });
+
+ it('does not submit profile toggle immediately' , async () => {
+ const user = userEvent.setup(); renderPanel();
+ await user.click(screen.getByRole('switch', { name: 'memory.settings.profileEnableLabel' }));
+ expect(api.saveMemorySettings).not.toHaveBeenCalled();
+ });
+
+ it('preserves custom endpoint draft when profile is toggled', async () => {
+ const user = userEvent.setup(); renderPanel();
+ const model = screen.getByLabelText('memory.settings.embeddingTitle: memory.settings.model');
+ await user.clear(model); await user.type(model, 'draft-model');
+ await user.click(screen.getByRole('switch', { name: 'memory.settings.profileEnableLabel' }));
+ expect((model as HTMLInputElement).value).toBe('draft-model');
+ expect(api.saveMemorySettings).not.toHaveBeenCalled();
+ });
+
+ it('jointly saves endpoint draft and profile toggle', async () => {
+ const user = userEvent.setup(); renderPanel();
+ const model = screen.getByLabelText('memory.settings.embeddingTitle: memory.settings.model');
+ await user.clear(model); await user.type(model, 'joint-model');
+ await user.click(screen.getByRole('switch', { name: 'memory.settings.profileEnableLabel' }));
+ await user.click(screen.getByRole('button', { name: 'memory.settings.save' }));
+ await user.click(screen.getByRole('button', { name: 'confirm-loss' }));
+ await waitFor(() => expect(api.saveMemorySettings).toHaveBeenCalledWith({ confirm_loss: true, profile_enabled: false, processing: { embedding: { model: 'joint-model' } } }));
+ });
+
+ it('retains endpoint and profile drafts after rejected save', async () => {
+ const user = userEvent.setup(); api.saveMemorySettings.mockRejectedValue(new Error('rejected')); renderPanel();
+ const model = screen.getByLabelText('memory.settings.embeddingTitle: memory.settings.model');
+ await user.clear(model); await user.type(model, 'failed-model');
+ await user.click(screen.getByRole('switch', { name: 'memory.settings.profileEnableLabel' }));
+ await user.click(screen.getByRole('button', { name: 'memory.settings.save' }));
+ await user.click(screen.getByRole('button', { name: 'confirm-loss' }));
+ expect((model as HTMLInputElement).value).toBe('failed-model');
+ expect((screen.getByRole('switch', { name: 'memory.settings.profileEnableLabel' }) as HTMLButtonElement).getAttribute('aria-checked')).toBe('false');
+ });
+
it('does not call a standalone rebuild client after a confirmed save', async () => {
const user = userEvent.setup();
renderPanel();
diff --git a/ui/src/components/settings/memory/MemorySettingsPanel.tsx b/ui/src/components/settings/memory/MemorySettingsPanel.tsx
index cfc1ad39e..d5640da18 100644
--- a/ui/src/components/settings/memory/MemorySettingsPanel.tsx
+++ b/ui/src/components/settings/memory/MemorySettingsPanel.tsx
@@ -1,4 +1,4 @@
-import { useEffect, useState } from 'react';
+import { useEffect, useRef, useState } from 'react';
import { useTranslation } from 'react-i18next';
import {
Building2,
@@ -225,6 +225,8 @@ export const MemorySettingsPanel: React.FC<{
const api = useApi();
const { showToast } = useToast();
const [enabledDraft, setEnabledDraft] = useState(settings.enabled);
+ const profileBaseline = useRef(settings.profile_enabled);
+ const [profileEnabledDraft, setProfileEnabledDraft] = useState(settings.profile_enabled);
const [modeDraft, setModeDraft] = useState<MemorySettings['mode']>(settings.mode);
const [llmDraft, setLlmDraft] = useState<EndpointDraft>(() => draftFromConfig(settings.processing.llm));
const [embeddingDraft, setEmbeddingDraft] = useState<EndpointDraft>(() => draftFromConfig(settings.processing.embedding));
@@ -237,7 +239,10 @@ export const MemorySettingsPanel: React.FC<{
// Reset drafts whenever a fresh settings snapshot lands (initial load or after a save).
useEffect(() => {
+ const previousProfileBaseline = profileBaseline.current;
setEnabledDraft(settings.enabled);
+ setProfileEnabledDraft((current) => current === previousProfileBaseline ? settings.profile_enabled : current);
+ profileBaseline.current = settings.profile_enabled;
setModeDraft(settings.mode);
setLlmDraft(draftFromConfig(settings.processing.llm));
setEmbeddingDraft(draftFromConfig(settings.processing.embedding));
@@ -253,6 +258,7 @@ export const MemorySettingsPanel: React.FC<{
const buildPatch = (): MemorySettingsPatch => {
const patch: MemorySettingsPatch = {};
if (enabledDraft !== settings.enabled) patch.enabled = enabledDraft;
+ if (profileEnabledDraft !== settings.profile_enabled) patch.profile_enabled = profileEnabledDraft;
if (modeDraft !== settings.mode && modeDraft !== 'organization') patch.mode = modeDraft;
if (!customMode) return patch;
// Required keys can clear only while the resulting state stays disabled.
@@ -304,6 +310,7 @@ export const MemorySettingsPanel: React.FC<{
const res = await api.saveMemorySettings(patch);
if (isMemoryOk(res)) {
onSaved(res);
+ profileBaseline.current = res.profile_enabled;
const runtime = res.runtime as { ok?: boolean; error?: string } | undefined;
if (patch.confirm_loss && runtime && typeof runtime.ok === 'boolean') {
showToast(
@@ -391,7 +398,11 @@ export const MemorySettingsPanel: React.FC<{
const setMemoryEnabled = (checked: boolean) => {
setEnabledDraft(checked);
- if (!customMode) void submitPatch({ enabled: checked });
+ if (!customMode) void submitPatch({ enabled: checked, ...(profileEnabledDraft !== settings.profile_enabled ? { profile_enabled: profileEnabledDraft } : {}) });
+ };
+
+ const setProfileEnabled = (checked: boolean) => {
+ setProfileEnabledDraft(checked);
};
const usePlatformMode = () => {
@@ -399,12 +410,12 @@ export const MemorySettingsPanel: React.FC<{
setModeDraft('platform');
return;
}
- setPendingPatch({ mode: 'platform' });
+ setPendingPatch({ mode: 'platform', ...(profileEnabledDraft !== settings.profile_enabled ? { profile_enabled: profileEnabledDraft } : {}) });
setConfirmLossOpen(true);
};
const acknowledgeOrganizationTransition = () => {
- setPendingPatch({ acknowledge_transition: true });
+ setPendingPatch({ acknowledge_transition: true, ...(profileEnabledDraft !== settings.profile_enabled ? { profile_enabled: profileEnabledDraft } : {}) });
setConfirmLossOpen(true);
};
@@ -449,6 +460,14 @@ export const MemorySettingsPanel: React.FC<{
/>
</div>
+ <div className="flex items-start justify-between gap-4 rounded-xl border border-border bg-surface px-4 py-3.5">
+ <div className="flex min-w-0 flex-col gap-1">
+ <span className="text-[13px] font-semibold text-foreground">{t('memory.settings.profileEnableLabel')}</span>
+ <span className="text-[11.5px] leading-snug text-muted">{t('memory.settings.profileEnableHint')}</span>
+ </div>
+ <Switch checked={profileEnabledDraft} onCheckedChange={setProfileEnabled} disabled={busy} label={t('memory.settings.profileEnableLabel')} />
+ </div>
+
{modeDraft === 'platform' ? (
<div className="overflow-hidden rounded-xl border border-border bg-surface">
<div className="flex items-center justify-between gap-4 border-b border-border px-4 py-3.5">
@@ -564,7 +583,7 @@ export const MemorySettingsPanel: React.FC<{
) : null}
<div className="flex flex-wrap items-center justify-between gap-3">
- {customMode ? (
+ {(customMode || profileEnabledDraft !== settings.profile_enabled) ? (
<div className="flex flex-wrap items-center gap-2">
<Button onClick={() => void save()} disabled={busy}>
{saving ? <Loader2 className="size-3.5 animate-spin" /> : null}
diff --git a/ui/src/context/ApiContext.tsx b/ui/src/context/ApiContext.tsx
index a27d8fcfa..f758efa20 100644
--- a/ui/src/context/ApiContext.tsx
+++ b/ui/src/context/ApiContext.tsx
@@ -1940,6 +1940,7 @@ export type MemoryProcessingConfig = {
export type MemorySettings = {
status: 'ok';
enabled: boolean;
+ profile_enabled: boolean;
mode: 'organization' | 'platform' | 'custom';
cloud_available?: boolean;
managed?: boolean;
@@ -1961,6 +1962,7 @@ export type MemoryEndpointPatch = {
export type MemorySettingsPatch = {
enabled?: boolean;
+ profile_enabled?: boolean;
mode?: 'platform' | 'custom';
acknowledge_transition?: true;
processing?: {
diff --git a/ui/src/i18n/en.json b/ui/src/i18n/en.json
index 5b36acc3c..b1e2b79e0 100644
--- a/ui/src/i18n/en.json
+++ b/ui/src/i18n/en.json
@@ -4961,6 +4961,8 @@
"loadFailed": "Couldn't load Memory settings.",
"enableLabel": "Memory",
"enableHint": "Remembers what matters from your conversations.",
+ "profileEnableLabel": "Enable profile",
+ "profileEnableHint": "Use profile memories to personalize future responses.",
"avibeCloudTitle": "Model provider",
"avibeCloudFree": "Free",
"avibeCloudIncluded": "Provided by Avibe Cloud. No setup required.",
diff --git a/ui/src/i18n/zh.json b/ui/src/i18n/zh.json
index 91bcff643..91dea846b 100644
--- a/ui/src/i18n/zh.json
+++ b/ui/src/i18n/zh.json
@@ -4961,6 +4961,8 @@
"loadFailed": "无法加载记忆设置。",
"enableLabel": "记忆",
"enableHint": "记住对话中真正重要的内容。",
+ "profileEnableLabel": "启用画像",
+ "profileEnableHint": "使用记忆画像为未来回复提供个性化信息。",
"avibeCloudTitle": "模型供应商",
"avibeCloudFree": "免费",
"avibeCloudIncluded": "由 Avibe 云端提供,无需设置",
diff --git a/vibe/ui_memory_routes.py b/vibe/ui_memory_routes.py
index 840f7c046..d51e8d6f6 100644
--- a/vibe/ui_memory_routes.py
+++ b/vibe/ui_memory_routes.py
@@ -173,6 +173,7 @@ def _memory_settings_patch(
allowed_fields = {
"enabled",
+ "profile_enabled",
"processing",
"mode",
"acknowledge_transition",
@@ -187,7 +188,7 @@ def _memory_settings_patch(
raise ValueError("invalid_memory_patch")
if "acknowledge_transition" in patch_payload and not set(
patch_payload
- ).issubset({"acknowledge_transition", "confirm_loss"}):
+ ).issubset({"acknowledge_transition", "confirm_loss", "profile_enabled"}):
raise ValueError("invalid_memory_patch")
target = memory_config_to_payload(current.memory, include_secrets=True)
@@ -202,6 +203,10 @@ def _memory_settings_patch(
if not isinstance(patch_payload["enabled"], bool):
raise ValueError("invalid_memory_patch")
target["enabled"] = patch_payload["enabled"]
+ if "profile_enabled" in patch_payload:
+ if not isinstance(patch_payload["profile_enabled"], bool):
+ raise ValueError("invalid_memory_patch")
+ target["profile_enabled"] = patch_payload["profile_enabled"]
if "mode" in patch_payload:
mode = patch_payload["mode"]
if (