The clear_memory.py script allows you to selectively or completely clear data from the ChromaDB memory persistence layer.
scripts/clear_memory.py
python scripts\clear_memory.py --statsOutput:
============================================================
MEMORY STATISTICS
============================================================
Leads: 54
Campaigns: 0
Interactions: 0
Pending Recommendations: 0
Storage Location: ./data/chroma
============================================================
python scripts\clear_memory.py --leads- Prompts for confirmation before deleting
- Removes all discovered prospects from memory
- Useful when you want to start fresh with prospect discovery
python scripts\clear_memory.py --campaigns- Removes all campaign execution history
- Keeps leads, interactions, and recommendations intact
python scripts\clear_memory.py --interactions- Removes all email interaction logs (sent, opened, clicked, replied)
- Useful for testing interaction tracking
python scripts\clear_memory.py --recommendations- Removes all AI-generated recommendations
- Useful for clearing old suggestions
python scripts\clear_memory.py --all- Shows summary of all data before deletion
- Prompts for confirmation
- Clears all collections at once
Example:
Current memory statistics:
- Leads: 54
- Campaigns: 3
- Interactions: 120
- Recommendations: 5
- Total items: 182
Are you sure you want to delete ALL data from memory? (yes/no): yes
[OK] Memory cleared successfully:
- Leads deleted: 54
- Campaigns deleted: 3
- Interactions deleted: 120
- Recommendations deleted: 5
python scripts\clear_memory.py --all --force⚠️ USE WITH CAUTION!- Skips all confirmation prompts
- Useful for automated scripts or testing
# Clear leads and campaigns together
python scripts\clear_memory.py --leads --campaigns
# Clear everything except recommendations
python scripts\clear_memory.py --leads --campaigns --interactions
# Show stats after clearing
python scripts\clear_memory.py --leads --statsAll delete operations require explicit confirmation:
- Type
yesoryto confirm - Type
noornto cancel - Any other input cancels the operation
Script detects empty collections and skips deletion:
No leads found in memory.
After deletion, shows:
- Number of items deleted from each collection
- Final memory statistics
# Clear only leads to re-run prospect search
python scripts\clear_memory.py --leads# Clear all test data
python scripts\clear_memory.py --all --force# Remove old campaign data, keep leads
python scripts\clear_memory.py --campaigns --interactions# Start fresh with recommendations
python scripts\clear_memory.py --recommendationsThe script uses these WorkflowMemory methods:
Removes all leads from memory, returns count deleted.
Removes all campaigns from memory, returns count deleted.
Removes all interactions from memory, returns count deleted.
Removes all recommendations from memory, returns count deleted.
Removes all data from all collections, returns counts for each.
Example:
from utils.memory import get_memory
memory = get_memory()
# Clear only leads
deleted_count = memory.clear_leads()
print(f"Deleted {deleted_count} leads")
# Clear all data
results = memory.clear_all_data()
print(f"Leads: {results['leads_deleted']}")
print(f"Campaigns: {results['campaigns_deleted']}")
print(f"Interactions: {results['interactions_deleted']}")
print(f"Recommendations: {results['recommendations_deleted']}")- Cleared data cannot be recovered
- Make backups if needed before clearing
- Consider exporting prospects before deletion:
# Export before clearing python scripts\view_prospects.py --csv --json python scripts\clear_memory.py --leads
- Default:
./data/chroma/ - Can be changed via
WorkflowMemory(persist_directory="path")
clear_*()methods: Delete specific data, keep collectionsreset_all()method: Completely reset ChromaDB client (use with extreme caution)
The script handles common errors:
- Empty collections (shows message, exits gracefully)
- Invalid confirmation input (treats as 'no')
- ChromaDB connection issues (shows error message)
0- Success1- Error occurred
view_memory.py- View memory statistics and contentsview_prospects.py- View and export prospectsdemo.py- Run workflow (generates memory data)
Remember: Always use --stats first to see what will be deleted!