From ea9cef27c8b4c2a112b784dceabc03d0bfffe3b7 Mon Sep 17 00:00:00 2001 From: Erwan Leboucher Date: Thu, 14 May 2026 15:24:16 +0200 Subject: [PATCH] fix(hermes): is_available() must not do network calls --- integrations/hermes/__init__.py | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/integrations/hermes/__init__.py b/integrations/hermes/__init__.py index 7f17d98a..3f10fff7 100644 --- a/integrations/hermes/__init__.py +++ b/integrations/hermes/__init__.py @@ -96,8 +96,17 @@ def _preload_agentmemory_dotenv() -> None: 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 @@ def name(self) -> str: 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)