bytedance/deer-flow · error · ValueError
mem0 backend_config has unknown keys: {sorted(unknown)}
Error message
mem0 backend_config has unknown keys: {sorted(unknown)} What it means
Raised by Mem0Config.from_backend_config when memory.backend_config (with manager_class: mem0) contains keys outside the accepted set {api_key_env, base_url, allow_insecure_http, top_k, score_threshold, max_injection_chars, timeout_seconds, startup_policy} plus the host-injected {storage_path, should_keep_hidden_message} (accepted and ignored). This is deliberate fail-fast design: a typo in persistent-state config must not silently fall back to defaults.
Source
Thrown at backend/packages/harness/deerflow/agents/memory/backends/mem0/config.py:74
def from_backend_config(cls, backend_config: dict[str, Any] | None) -> Mem0Config:
cfg = dict(backend_config or {})
failure_policy = cfg.pop("failure_policy", {}) or {}
unknown = (
set(cfg)
- {
"api_key_env",
"base_url",
"allow_insecure_http",
"top_k",
"score_threshold",
"max_injection_chars",
"timeout_seconds",
"startup_policy",
}
- _HOST_INJECTED_KEYS
)
if unknown:
raise ValueError(f"mem0 backend_config has unknown keys: {sorted(unknown)}")
if not isinstance(failure_policy, dict):
raise ValueError("mem0 failure_policy must be a mapping {read, write}")
unknown_fp = set(failure_policy) - {"read", "write"}
if unknown_fp:
raise ValueError(f"mem0 failure_policy has unknown keys: {sorted(unknown_fp)}")
allow_insecure_http = cfg.get("allow_insecure_http", False)
if not isinstance(allow_insecure_http, bool):
raise ValueError("mem0 allow_insecure_http must be a boolean")
config = cls(
api_key_env=str(cfg.get("api_key_env", "MEM0_API_KEY")),
base_url=str(cfg.get("base_url", "https://api.mem0.ai")).rstrip("/"),
allow_insecure_http=allow_insecure_http,
top_k=int(cfg.get("top_k", 8)),
score_threshold=float(cfg.get("score_threshold", 0.1)),
max_injection_chars=int(cfg.get("max_injection_chars", 12000)),
timeout_seconds=float(cfg.get("timeout_seconds", 10.0)),
startup_policy=str(cfg.get("startup_policy", "fail_fast")),View on GitHub (pinned to 1dd6ba1acb)
Solutions
- Remove or correct the key(s) listed in the message — the sorted unknown list tells you exactly which ones are rejected
- If you meant to supply the API key, set api_key_env: MEM0_API_KEY (name only) and export the key in the environment; the key value itself is never valid in config
- Move per-backend policy settings under failure_policy: {read, write} which is validated separately
- Check the mem0 backend section of the DeerFlow memory docs for the exact supported key set
Example fix
# before (config.yaml)
memory:
manager_class: mem0
backend_config:
api_key: "m0-sk-..." # unknown key -> ValueError
top_k: 8
# after
memory:
manager_class: mem0
backend_config:
api_key_env: MEM0_API_KEY # key value goes in the environment
top_k: 8 Defensive patterns
Strategy: validation
Validate before calling
ALLOWED = {"api_key_env", "base_url", "allow_insecure_http", "top_k",
"score_threshold", "max_injection_chars", "timeout_seconds",
"startup_policy", "failure_policy", "storage_path", "should_keep_hidden_message"}
def mem0_config_keys_ok(backend_config: dict) -> bool:
return not (set(backend_config or {}) - ALLOWED)
# Stronger: parse it for real — this runs every validation rule.
from deerflow.agents.memory.backends.mem0.config import Mem0Config
Mem0Config.from_backend_config(backend_config) # raises ValueError on any problem Prevention
- Validate config in CI/deploy by calling Mem0Config.from_backend_config on the rendered config before rollout
- Never place the API key value in backend_config — only api_key_env (the env var name)
- Per-backend options are not portable: honcho keys (workspace_prefix, assistant_peer, ...) are rejected by the mem0 parser
When it happens
Trigger: Adding any extra key under memory.backend_config, e.g. api_key (the mem0 backend takes the key via env var, not config), failure_policy is fine (popped before the check) but failure_policies is an unknown key, mem0_api_key, max_tokens, or a key that only the honcho backend understands (workspace_prefix, assistant_peer).
Common situations: Copy-pasting honcho or generic backend options into the mem0 block; trying to put the API key in config (must use api_key_env env var instead); version drift — using a key from a newer/older DeerFlow docs page; leftover experimental keys after an upgrade.
Related errors
- mem0 failure_policy must be a mapping {read, write}
- mem0 failure_policy has unknown keys: {sorted(unknown_fp)}
- Honcho backend: {key}[{k!r}] has an empty value; remove the
- mem0 allow_insecure_http must be a boolean
- mem0 startup_policy must be one of {sorted(_STARTUP_POLICIES
AI-assisted analysis of bytedance/deer-flow@1dd6ba1acb (2026-08-14).
Data as JSON: /api/errors/28b00eaf0c2b8cd7.
Report an issue: GitHub.