praval.memory.short_term_memory๏
Short-term working memory for Praval agents
This provides fast, in-memory storage for: - Current conversation context - Recent agent interactions - Active tasks and goals - Temporary state information
Classes
|
Fast, in-memory storage for short-term agent memory |
- class praval.memory.short_term_memory.ShortTermMemory(max_entries=1000, retention_hours=24, cleanup_interval=3600)[source]๏
Bases:
objectFast, in-memory storage for short-term agent memory
Features: - Thread-safe operations - Automatic cleanup of old memories - Context-aware retrieval - Working memory capacity limits
- __init__(max_entries=1000, retention_hours=24, cleanup_interval=3600)[source]๏
Initialize short-term memory
- store(memory)[source]๏
Store a memory entry
- Parameters:
memory (
MemoryEntry) โ The memory entry to store- Return type:
- Returns:
The ID of the stored memory
- retrieve(memory_id)[source]๏
Retrieve a specific memory by ID
- Parameters:
memory_id (
str) โ The ID of the memory to retrieve- Return type:
- Returns:
The memory entry if found, None otherwise
- search(query)[source]๏
Search memories using text similarity
- Parameters:
query (
MemoryQuery) โ The search query- Return type:
- Returns:
Search results with matching memories
- get_recent(agent_id=None, limit=10)[source]๏
Get recent memories
- Parameters:
- Return type:
- Returns:
List of recent memory entries
- get_context(agent_id, context_size=5)[source]๏
Get contextual memories for an agent
- Parameters:
- Return type:
- Returns:
List of contextual memory entries