> ## Documentation Index
> Fetch the complete documentation index at: https://praison.ai/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Knowledge Erasure

> Clear, delete, and inspect knowledge with loud, predictable guarantees

Erasure clears an agent's knowledge base between sessions, with clear errors when an adapter can't support an operation.

```python theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
from praisonaiagents import Agent

agent = Agent(name="privacy-aware", instructions="Answer, then clear context between sessions.", knowledge=["policy.md"])
agent.start("Summarise the policy")
agent.knowledge.reset()   # clears the knowledge base between sessions
```

```mermaid theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
graph LR
    subgraph "Knowledge Erasure"
        A[📚 Knowledge] --> B{🔍 Adapter supports op?}
        B -->|Yes| C[✅ Erased — reset returns True]
        B -->|reset unsupported| D[⚠️ Warning no-op — reset returns False]
        B -->|delete_all / history unsupported| E[❌ NotImplementedError]
    end

    classDef input fill:#8B0000,stroke:#7C90A0,color:#fff
    classDef process fill:#F59E0B,stroke:#7C90A0,color:#fff
    classDef success fill:#10B981,stroke:#7C90A0,color:#fff
    classDef warn fill:#6366F1,stroke:#7C90A0,color:#fff

    class A input
    class B process
    class C success
    class D,E warn
```

## Quick Start

**1. Reset the knowledge base**

```python theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
from praisonaiagents import Agent

agent = Agent(name="assistant", instructions="Answer from the docs", knowledge=["policy.md"])
agent.start("Summarise the policy")

# Clear the knowledge base between sessions
agent.knowledge.reset()
```

**2. Delete all scoped memories**

```python theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
# Delete everything for a given scope
agent.knowledge.delete_all(user_id="user-123")
```

**3. Inspect change history**

```python theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
# History is only available on Mem0-backed knowledge
changes = agent.knowledge.history(memory_id="mem-abc")
```

***

## How It Works

`Knowledge` erasure calls route to the underlying `memory` adapter. Unsupported operations fail loudly instead of raising `AttributeError`.

```mermaid theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
sequenceDiagram
    participant User
    participant Knowledge
    participant Adapter

    User->>Knowledge: reset() / delete_all() / history()
    Knowledge->>Adapter: Delegate operation
    alt Adapter supports it
        Adapter-->>Knowledge: Done
        Knowledge-->>User: reset returns True / Result
    else reset() unsupported
        Knowledge-->>User: WARNING no-op, returns False
    else delete_all() / history() unsupported
        Knowledge-->>User: NotImplementedError
    end
```

| Operation | Behaviour when unsupported |
| - | - |
| `reset()` | Logs a `WARNING`, no-ops, and returns `False` (returns `True` on a real reset) |
| `delete_all()` | Raises `NotImplementedError` |
| `history(memory_id)` | Raises `NotImplementedError` |

***

## Adapter Capabilities

Support differs per adapter — verify against `praisonaiagents/knowledge/adapters/` before relying on an operation.

| Operation | Chroma | SQLite | Mongo | Mem0 |
| - | - | - | - | - |
| `reset()` | ✅ | ✅ | ⚠️ warning + no-op | ✅ |
| `delete_all()` | ✅ | ✅ | ❌ `NotImplementedError` | ✅ |
| `history(id)` | ❌ `NotImplementedError` | ❌ `NotImplementedError` | ❌ `NotImplementedError` | ✅ |

> [!NOTE]
>
> **Since PraisonAI PR [#4020](https://github.com/MervinPraison/PraisonAI/pull/4020)**, `Knowledge.reset()` warns instead of raising `AttributeError`, and `delete_all()` / `history()` raise `NotImplementedError` on unsupported adapters instead of `AttributeError`. Wrap `history()` and `delete_all()` in try/except when your code should work across adapters.

> [!NOTE]
>
> **Since PraisonAI PR [#4991](https://github.com/MervinPraison/PraisonAI/pull/4991)**, `Knowledge.reset()` returns `bool` — `True` when the backend actually reset, `False` when the adapter has no `reset()` and the call was a silent no-op. On destructive paths, check the return value before telling a user their data was erased: a `False` means nothing was cleared. Existing callers that ignore the return value are unaffected.

***

## Common Patterns

Guard erasure calls so your code works across adapters:

```python theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
from praisonaiagents import Agent

agent = Agent(name="assistant", instructions="Answer from the docs", knowledge=["policy.md"])

# reset() never raises — it warns and no-ops on adapters without native reset
agent.knowledge.reset()

# delete_all() / history() may not be supported
try:
    agent.knowledge.delete_all(user_id="user-123")
except NotImplementedError:
    # Fall back to reset() on adapters without scoped delete
    agent.knowledge.reset()
```

Report to users honestly on a destructive path — check the return value before claiming success:

```python theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
from praisonaiagents import Agent

agent = Agent(name="assistant", knowledge=["policy.md"])

# Never claim success on a destructive path without checking
if agent.knowledge.reset():
    print("Knowledge cleared")
else:
    backend = type(agent.knowledge.memory).__name__
    print(f"Knowledge was NOT cleared — backend {backend} has no reset()")
```

***

## Best Practices

> [accordion] Reset between sessions
>
> Call `agent.knowledge.reset()` at the end of a session to clear context for privacy-sensitive workflows. `reset()` returns `True` when the backend actually reset, and `False` when the adapter had no `reset` — it warns and no-ops instead. On destructive paths **check the return value before telling a user their data was erased**; a `False` means nothing was cleared.

> [accordion] Wrap delete\_all() and history()
>
> Both raise `NotImplementedError` on adapters that don't support them. Wrap them in try/except so multi-adapter code degrades gracefully.

> [accordion] Use Mem0 for history
>
> Only Mem0-backed knowledge implements `history(memory_id)`. Choose Mem0 when you need an audit trail of memory changes.

> [accordion] Check logs after upgrade
>
> `reset()` returns `False` and logs a warning when the adapter can't reset. Prefer the return value over log-scraping — it's a reliable signal that the tier was actually cleared (`True`) or silently skipped (`False`).

***

## Related

> [card] [Knowledge Overview](https://praison.ai/docs/knowledge/overview.md)
>
> Load files and documents into an agent's knowledge base.

> [card] [Knowledge Storage](https://praison.ai/docs/knowledge/storage.md)
>
> Configure the storage backend for knowledge.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.