-
-
Notifications
You must be signed in to change notification settings - Fork 82
Description
Overview
Currently, updating memory metadata requires deleting and re-creating the entire memory entry. This is inefficient for operations that only need to modify tags or other metadata attributes. A dedicated API for updating just the metadata of existing memories would improve system efficiency and reduce the risk of data loss.
Problem
When users need to enhance or modify the metadata (especially tags) of an existing memory, they currently have to:
- Retrieve the original memory
- Delete the entire memory entry
- Create a new memory with the same content but updated metadata
This approach has several drawbacks:
- It's resource-intensive (requires multiple API calls)
- Risks data corruption during the process
- Creates a new timestamp, losing the original creation time
- Generates a new memory ID/hash, breaking any existing references
- Consumes more storage temporarily during the replacement process
Proposed Solution
Implement a dedicated update_memory_metadata
function that allows modifying just the tags/metadata of an existing memory without recreating the entire entry.
Function Specification
async def update_memory_metadata(content_hash: str, metadata: dict) -> dict:
"""
Update the metadata of an existing memory without modifying its content or creating a new entry.
Args:
content_hash: The hash/ID of the memory to update
metadata: The new metadata to apply (can be partial update)
Returns:
dict: Status and information about the updated memory
Raises:
MemoryNotFoundError: If the specified memory doesn't exist
InvalidMetadataError: If the provided metadata is invalid
"""
Implementation Details
- Add a new MCP tool for updating memory metadata
- Modify the ChromaDB integration to support metadata-only updates
- Implement validation for metadata format
- Add support for partial metadata updates (only changing specified fields)
- Ensure timestamp preservation during updates
- Add proper error handling for missing memories
Benefits
- More efficient resource usage (processing and storage)
- Maintains original creation timestamp
- Preserves original memory ID/hash
- Reduces risk of data corruption during update operations
- Enables more sophisticated memory organization strategies
Use Cases
- Adding new tags to existing memories
- Removing tags from memories
- Updating memory type or other metadata attributes
- Programmatically organizing memories into categories
- Implementing memory linking systems (connecting related memories)
- Setting up memory time-to-live (TTL) attributes
Related Enhancement Ideas
This feature would enable more advanced memory organization features such as:
- Memory graph connections (linking related memories together)
- Hierarchical memory organization
- Smart tagging based on content analysis
- Automatic memory consolidation (related to the multi-layered time horizon concept)
Success Criteria
- API successfully updates metadata without recreating entries
- Original timestamps are preserved
- Documentation updated with usage examples
- Tests for various metadata update scenarios
- Performance metrics showing efficiency improvement over delete/recreate
Priority
Medium - This is a foundational improvement that will enable many other enhancements.