{"record":{"id":"0e87af94bc47a0ea","repo":"bytedance/deer-flow","slug":"mem0-request-failed-e","errorCode":null,"errorMessage":"mem0 request failed: {e}","messagePattern":"mem0 request failed: (.+?)","errorType":"exception","errorClass":"Mem0APIError","httpStatus":null,"severity":"error","filePath":"backend/packages/harness/deerflow/agents/memory/backends/mem0/client.py","lineNumber":49,"sourceCode":"        api_key: str,\n        timeout_seconds: float = 10.0,\n        transport: httpx.BaseTransport | None = None,\n    ) -> None:\n        self._http = httpx.Client(\n            base_url=base_url.rstrip(\"/\"),\n            headers={\"Authorization\": f\"Token {api_key}\", \"Accept\": \"application/json\"},\n            timeout=timeout_seconds,\n            transport=transport,\n        )\n\n    def close(self) -> None:\n        self._http.close()\n\n    def _request(self, method: str, path: str, **kwargs: Any) -> dict[str, Any]:\n        try:\n            resp = self._http.request(method, path, **kwargs)\n        except httpx.HTTPError as e:\n            raise Mem0APIError(f\"mem0 request failed: {e}\") from e\n        if resp.status_code == 401:\n            raise Mem0AuthError(\"mem0 authentication failed (check the API key)\")\n        if resp.status_code >= 400:\n            raise Mem0APIError(f\"mem0 {method} {path} -> {resp.status_code}: {resp.text[:200]}\")\n        if not resp.content:\n            return {}\n        try:\n            return resp.json()\n        except json.JSONDecodeError as e:\n            raise Mem0APIError(f\"mem0 {method} {path} returned malformed JSON: {e}\") from e\n\n    def add_memories(\n        self,\n        *,\n        messages: list[dict[str, str]],\n        user_id: str | None = None,\n        agent_id: str | None = None,\n        run_id: str | None = None,","sourceCodeStart":31,"sourceCodeEnd":67,"githubUrl":"https://github.com/bytedance/deer-flow/blob/1dd6ba1acb03700589994b0366c5d1c7d05e2eff/backend/packages/harness/deerflow/agents/memory/backends/mem0/client.py#L31-L67","documentation":"Raised as Mem0APIError by Mem0Client._request when httpx fails below the HTTP layer — the request to the mem0 Platform API raised httpx.HTTPError (connection refused, DNS failure, TLS error, or timeout exceeding timeout_seconds). It means no HTTP response was received at all; the message embeds the underlying httpx exception text for diagnosis.","triggerScenarios":"Any Mem0Client call (add_memories, search, get_context, ...) while the configured base_url is unreachable, DNS does not resolve, a proxy blocks the request, or the server takes longer than timeout_seconds (default 10.0) to respond.","commonSituations":"Self-hosted mem0 base_url pointing at a stopped container; mem0.ai unreachable behind a corporate proxy/firewall; timeout_seconds too small for slow memory extraction endpoints; typo in base_url host; the Gateway losing network during a run.","solutions":["Verify connectivity from the Gateway host: curl -H \"Authorization: Token $MEM0_API_KEY\" <base_url> with a simple GET","Fix base_url in memory.backend_config (scheme, host, port) — note it must be http(s) and https unless allow_insecure_http is set","If the error text mentions a timeout, raise timeout_seconds in backend_config","Configure httpx/HTTPS_PROXY env vars if a corporate proxy is required; ensure DNS resolves the host"],"exampleFix":"# before (config.yaml)\nmemory:\n  manager_class: mem0\n  backend_config:\n    base_url: http://mem0:8080   # container not running\n    timeout_seconds: 2\n\n# after\nmemory:\n  manager_class: mem0\n  backend_config:\n    base_url: https://api.mem0.ai\n    timeout_seconds: 15","handlingStrategy":"retry","validationCode":"import httpx\n\ndef mem0_endpoint_reachable(base_url: str, timeout: float = 3.0) -> bool:\n    try:\n        httpx.get(base_url, timeout=timeout)  # any HTTP answer proves reachability\n        return True\n    except httpx.HTTPError:\n        return False","typeGuard":null,"tryCatchPattern":"from deerflow.agents.memory.backends.mem0.client import Mem0APIError\n\nfor attempt in range(3):\n    try:\n        result = client.search(query=..., user_id=...)\n        break\n    except Mem0APIError as e:\n        if \"request failed\" not in str(e) or attempt == 2:\n            raise   # non-transport errors, or retries exhausted\n        time.sleep(2 ** attempt)   # transport-level failure: backoff and retry","preventionTips":["Verify base_url reachability from the Gateway host before enabling the mem0 backend (curl the API root)","Size timeout_seconds against observed p99 latency of the mem0 endpoint","Rely on failure_policy defaults (read: fail_open, write: log_and_drop) so transient transport errors degrade instead of failing runs"],"tags":["mem0","memory","network","http","timeout"],"backgroundTag":null,"analyzedSha":"1dd6ba1acb03700589994b0366c5d1c7d05e2eff","analyzedAt":"2026-08-14T21:20:34.804Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}