Fix readonly database error in reset_memories (#3753) #3754
+222
−4
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fix readonly database error in reset_memories (#3753)
Summary
Fixes issue #3753 where calling
crew.reset_memories(command_type='all')fails with "attempt to write a readonly database" error when trying to reset agent knowledge.The fix adds error handling to gracefully ignore "readonly database" and "collection does not exist" errors during memory reset operations. These errors indicate the collection is already in a reset state (either inaccessible or already deleted), so they can be safely ignored. This approach follows the existing pattern in
RAGStorage.reset()which already handles these same errors.Changes made:
KnowledgeStorage.reset()to catch and ignore readonly database and collection not found errorsCrew.reset_knowledge()to handle cases where the error propagates from the Knowledge layerReview & Testing Checklist for Human
"attempt to write a readonly database" in str(e)) to identify specific errors. Confirm this is robust enough for production use, especially if ChromaDB/Qdrant error messages changeKnowledgeStorage.reset()andCrew.reset_knowledge(). Consider if both layers are necessary or if one would sufficeTest Plan
Notes
RAGStorage.reset()test_knowledge_storage_reset_readonly_databaseintest_error_handling.pyalready expected this behaviorSession Info: Requested by João (joao@crewai.com)
Devin Session: https://app.devin.ai/sessions/2b34f161b21e4823bcecb446eb4c5fa6