praval.memory.episodic_memory

Episodic memory for Praval agents - conversation history and experiences

This manages: - Conversation turns and dialogue history - Agent interaction sequences - Temporal event chains - Experience-based learning patterns

Classes

EpisodicMemory(long_term_memory, ...[, ...])

Manages episodic memories - experiences and conversations over time

class praval.memory.episodic_memory.EpisodicMemory(long_term_memory, short_term_memory, conversation_window=50, episode_lifetime_days=30)[source]

Bases: object

Manages episodic memories - experiences and conversations over time

Features: - Conversation turn tracking - Experience sequencing - Temporal relationship modeling - Context window management

Parameters:
__init__(long_term_memory, short_term_memory, conversation_window=50, episode_lifetime_days=30)[source]

Initialize episodic memory

Parameters:
  • long_term_memory (LongTermMemory) – Long-term memory backend

  • short_term_memory (ShortTermMemory) – Short-term memory backend

  • conversation_window (int) – Number of conversation turns to keep in context

  • episode_lifetime_days (int) – How long to keep episodes before archiving

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

Store a conversation turn as an episodic memory

Parameters:
  • agent_id (str) – The agent involved in the conversation

  • user_message (str) – The user’s message

  • agent_response (str) – The agent’s response

  • context (Optional[Dict[str, Any]]) – Additional context information

Return type:

str

Returns:

The memory ID

store_experience(agent_id, experience_type, experience_data, outcome, success=True)[source]

Store an experience or learning episode

Parameters:
  • agent_id (str) – The agent that had the experience

  • experience_type (str) – Type of experience (e.g., “task_completion”,

  • "problem_solving")

  • experience_data (Dict[str, Any]) – Data about the experience

  • outcome (str) – The result or outcome

  • success (bool) – Whether the experience was successful

Return type:

str

Returns:

The memory ID

get_conversation_context(agent_id, turns=None)[source]

Get recent conversation context for an agent

Parameters:
  • agent_id (str) – The agent to get context for

  • turns (Optional[int]) – Number of conversation turns (default: conversation_window)

Return type:

List[MemoryEntry]

Returns:

List of recent conversation memories

get_similar_experiences(agent_id, experience_description, limit=5)[source]

Find similar past experiences for an agent

Parameters:
  • agent_id (str) – The agent to search experiences for

  • experience_description (str) – Description of the current experience

  • limit (int) – Maximum number of similar experiences to return

Return type:

MemorySearchResult

Returns:

Search results with similar experiences

get_episode_timeline(agent_id, start_time, end_time)[source]

Get episodic memories within a time range

Parameters:
  • agent_id (str) – The agent to get timeline for

  • start_time (datetime) – Start of the time range

  • end_time (datetime) – End of the time range

Return type:

List[MemoryEntry]

Returns:

List of episodic memories in chronological order

archive_old_episodes(cutoff_days=None)[source]

Archive old episodic memories (implementation depends on requirements)

Parameters:

cutoff_days (Optional[int]) – Days after which to archive (default: episode_lifetime_days)

get_stats()[source]

Get episodic memory statistics

Return type:

Dict[str, Any]