{"record":{"id":"0a1f4985e812af25","repo":"bytedance/deer-flow","slug":"import-memory-not-supported-by-type-self-name","errorCode":null,"errorMessage":"import_memory not supported by {type(self).__name__}","messagePattern":"import_memory not supported by (.+?)","errorType":"exception","errorClass":"NotImplementedError","httpStatus":null,"severity":"error","filePath":"backend/packages/harness/deerflow/agents/memory/manager.py","lineNumber":326,"sourceCode":"        \"\"\"Clear the bucket's memory; return the cleared (now-empty) document.\n\n        ``agent_name=None`` means all memory owned by the user. An explicit\n        agent name clears only that agent's memory and must preserve shared\n        user-level summaries. Default: unsupported (raise\n        ``NotImplementedError``); backends that support clearing override.\n        \"\"\"\n        raise NotImplementedError(f\"clear_memory not supported by {type(self).__name__}\")\n\n    def import_memory(\n        self,\n        memory_data: dict[str, Any],\n        *,\n        user_id: str | None = None,\n        agent_name: str | None = None,\n    ) -> dict[str, Any]:\n        \"\"\"Import a memory document into the bucket; return the merged result.\n        Default: unsupported.\"\"\"\n        raise NotImplementedError(f\"import_memory not supported by {type(self).__name__}\")\n\n    def export_memory(\n        self,\n        *,\n        user_id: str | None = None,\n        agent_name: str | None = None,\n    ) -> dict[str, Any]:\n        \"\"\"Export the memory document for the bucket. Default: unsupported (dead\n        contract -- zero callers; /memory/export routes via get_memory).\"\"\"\n        raise NotImplementedError(f\"export_memory not supported by {type(self).__name__}\")\n\n    def shutdown_flush(self, timeout: float) -> bool:\n        \"\"\"Best-effort bounded drain of pending updates on graceful shutdown.\n\n        Runs on the Gateway shutdown path (after IM channels and the scheduler\n        stop, so no new IM/scheduler updates arrive during the drain) to flush\n        updates still sitting in the backend's debounce buffer. Without it, any\n        update enqueued since the last timer fire is lost on restart / rolling","sourceCodeStart":308,"sourceCodeEnd":344,"githubUrl":"https://github.com/bytedance/deer-flow/blob/1dd6ba1acb03700589994b0366c5d1c7d05e2eff/backend/packages/harness/deerflow/agents/memory/manager.py#L308-L344","documentation":"MemoryManager.import_memory raises NotImplementedError by design: the base class in deerflow/agents/memory/manager.py treats importing a memory document into the backend's bucket as an optional capability, and only backends that persist a self-contained local memory document (the default DeerMem file backend) override it. Remote or no-op backends (noop, mem0, honcho, openviking adapters) inherit the raising default because they either keep no importable document or cannot accept one through their API. Hitting it means the configured memory backend simply does not implement document import.","triggerScenarios":"Calling MemoryManager.import_memory(memory_data, user_id=..., agent_name=...) — directly in Python, or through any code path (API route, script, test) that forwards an import payload — while memory.manager_class resolves to a backend whose class does not override import_memory (e.g. 'noop', 'mem0', 'honcho', 'openviking'). DeerMem overrides it, so the error never fires on the default configuration.","commonSituations":"Switching config.yaml memory.manager_class from deermem to a remote backend (honcho/mem0/openviking) and then replaying an export/import workflow that worked before; running a migration or backup-restore script that unconditionally calls import_memory; unit tests written against DeerMem being pointed at the noop backend.","solutions":["Switch memory.manager_class back to a backend that implements import (set memory.manager_class: deermem in config.yaml) and retry the import.","If you must keep the current backend, guard the call with hasattr/try and skip or transform the import (e.g. re-create facts individually via a backend-supported write path).","If you own the backend, override import_memory on your MemoryManager subclass to merge the document into your store.","Check the backend's package under deerflow/agents/memory/backends/<name>/ to confirm which manager methods it overrides before building import tooling."],"exampleFix":"# before\nmanager = MemoryManager.from_config(cfg)\nresult = manager.import_memory(doc, user_id=\"u1\")  # NotImplementedError on noop/mem0/honcho\n\n# after\nif type(manager).import_memory is MemoryManager.import_memory:\n    raise RuntimeError(f\"backend {type(manager).__name__} cannot import memory\")\nresult = manager.import_memory(doc, user_id=\"u1\")","handlingStrategy":"type-guard","validationCode":"from deerflow.agents.memory.manager import MemoryManager\n\ndef supports_import(manager: MemoryManager) -> bool:\n    return type(manager).import_memory is not MemoryManager.import_memory","typeGuard":"def supports_import(manager: MemoryManager) -> bool:\n    \"\"\"True when the backend overrides import_memory (i.e. supports it).\"\"\"\n    return type(manager).import_memory is not MemoryManager.import_memory","tryCatchPattern":"try:\n    result = manager.import_memory(doc, user_id=uid)\nexcept NotImplementedError as e:\n    # capability mismatch, not a transient failure: report, do not retry\n    raise UnsupportedMemoryOperation(str(e)) from e","preventionTips":["Check which methods the configured backend overrides before building import/export tooling (read deerflow/agents/memory/backends/<name>/).","Feature-gate import UI on the capability check, not on config flags alone.","Keep deployment docs listing per-backend capabilities next to memory.manager_class settings."],"tags":["memory","not-implemented","backend","deerflow"],"backgroundTag":null,"analyzedSha":"1dd6ba1acb03700589994b0366c5d1c7d05e2eff","analyzedAt":"2026-08-14T21:20:34.804Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}