Skip to content

feat: add on-device persistent memory module#1182

Open
zhaog100 wants to merge 1 commit intodeepseek-ai:mainfrom
zhaog100:feature/persistent-memory
Open

feat: add on-device persistent memory module#1182
zhaog100 wants to merge 1 commit intodeepseek-ai:mainfrom
zhaog100:feature/persistent-memory

Conversation

@zhaog100
Copy link
Copy Markdown

On-Device Persistent Memory with Cryptographic Identity Binding

Implements the feature request from #1121.

Features

  • Cryptographic Identity Management: PBKDF2-HMAC-SHA256 key derivation with UUIDv4 identity
  • AES-256 Encrypted Storage: Local storage of conversation history and user profile
  • Context Compression: Tiered memory management with configurable compression ratios
  • Privacy-First: Zero data exfiltration - all data stays on device

Modules

Class Purpose
IdentityManager Cryptographic identity generation and management
LocalEncryptedStore AES-256-GCM encrypted local storage
ContextCompressor Conversation history compression
PersistentMemoryManager High-level API for client applications

Usage Example

from persistent_memory import PersistentMemoryManager

# Initialize
manager = PersistentMemoryManager()

# Add conversation
manager.add_message("user", "My name is Alice and I live in Tokyo.")
manager.add_message("assistant", "Nice to meet you, Alice!")

# Update user profile
manager.update_key_fact("name", "Alice")
manager.update_key_fact("location", "Tokyo")

# Get system prompt with persistent context
system_prompt = manager.get_system_prompt()

# Export for GDPR compliance
export = manager.export_data()

# Delete all data (forget me)
manager.delete_all_data()

Security Architecture

  • Identity key: PBKDF2-HMAC-SHA256 (10000 iterations)
  • Storage encryption: AES-256-GCM
  • Key storage: Platform keychain (Android Keystore / iOS Keychain) recommended for production

Reference

Implements cryptographic identity binding and context compression
for persistent user memory across DeepSeek sessions.

Based on: deepseek-ai#1121
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant