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.
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 sessionsgraph 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 warnQuick Start
- Reset the knowledge base
python 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() - Delete all scoped memories
python # Delete everything for a given scope agent.knowledge.delete_all(user_id="user-123") - Inspect change history
python # 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.
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 | ✅ |
Common Patterns
Guard erasure calls so your code works across adapters:
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:
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
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.
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.
Use Mem0 for history
Only Mem0-backed knowledge implements history(memory_id). Choose Mem0 when you need an audit trail of memory changes.
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).