From 42291693ab2dd780b643b064847afdca822fe0a0 Mon Sep 17 00:00:00 2001 From: Teknium <127238744+teknium1@users.noreply.github.com> Date: Wed, 2 Sep 2026 20:57:29 -0700 Subject: [PATCH 01/25] refactor(memory/retaindb): fold HTTP calls into one _http helper, unify debug-logged failures via _quiet, compact schemas/client --- plugins/memory/retaindb/__init__.py | 292 +++++++++++----------------- 1 file changed, 114 insertions(+), 178 deletions(-) diff --git a/plugins/memory/retaindb/__init__.py b/plugins/memory/retaindb/__init__.py index ed21555795..77349ac5bb 100644 --- a/plugins/memory/retaindb/__init__.py +++ b/plugins/memory/retaindb/__init__.py @@ -2,9 +2,8 @@ Cross-session memory via the RetainDB cloud API: durable SQLite write-behind queue, semantic search + profile, context overlay, dialectic/agent self-model prefetch, shared file store tools. - -Config (env vars, or config.yaml ``memory.retaindb`` for the non-secret ones): RETAINDB_API_KEY (required), -RETAINDB_BASE_URL (default https://api.retaindb.com), RETAINDB_PROJECT (optional; defaults to "default"). +Config: RETAINDB_API_KEY (required, scoped secret), RETAINDB_BASE_URL (default https://api.retaindb.com), +RETAINDB_PROJECT (optional; defaults to "default"); the non-secret two also read config.yaml ``memory.retaindb``. """ from __future__ import annotations @@ -20,7 +19,7 @@ import time from contextlib import suppress from datetime import datetime, timezone from pathlib import Path -from typing import Any, Callable, Dict, List +from typing import Any, Callable from urllib.parse import quote from agent.memory_provider import MemoryProvider @@ -35,19 +34,18 @@ _ASYNC_SHUTDOWN = object() _TEXT_EXTS = (".txt", ".md", ".json", ".csv", ".yaml", ".yml", ".xml", ".html") -def _load_retaindb_config() -> Dict[str, Any]: +def _load_retaindb_config() -> dict[str, Any]: """``memory.retaindb`` block from config.yaml (empty on error): Dashboard-persisted base_url/project; api_key stays in scoped secrets.""" try: from hermes_cli.config import load_config_readonly - provider_config = load_config_readonly().get("memory", {}).get("retaindb", {}) - return dict(provider_config) if isinstance(provider_config, dict) else {} + block = load_config_readonly().get("memory", {}).get("retaindb", {}) + return dict(block) if isinstance(block, dict) else {} except Exception: return {} def _config_str(value: Any) -> str: - """Stripped string for a config value, else ``""``.""" return value.strip() if isinstance(value, str) else "" @@ -55,66 +53,54 @@ def _q(s: str) -> str: return quote(s, safe="") -# ── Tool schemas ───────────────────────────────────────────────────────────── +def _quiet(label: str, fn: Callable[[], Any]) -> Any: + """Run *fn*; on any exception log "RetainDB