praval.memory.memory_manager๏ƒ

MemoryManager - Unified interface for all Praval agent memory systems

This coordinates: - Short-term working memory - Long-term vector memory - Episodic conversation memory - Semantic knowledge memory

Classes

MemoryManager(agent_id[,ย backend,ย ...])

Unified memory management system for Praval agents

class praval.memory.memory_manager.MemoryManager(agent_id, backend='auto', qdrant_url='http://localhost:6333', storage_path=None, collection_name='praval_memories', short_term_max_entries=1000, short_term_retention_hours=24, knowledge_base_path=None)[source]๏ƒ

Bases: object

Unified memory management system for Praval agents

Provides a single interface to: - Store and retrieve memories across all systems - Coordinate between short-term and long-term storage - Manage different types of memory (episodic, semantic, etc.) - Optimize memory access patterns

Parameters:
  • agent_id (str)

  • backend (str)

  • qdrant_url (str)

  • storage_path (str | None)

  • collection_name (str)

  • short_term_max_entries (int)

  • short_term_retention_hours (int)

  • knowledge_base_path (str | None)

__init__(agent_id, backend='auto', qdrant_url='http://localhost:6333', storage_path=None, collection_name='praval_memories', short_term_max_entries=1000, short_term_retention_hours=24, knowledge_base_path=None)[source]๏ƒ

Initialize the unified memory manager

Parameters:
  • agent_id (str) โ€“ ID of the agent using this memory

  • backend (str) โ€“ Memory backend (โ€œautoโ€, โ€œchromadbโ€, โ€œqdrantโ€, โ€œmemoryโ€)

  • qdrant_url (str) โ€“ URL for Qdrant vector database

  • storage_path (Optional[str]) โ€“ Path for persistent storage

  • collection_name (str) โ€“ Collection name for vector storage

  • short_term_max_entries (int) โ€“ Max entries in short-term memory

  • short_term_retention_hours (int) โ€“ Short-term memory retention time

  • knowledge_base_path (Optional[str]) โ€“ Path to knowledge base files to auto-index

store_memory(agent_id, content, memory_type=MemoryType.SHORT_TERM, metadata=None, importance=0.5, store_long_term=None)[source]๏ƒ

Store a memory entry

Parameters:
  • agent_id (str) โ€“ The agent storing the memory

  • content (str) โ€“ The memory content

  • memory_type (MemoryType) โ€“ Type of memory

  • metadata (Optional[Dict[str, Any]]) โ€“ Additional metadata

  • importance (float) โ€“ Importance score (0.0 to 1.0)

  • store_long_term (bool) โ€“ Whether to store in long-term memory (auto-decided if None)

Return type:

str

Returns:

Memory ID

retrieve_memory(memory_id)[source]๏ƒ

Retrieve a specific memory by ID

Parameters:

memory_id (str) โ€“ The memory ID

Return type:

Optional[MemoryEntry]

Returns:

The memory entry if found

search_memories(query)[source]๏ƒ

Search memories across all systems

Parameters:

query (MemoryQuery) โ€“ The search query

Return type:

MemorySearchResult

Returns:

Combined search results

get_conversation_context(agent_id, turns=10)[source]๏ƒ

Get recent conversation context for an agent

Parameters:
  • agent_id (str) โ€“ The agent ID

  • turns (int) โ€“ Number of conversation turns

Return type:

List[MemoryEntry]

Returns:

List of conversation memories

store_conversation_turn(agent_id, user_message, agent_response, context=None)[source]๏ƒ

Store a conversation turn

Parameters:
  • agent_id (str) โ€“ The agent ID

  • user_message (str) โ€“ Userโ€™s message

  • agent_response (str) โ€“ Agentโ€™s response

  • context (Optional[Dict[str, Any]]) โ€“ Additional context

Return type:

str

Returns:

Memory ID

store_knowledge(agent_id, knowledge, domain='general', confidence=1.0, knowledge_type='fact')[source]๏ƒ

Store knowledge or facts

Parameters:
  • agent_id (str) โ€“ The agent ID

  • knowledge (str) โ€“ The knowledge content

  • domain (str) โ€“ Domain of knowledge

  • confidence (float) โ€“ Confidence in the knowledge

  • knowledge_type (str) โ€“ Type of knowledge (fact, concept, rule)

Return type:

str

Returns:

Memory ID

get_domain_knowledge(agent_id, domain, limit=20)[source]๏ƒ

Get knowledge in a specific domain

Parameters:
  • agent_id (str) โ€“ The agent ID

  • domain (str) โ€“ The domain

  • limit (int) โ€“ Maximum results

Return type:

List[MemoryEntry]

Returns:

List of knowledge entries

clear_agent_memories(agent_id, memory_types=None)[source]๏ƒ

Clear memories for a specific agent

Parameters:
  • agent_id (str) โ€“ The agent ID

  • memory_types (Optional[List[MemoryType]]) โ€“ Types of memory to clear (all if None)

get_memory_stats()[source]๏ƒ

Get comprehensive memory statistics

Return type:

Dict[str, Any]

health_check()[source]๏ƒ

Check health of all memory systems

Return type:

Dict[str, bool]

recall_by_id(memory_id)[source]๏ƒ

Recall a specific memory by ID (for spore references)

Return type:

List[MemoryEntry]

Parameters:

memory_id (str)

get_knowledge_references(content, importance_threshold=0.7)[source]๏ƒ

Get knowledge references for lightweight spores

Return type:

List[str]

Parameters:
  • content (str)

  • importance_threshold (float)

shutdown()[source]๏ƒ

Shutdown all memory systems