Skip to content

The agent that grows with you

fix(secrets): scope memory plugin credential reads (hindsight/honcho/supermemory/mem0/retaindb)

Teknium74b28c8910eb
diff --git a/plugins/memory/hindsight/__init__.py b/plugins/memory/hindsight/__init__.py
index 8c93df87f6c..086bb1239bc 100644
--- a/plugins/memory/hindsight/__init__.py
+++ b/plugins/memory/hindsight/__init__.py
@@ -44,6 +44,8 @@ import time
from datetime import datetime, timezone
from typing import Any, Dict, List
+from agent.secret_scope import get_secret
+
from agent.memory_provider import MemoryProvider
from hermes_constants import get_hermes_home
from tools.registry import tool_error
@@ -384,7 +386,7 @@ def _load_config() -> dict:
return {
"mode": os.environ.get("HINDSIGHT_MODE", "cloud"),
- "apiKey": os.environ.get("HINDSIGHT_API_KEY", ""),
+ "apiKey": get_secret("HINDSIGHT_API_KEY", ""),
"timeout": _parse_int_setting(os.environ.get("HINDSIGHT_TIMEOUT"), _DEFAULT_TIMEOUT),
"idle_timeout": _parse_int_setting(os.environ.get("HINDSIGHT_IDLE_TIMEOUT"), _DEFAULT_IDLE_TIMEOUT),
"retain_tags": os.environ.get("HINDSIGHT_RETAIN_TAGS", ""),
@@ -523,7 +525,7 @@ def _build_embedded_profile_env(config: dict[str, Any], *, llm_api_key: str | No
current_key = (
config.get("llmApiKey")
or config.get("llm_api_key")
- or os.environ.get("HINDSIGHT_LLM_API_KEY", "")
+ or get_secret("HINDSIGHT_LLM_API_KEY", "")
)
current_provider = config.get("llm_provider", "")
@@ -813,7 +815,7 @@ class HindsightMemoryProvider(MemoryProvider):
has_key = bool(
cfg.get("apiKey")
or cfg.get("api_key")
- or os.environ.get("HINDSIGHT_API_KEY", "")
+ or get_secret("HINDSIGHT_API_KEY", "")
)
has_url = bool(cfg.get("api_url") or os.environ.get("HINDSIGHT_API_URL", ""))
return has_key or has_url
@@ -922,7 +924,7 @@ class HindsightMemoryProvider(MemoryProvider):
# Step 3: Mode-specific config
if mode == "cloud":
print("\n Get your API key at https://ui.hindsight.vectorize.io\n")
- existing_key = os.environ.get("HINDSIGHT_API_KEY", "")
+ existing_key = get_secret("HINDSIGHT_API_KEY", "") or ""
if existing_key:
masked = f"...{existing_key[-4:]}" if len(existing_key) > 4 else "set"
sys.stdout.write(f" API key (current: {masked}, blank to keep): ")
@@ -1123,7 +1125,7 @@ class HindsightMemoryProvider(MemoryProvider):
kwargs = dict(
profile=self._config.get("profile", "hermes"),
llm_provider=llm_provider,
- llm_api_key=self._config.get("llmApiKey") or self._config.get("llm_api_key") or os.environ.get("HINDSIGHT_LLM_API_KEY", ""),
+ llm_api_key=self._config.get("llmApiKey") or self._config.get("llm_api_key") or get_secret("HINDSIGHT_LLM_API_KEY", ""),
llm_model=self._config.get("llm_model", ""),
)
if self._llm_base_url:
@@ -1522,7 +1524,7 @@ class HindsightMemoryProvider(MemoryProvider):
)
self._mode = "disabled"
return
- self._api_key = self._config.get("apiKey") or self._config.get("api_key") or os.environ.get("HINDSIGHT_API_KEY", "")
+ self._api_key = self._config.get("apiKey") or self._config.get("api_key") or get_secret("HINDSIGHT_API_KEY", "")
default_url = _DEFAULT_LOCAL_URL if self._mode in {"local_embedded", "local_external"} else _DEFAULT_API_URL
self._api_url = self._config.get("api_url") or os.environ.get("HINDSIGHT_API_URL", default_url)
self._llm_base_url = self._config.get("llm_base_url", "")
diff --git a/plugins/memory/honcho/client.py b/plugins/memory/honcho/client.py
index cc1da55ffaf..1945a38a15f 100644
--- a/plugins/memory/honcho/client.py
+++ b/plugins/memory/honcho/client.py
@@ -22,6 +22,7 @@ from dataclasses import dataclass, field
from pathlib import Path
from urllib.parse import urlparse
+from agent.secret_scope import get_secret
from hermes_constants import get_hermes_home
from hermes_cli.profiles import _get_default_hermes_home
from plugins.plugin_utils import SingletonSlot
@@ -469,7 +470,7 @@ class HonchoClientConfig:
) -> HonchoClientConfig:
"""Create config from environment variables (fallback)."""
resolved_host = host or resolve_active_host()
- api_key = os.environ.get("HONCHO_API_KEY")
+ api_key = get_secret("HONCHO_API_KEY")
base_url = os.environ.get("HONCHO_BASE_URL", "").strip() or None
timeout = _resolve_optional_float(os.environ.get("HONCHO_TIMEOUT"))
return cls(
@@ -525,7 +526,7 @@ class HonchoClientConfig:
api_key = (
host_block.get("apiKey")
or raw.get("apiKey")
- or os.environ.get("HONCHO_API_KEY")
+ or get_secret("HONCHO_API_KEY")
)
environment = (
diff --git a/plugins/memory/mem0/__init__.py b/plugins/memory/mem0/__init__.py
index b060a7bf7a8..ea871c44cc4 100644
--- a/plugins/memory/mem0/__init__.py
+++ b/plugins/memory/mem0/__init__.py
@@ -41,6 +41,7 @@ import time
from typing import Any, Dict, List
from agent.memory_provider import MemoryProvider
+from agent.secret_scope import get_secret
from tools.registry import tool_error
logger = logging.getLogger(__name__)
@@ -85,7 +86,7 @@ def _load_config() -> dict:
config = {
"mode": os.environ.get("MEM0_MODE", "platform"),
- "api_key": os.environ.get("MEM0_API_KEY", ""),
+ "api_key": get_secret("MEM0_API_KEY", ""),
"host": os.environ.get("MEM0_HOST", ""),
"agent_id": os.environ.get("MEM0_AGENT_ID", "hermes"),
"oss": {},
diff --git a/plugins/memory/retaindb/__init__.py b/plugins/memory/retaindb/__init__.py
index a777ccbd55e..13ad0331501 100644
--- a/plugins/memory/retaindb/__init__.py
+++ b/plugins/memory/retaindb/__init__.py
@@ -34,6 +34,7 @@ from typing import Any, Dict, List
from urllib.parse import quote
from agent.memory_provider import MemoryProvider
+from agent.secret_scope import get_secret
from agent.file_safety import raise_if_read_blocked
from tools.registry import tool_error
@@ -476,7 +477,7 @@ class RetainDBMemoryProvider(MemoryProvider):
return "retaindb"
def is_available(self) -> bool:
- return bool(os.environ.get("RETAINDB_API_KEY"))
+ return bool(get_secret("RETAINDB_API_KEY"))
def get_config_schema(self) -> List[Dict[str, Any]]:
return [
@@ -488,7 +489,7 @@ class RetainDBMemoryProvider(MemoryProvider):
# ── Lifecycle ──────────────────────────────────────────────────────────
def initialize(self, session_id: str, **kwargs) -> None:
- api_key = os.environ.get("RETAINDB_API_KEY", "")
+ api_key = get_secret("RETAINDB_API_KEY", "") or ""
base_url = re.sub(r"/+$", "", os.environ.get("RETAINDB_BASE_URL", _DEFAULT_BASE_URL))
# Project resolution: RETAINDB_PROJECT > hermes-<profile> > "default"
diff --git a/plugins/memory/supermemory/__init__.py b/plugins/memory/supermemory/__init__.py
index 2112b5095d7..7d737fd3677 100644
--- a/plugins/memory/supermemory/__init__.py
+++ b/plugins/memory/supermemory/__init__.py
@@ -18,6 +18,7 @@ from pathlib import Path
from typing import Any, Dict, List, Optional
from agent.memory_provider import MemoryProvider
+from agent.secret_scope import get_secret, is_multiplex_active
from tools.registry import tool_error
logger = logging.getLogger(__name__)
@@ -572,7 +573,7 @@ class SupermemoryMemoryProvider(MemoryProvider):
# Docker venv the package isn't present until ensure() runs, but
# ensure() only runs once the provider is loaded — which this gates.
# Mirrors honcho/mem0, which check config only. No network calls.
- return bool(os.environ.get("SUPERMEMORY_API_KEY", ""))
+ return bool(get_secret("SUPERMEMORY_API_KEY", ""))
def get_config_schema(self):
# Only prompt for the API key during `hermes memory setup`.
@@ -595,7 +596,7 @@ class SupermemoryMemoryProvider(MemoryProvider):
del provider_config
hermes_home = str(get_hermes_home())
- api_key = os.environ.get("SUPERMEMORY_API_KEY", "")
+ api_key = get_secret("SUPERMEMORY_API_KEY", "") or ""
status = _probe_supermemory_connection(api_key, hermes_home)
return {"summary": _format_connection_summary(status)}
@@ -630,7 +631,15 @@ class SupermemoryMemoryProvider(MemoryProvider):
# Make the freshly-entered key visible to the connection probe below.
# (Checks the VALUE of SUPERMEMORY_API_KEY, not whether the key string
# happens to name some unrelated env var.)
- if api_key and os.environ.get("SUPERMEMORY_API_KEY") != api_key:
+ # Single-profile convenience only: never write a profile's key into
+ # the process-global environ under a multiplexed gateway — sibling
+ # profiles' turns (and any subprocess spawned with env=os.environ)
+ # would inherit it.
+ if (
+ api_key
+ and not is_multiplex_active()
+ and os.environ.get("SUPERMEMORY_API_KEY") != api_key
+ ):
os.environ["SUPERMEMORY_API_KEY"] = api_key
status = _probe_supermemory_connection(api_key, hermes_home)
@@ -647,7 +656,7 @@ class SupermemoryMemoryProvider(MemoryProvider):
self._session_id = session_id
self._turn_count = 0
self._config = _load_supermemory_config(self._hermes_home)
- self._api_key = os.environ.get("SUPERMEMORY_API_KEY", "")
+ self._api_key = get_secret("SUPERMEMORY_API_KEY", "") or ""
# Resolve container tag: env var > config > default.
# Supports {identity} template for profile-scoped containers.