The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
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__.pyindex 8c93df87f6c..086bb1239bc 100644--- a/plugins/memory/hindsight/__init__.py+++ b/plugins/memory/hindsight/__init__.py@@ -44,6 +44,8 @@ import timefrom datetime import datetime, timezonefrom typing import Any, Dict, List+from agent.secret_scope import get_secret+from agent.memory_provider import MemoryProviderfrom hermes_constants import get_hermes_homefrom 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 | Nocurrent_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 configif 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_URLself._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.pyindex cc1da55ffaf..1945a38a15f 100644--- a/plugins/memory/honcho/client.py+++ b/plugins/memory/honcho/client.py@@ -22,6 +22,7 @@ from dataclasses import dataclass, fieldfrom pathlib import Pathfrom urllib.parse import urlparse+from agent.secret_scope import get_secretfrom hermes_constants import get_hermes_homefrom hermes_cli.profiles import _get_default_hermes_homefrom 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 Nonetimeout = _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__.pyindex b060a7bf7a8..ea871c44cc4 100644--- a/plugins/memory/mem0/__init__.py+++ b/plugins/memory/mem0/__init__.py@@ -41,6 +41,7 @@ import timefrom typing import Any, Dict, Listfrom agent.memory_provider import MemoryProvider+from agent.secret_scope import get_secretfrom tools.registry import tool_errorlogger = 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__.pyindex a777ccbd55e..13ad0331501 100644--- a/plugins/memory/retaindb/__init__.py+++ b/plugins/memory/retaindb/__init__.py@@ -34,6 +34,7 @@ from typing import Any, Dict, Listfrom urllib.parse import quotefrom agent.memory_provider import MemoryProvider+from agent.secret_scope import get_secretfrom agent.file_safety import raise_if_read_blockedfrom 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__.pyindex 2112b5095d7..7d737fd3677 100644--- a/plugins/memory/supermemory/__init__.py+++ b/plugins/memory/supermemory/__init__.py@@ -18,6 +18,7 @@ from pathlib import Pathfrom typing import Any, Dict, List, Optionalfrom agent.memory_provider import MemoryProvider+from agent.secret_scope import get_secret, is_multiplex_activefrom tools.registry import tool_errorlogger = 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_confighermes_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_keystatus = _probe_supermemory_connection(api_key, hermes_home)@@ -647,7 +656,7 @@ class SupermemoryMemoryProvider(MemoryProvider):self._session_id = session_idself._turn_count = 0self._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.