DS DevShelfHub Projects · AI tools
Tutorials / CrewAI / Reference / Methods / reset_memories()
Method Crew, CLI

reset_memories(): Reference Guide

By DevShelfHub

Clears stored memory — short-term, long-term, entity, knowledge, or all.

See the CrewAI methods catalog, CrewAI introduction, kickoff() reference, and core concepts for surrounding context.

What is reset_memories()?

reset_memories exists because CrewAI persists several independent memory surfaces: short-term buffers that carry context within a session, long-term stores that survive kickoffs, entity graphs built from structured extraction, knowledge corpora ingested from files, and cached kickoff outputs referenced by replay(). The Python method and the `crewai reset-memories` CLI share the same flag vocabulary so ops playbooks and pytest fixtures stay aligned — pick the narrowest flag that fixes your leak instead of defaulting to --all.

Typical workflows: wipe -k between integration tests so TaskOutput caches do not cross-pollinate cases; use --knowledge after you replace source documents so embeddings are rebuilt on the next ingest; use --entity when your schema for remembered facts changed; reserve --all for destructive local resets or after migrations that touch every store. In production, prefer time-bounded memory policies or explicit scopes rather than blanket wipes that surprise concurrent users.

Combine with db_storage_path() when scripting cleanup so paths honor CREWAI_STORAGE_DIR overrides.

Use Cases

  • Test isolation
  • Reset after migration

Key Features

  • Multiple scopes via flags
  • Available as CLI or Python call

When NOT to Use

In production unless intentionally rotating memory state.

Notes

Scope flags are not always commutative

Ordering and inclusion differ between short, long, entity, and knowledge stores. Read the CLI help for your installed crewai version when scripting — flag names evolve across releases.

Replay safety

Clearing kickoff outputs invalidates task_id caches replay() depends on. After -k, expect replay() to miss unless you rerun a full kickoff.

Concurrency

If multiple workers share one on-disk store, a reset from one process can surprise another. Isolate storage per tenant or serialize maintenance windows.

Backups before --all

Snapshot CREWAI_STORAGE_DIR before destructive resets in shared environments — vector DB files and SQLite corpora are not always trivially rebuilt.

Code Examples

CLI

python
crewai reset-memories --all
crewai reset-memories -k

Pytest autouse fixture for knowledge tests

python
import pytest
from crewai import Crew

@pytest.fixture(autouse=True)
def _clean_memories():
    Crew().reset_memories(knowledge=True, agent_knowledge=True)
    yield

Narrow wipe after a bad ingest

python
from crewai import Crew

def rebuild_knowledge_index(crew: Crew) -> None:
    crew.reset_memories(knowledge=True)
    crew.kickoff(inputs={'reindex': True})

When to Use

Before tests, after schema changes, or when memory is corrupted.

Common Mistakes

❌ Running --all in production

✅ Use the narrowest scope you need.

Related: @tool decorator reference, Agent class reference, and the first Crew tutorial.

reset_memories() FAQ

What is reset_memories() in CrewAI?

Clears stored memory — short-term, long-term, entity, knowledge, or all. reset_memories exists because CrewAI persists several independent memory surfaces: short-term buffers that carry context within a session, long-term stores that survive kickoffs, entity graphs built from structured extraction, knowledge corpora ingested from files, and cached kickoff outputs referenced by replay(). The Python method and the `crewai reset-memories` CLI share the same flag vocabulary so ops playbooks and pytest fixtures stay aligned — pick the narrowest flag th…

Which CrewAI types expose the method reset_memories()?

DevShelfHub documents reset_memories() on Crew, CLI. The reference maps it to Python module crewai.Crew — pin your installed crewai version and match imports to the snippet on this page.

When should I use reset_memories()?

Before tests, after schema changes, or when memory is corrupted.

When should I avoid reset_memories()?

In production unless intentionally rotating memory state.

How do I call reset_memories() from Python?

crew.reset_memories()

Where can I explore more CrewAI API reference pages?

Open the CrewAI API reference index on DevShelfHub to search classes, methods, and decorators, each with runnable examples, parameters, common mistakes, and cross-links.