bytedance/deer-flow · error · NotImplementedError

clear_memory not supported by {type(self).__name__}

Error message

clear_memory not supported by {type(self).__name__}

What it means

The base MemoryManager.clear_memory() raises NotImplementedError naming the backend class. Clearing a bucket's memory is an optional mutating capability that backends must override; the default refuses rather than pretending to clear, because a silent no-op would leave the user believing their memory was erased. Per the docstring, agent_name=None means all user-owned memory; an explicit agent clears only that bucket.

Source

Thrown at backend/packages/harness/deerflow/agents/memory/manager.py:315

    ) -> None:
        """Delete the entire memory document for the bucket. Default: unsupported
        (dead contract -- zero callers)."""
        raise NotImplementedError(f"delete_memory not supported by {type(self).__name__}")

    def clear_memory(
        self,
        *,
        user_id: str | None = None,
        agent_name: str | None = None,
    ) -> dict[str, Any]:
        """Clear the bucket's memory; return the cleared (now-empty) document.

        ``agent_name=None`` means all memory owned by the user. An explicit
        agent name clears only that agent's memory and must preserve shared
        user-level summaries. Default: unsupported (raise
        ``NotImplementedError``); backends that support clearing override.
        """
        raise NotImplementedError(f"clear_memory not supported by {type(self).__name__}")

    def import_memory(
        self,
        memory_data: dict[str, Any],
        *,
        user_id: str | None = None,
        agent_name: str | None = None,
    ) -> dict[str, Any]:
        """Import a memory document into the bucket; return the merged result.
        Default: unsupported."""
        raise NotImplementedError(f"import_memory not supported by {type(self).__name__}")

    def export_memory(
        self,
        *,
        user_id: str | None = None,
        agent_name: str | None = None,
    ) -> dict[str, Any]:

View on GitHub (pinned to 1dd6ba1acb)

Solutions

  1. Capability-check before calling: only invoke clear_memory when the backend overrides it (type(manager).clear_memory is not MemoryManager.clear_memory)
  2. Use a backend that implements clear (e.g. DeerMem file storage) if destructive clear is a product requirement
  3. In custom backends, override clear_memory() honoring the agent_name=None-means-all semantics (preserve shared user summaries on explicit-agent clears)

Example fix

# before
manager.clear_memory(user_id='default')

# after
is_overridden = type(manager).clear_memory is not MemoryManager.clear_memory
if is_overridden:
    manager.clear_memory(user_id='default')
else:
    raise LookupError(f'{type(manager).__name__} does not support clearing memory')
Defensive patterns

Strategy: type-guard

Validate before calling

from deerflow.agents.memory.manager import MemoryManager
if type(manager).clear_memory is MemoryManager.clear_memory:
    raise LookupError(f"{type(manager).__name__} does not support clearing memory")
manager.clear_memory(user_id=user, agent_name=agent_name)

Type guard

def backend_can_clear(manager) -> bool:
    from deerflow.agents.memory.manager import MemoryManager
    return type(manager).clear_memory is not MemoryManager.clear_memory

Try / catch

try:
    manager.clear_memory(user_id=user)
except NotImplementedError:
    surface_ui_error("This memory backend does not support clearing")  # never report success

Prevention

When it happens

Trigger: Calling manager.clear_memory(user_id=..., agent_name=...) on a backend that does not override clear_memory — e.g. a custom minimal backend, or a remote adapter that intentionally exposes no destructive clear.

Common situations: 'Delete my data' flows or admin tooling calling clear_memory() unconditionally across backends; test teardown code that clears memory after each test against a backend without clear support.

Related errors


AI-assisted analysis of bytedance/deer-flow@1dd6ba1acb (2026-08-14). Data as JSON: /api/errors/70ef12c09a76690d. Report an issue: GitHub.