bytedance/deer-flow · error · Mem0APIError
mem0 request failed: {e}
Error message
mem0 request failed: {e} What it means
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.
Source
Thrown at backend/packages/harness/deerflow/agents/memory/backends/mem0/client.py:49
api_key: str,
timeout_seconds: float = 10.0,
transport: httpx.BaseTransport | None = None,
) -> None:
self._http = httpx.Client(
base_url=base_url.rstrip("/"),
headers={"Authorization": f"Token {api_key}", "Accept": "application/json"},
timeout=timeout_seconds,
transport=transport,
)
def close(self) -> None:
self._http.close()
def _request(self, method: str, path: str, **kwargs: Any) -> dict[str, Any]:
try:
resp = self._http.request(method, path, **kwargs)
except httpx.HTTPError as e:
raise Mem0APIError(f"mem0 request failed: {e}") from e
if resp.status_code == 401:
raise Mem0AuthError("mem0 authentication failed (check the API key)")
if resp.status_code >= 400:
raise Mem0APIError(f"mem0 {method} {path} -> {resp.status_code}: {resp.text[:200]}")
if not resp.content:
return {}
try:
return resp.json()
except json.JSONDecodeError as e:
raise Mem0APIError(f"mem0 {method} {path} returned malformed JSON: {e}") from e
def add_memories(
self,
*,
messages: list[dict[str, str]],
user_id: str | None = None,
agent_id: str | None = None,
run_id: str | None = None,View on GitHub (pinned to 1dd6ba1acb)
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
Example fix
# before (config.yaml)
memory:
manager_class: mem0
backend_config:
base_url: http://mem0:8080 # container not running
timeout_seconds: 2
# after
memory:
manager_class: mem0
backend_config:
base_url: https://api.mem0.ai
timeout_seconds: 15 Defensive patterns
Strategy: retry
Validate before calling
import httpx
def mem0_endpoint_reachable(base_url: str, timeout: float = 3.0) -> bool:
try:
httpx.get(base_url, timeout=timeout) # any HTTP answer proves reachability
return True
except httpx.HTTPError:
return False Try / catch
from deerflow.agents.memory.backends.mem0.client import Mem0APIError
for attempt in range(3):
try:
result = client.search(query=..., user_id=...)
break
except Mem0APIError as e:
if "request failed" not in str(e) or attempt == 2:
raise # non-transport errors, or retries exhausted
time.sleep(2 ** attempt) # transport-level failure: backoff and retry Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- agents_api.enabled
- Failed to create agent: ${res.statusText}
- Honcho request failed: POST {path}: {exc}
- mem0 {method} {path} -> {resp.status_code}: {resp.text[:200]
- mem0 {method} {path} returned malformed JSON: {e}
AI-assisted analysis of bytedance/deer-flow@1dd6ba1acb (2026-08-14).
Data as JSON: /api/errors/0e87af94bc47a0ea.
Report an issue: GitHub.