Skip to content

#1 Persistent memory for AI coding agents based on real-world benchmarks

fix(hermes): is_available() must not do network calls (#377)

Erwan Leboucher1c8713f97813
diff --git a/integrations/hermes/__init__.py b/integrations/hermes/__init__.py
index abfaf5a1..a93026c0 100644
--- a/integrations/hermes/__init__.py
+++ b/integrations/hermes/__init__.py
@@ -96,8 +96,17 @@ _preload_agentmemory_dotenv()
def _validate_url(base: str) -> bool:
- parsed = urlparse(base)
- return parsed.scheme in ("http", "https")
+ if not base:
+ return False
+ try:
+ parsed = urlparse(base)
+ # .port raises ValueError on a non-numeric or out-of-range port
+ _ = parsed.port
+ except ValueError:
+ return False
+ if parsed.scheme not in ("http", "https"):
+ return False
+ return bool(parsed.hostname)
def _uses_plaintext_bearer_auth(base: str, secret: str = "") -> bool:
@@ -167,15 +176,9 @@ class AgentMemoryProvider(MemoryProvider):
return "agentmemory"
def is_available(self) -> bool:
+ # Hermes contract: no network calls in is_available.
base = os.environ.get("AGENTMEMORY_URL", DEFAULT_BASE_URL)
- if not _validate_url(base):
- return False
- try:
- req = Request(f"{base}/agentmemory/health", method="GET")
- with urlopen(req, timeout=2):
- return True
- except Exception:
- return False
+ return _validate_url(base)
def initialize(self, session_id: str, **kwargs: Any) -> None:
self._base = os.environ.get("AGENTMEMORY_URL", DEFAULT_BASE_URL)