Skip to content
Merged

Dev #157

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .cursorignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
venv/
venv/
explorer/node_modules/
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ This allows you to develop and test your agent memory system without setting up
Explore the comprehensive documentation to understand the system components and APIs:

- [Memory API](docs/memory_api.md) - Complete API reference for working with the TASM system
- [Agent Memory](docs/agent_memory.md) - Core MemoryAgent implementation and usage
- [Agent Memory](docs/agent_memory.md) - Core MemorySpace implementation and usage
- [Memory System](docs/memory_system.md) - Overview of the tiered memory architecture
- [Memory Configuration](docs/memory_config.md) - Configuration options for all components
- [Memory Tiers](docs/memory_tiers.md) - Details on the three memory tiers and their characteristics
Expand Down
36 changes: 18 additions & 18 deletions archive/01_basic_memory_operations.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,13 +143,13 @@ def validate_memory_statistics(logger, stats, agent_id, memory_system):
all_validations_passed = False

# 3. Validate memory type distribution
memory_agent = memory_system.get_memory_agent(agent_id)
memory_space = memory_system.get_memory_space(agent_id)

# Collect all memories across tiers
all_memories = []
all_memories.extend(memory_agent.stm_store.get_all(agent_id))
all_memories.extend(memory_agent.im_store.get_all(agent_id))
all_memories.extend(memory_agent.ltm_store.get_all(agent_id))
all_memories.extend(memory_space.stm_store.get_all(agent_id))
all_memories.extend(memory_space.im_store.get_all(agent_id))
all_memories.extend(memory_space.ltm_store.get_all(agent_id))

# Count by memory type
memory_types = {"state": 0, "action": 0, "interaction": 0}
Expand Down Expand Up @@ -221,8 +221,8 @@ def validate_memory_statistics(logger, stats, agent_id, memory_system):

# If still missing, check by step_number
if step in missing_steps:
memory_agent = memory_system.get_memory_agent(agent_id)
for source in [memory_agent.stm_store, memory_agent.im_store]:
memory_space = memory_system.get_memory_space(agent_id)
for source in [memory_space.stm_store, memory_space.im_store]:
memories = source.get_all(agent_id)
for memory in memories:
step_number = memory.get("step_number")
Expand All @@ -234,7 +234,7 @@ def validate_memory_statistics(logger, stats, agent_id, memory_system):

# Also check LTM if still missing
if step in missing_steps:
memories = memory_agent.ltm_store.get_all(agent_id)
memories = memory_space.ltm_store.get_all(agent_id)
for memory in memories:
step_number = memory.get("step_number")
if step_number == step:
Expand Down Expand Up @@ -378,11 +378,11 @@ def run_demo():

# Display example content from each memory tier
log_print(logger, "\n== EXAMPLE MEMORY CONTENT FROM EACH TIER ==")
memory_agent = memory_system.get_memory_agent(agent_id)
memory_space = memory_system.get_memory_space(agent_id)

# STM example content
log_print(logger, "\n----- SHORT-TERM MEMORY (STM) EXAMPLES -----")
stm_memories = memory_agent.stm_store.get_all(agent_id)
stm_memories = memory_space.stm_store.get_all(agent_id)

if stm_memories:
for i, memory in enumerate(stm_memories[:3]): # Show up to 3 examples
Expand Down Expand Up @@ -411,7 +411,7 @@ def run_demo():

# IM example content
log_print(logger, "\n----- INTERMEDIATE MEMORY (IM) EXAMPLES -----")
im_memories = memory_agent.im_store.get_all(agent_id)
im_memories = memory_space.im_store.get_all(agent_id)

if im_memories:
for i, memory in enumerate(im_memories[:3]): # Show up to 3 examples
Expand All @@ -432,7 +432,7 @@ def run_demo():

# LTM example content
log_print(logger, "\n----- LONG-TERM MEMORY (LTM) EXAMPLES -----")
ltm_memories = memory_agent.ltm_store.get_all(agent_id)
ltm_memories = memory_space.ltm_store.get_all(agent_id)

if ltm_memories:
for i, memory in enumerate(ltm_memories[:3]): # Show up to 3 examples
Expand Down Expand Up @@ -483,7 +483,7 @@ def run_demo():
# 3. Check high-priority memories in different tiers
# We expect most high-priority memories to be preserved in higher tiers (IM/LTM)
high_priority_steps = [5, 10, 15, 20, 21, 25, 30]
memory_agent = memory_system.get_memory_agent(agent_id)
memory_space = memory_system.get_memory_space(agent_id)

# Query for high-priority memories across all tiers
milestone_memories = []
Expand All @@ -497,9 +497,9 @@ def run_demo():
# First try to find directly by step_number across all tiers
found_by_step = False
for store_memories in [
memory_agent.stm_store.get_all(agent_id),
memory_agent.im_store.get_all(agent_id),
memory_agent.ltm_store.get_all(agent_id),
memory_space.stm_store.get_all(agent_id),
memory_space.im_store.get_all(agent_id),
memory_space.ltm_store.get_all(agent_id),
]:
for memory in store_memories:
mem_step = memory.get("step_number")
Expand Down Expand Up @@ -567,9 +567,9 @@ def run_demo():
# For each missing step, try to verify if any memory actually exists
for missing_step in list(missing_steps):
# Directly check if we can find any memories with this timestamp across all three tiers
stm_memories = memory_agent.stm_store.get_all(agent_id)
im_memories = memory_agent.im_store.get_all(agent_id)
ltm_memories = memory_agent.ltm_store.get_all(agent_id)
stm_memories = memory_space.stm_store.get_all(agent_id)
im_memories = memory_space.im_store.get_all(agent_id)
ltm_memories = memory_space.ltm_store.get_all(agent_id)
log_print(
logger, f"Searching for step {missing_step} manually in all stores..."
)
Expand Down
8 changes: 4 additions & 4 deletions archive/02_memory_retrieval.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,13 +68,13 @@ def validate_memory_statistics(logger, stats, agent_id, memory_system):
all_validations_passed = False

# 2. Validate memory type distribution
memory_agent = memory_system.get_memory_agent(agent_id)
memory_space = memory_system.get_memory_space(agent_id)

# Collect all memories across tiers
all_memories = []
all_memories.extend(memory_agent.stm_store.get_all(agent_id))
all_memories.extend(memory_agent.im_store.get_all(agent_id))
all_memories.extend(memory_agent.ltm_store.get_all(agent_id))
all_memories.extend(memory_space.stm_store.get_all(agent_id))
all_memories.extend(memory_space.im_store.get_all(agent_id))
all_memories.extend(memory_space.ltm_store.get_all(agent_id))

# Count by memory type
memory_types = {"state": 0, "action": 0, "interaction": 0}
Expand Down
6 changes: 3 additions & 3 deletions archive/04_memory_hooks_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def significant_event_hook(
Returns:
True if processing was successful
"""
# Handle when agent_id is a MemoryAgent object
# Handle when agent_id is a MemorySpace object
agent_id_str = getattr(agent_id, "agent_id", agent_id)
print(f"Significant event hook triggered for agent {agent_id_str}")
print(f" Event type: {event_data.get('type', 'unknown')}")
Expand Down Expand Up @@ -104,7 +104,7 @@ def state_change_hook(
Returns:
True if processing was successful
"""
# Handle when agent_id is a MemoryAgent object
# Handle when agent_id is a MemorySpace object
agent_id_str = getattr(agent_id, "agent_id", agent_id)
print(f"State change hook triggered for agent {agent_id_str}")

Expand Down Expand Up @@ -194,7 +194,7 @@ def interaction_hook(
Returns:
True if processing was successful
"""
# Handle when agent_id is a MemoryAgent object
# Handle when agent_id is a MemorySpace object
agent_id_str = getattr(agent_id, "agent_id", agent_id)
print(f"Interaction hook triggered for agent {agent_id_str}")

Expand Down
24 changes: 12 additions & 12 deletions archive/06_search_capabilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ def run_demo():

# Clear existing LTM store to prevent duplicate memories
log_print(logger, "Clearing existing memories to avoid duplicates...")
memory_agent = memory_system.get_memory_agent(agent_id)
memory_agent.ltm_store.clear()
memory_space = memory_system.get_memory_space(agent_id)
memory_space.ltm_store.clear()

# Initialize validation tracking
validation_results = {
Expand Down Expand Up @@ -297,7 +297,7 @@ def validate_results(actual_results, expected_content_snippets, test_name):

# Explicitly add older memories directly to LTM for demonstration purposes
log_print(logger, "Adding demonstration memories directly to LTM...")
memory_agent = memory_system.get_memory_agent(agent_id)
memory_space = memory_system.get_memory_space(agent_id)

# Create older memories specifically for LTM
ltm_memories = [
Expand Down Expand Up @@ -389,7 +389,7 @@ def validate_results(actual_results, expected_content_snippets, test_name):
logger,
f"Adding memory directly to LTM: {memory['content']['content'][:50]}...",
)
memory_agent.ltm_store.store(memory)
memory_space.ltm_store.store(memory)

# Generate and store embedding for the memory
try:
Expand All @@ -401,7 +401,7 @@ def validate_results(actual_results, expected_content_snippets, test_name):
logger,
f"Generating embedding for memory: {text_content[:50]}...",
)
memory_agent.ltm_store.generate_and_store_embedding(
memory_space.ltm_store.generate_and_store_embedding(
memory_id=memory.get("memory_id"),
text=text_content,
agent_id=agent_id,
Expand All @@ -412,7 +412,7 @@ def validate_results(actual_results, expected_content_snippets, test_name):

# Initialize the search model with the memory system's configuration
log_print(logger, "\nInitializing search model...")
memory_agent = memory_system.get_memory_agent(agent_id)
memory_space = memory_system.get_memory_space(agent_id)

# Initialize search model
search_model = SearchModel(memory_system.config)
Expand All @@ -424,13 +424,13 @@ def validate_results(actual_results, expected_content_snippets, test_name):

# Temporal search strategy
temporal_strategy = TemporalSearchStrategy(
memory_agent.stm_store, memory_agent.im_store, memory_agent.ltm_store
memory_space.stm_store, memory_space.im_store, memory_space.ltm_store
)
search_model.register_strategy(temporal_strategy, make_default=True)

# Attribute search strategy
attribute_strategy = AttributeSearchStrategy(
memory_agent.stm_store, memory_agent.im_store, memory_agent.ltm_store
memory_space.stm_store, memory_space.im_store, memory_space.ltm_store
)
search_model.register_strategy(attribute_strategy)

Expand Down Expand Up @@ -459,12 +459,12 @@ def validate_results(actual_results, expected_content_snippets, test_name):

log_print(logger, "Searching for memories from the last 48 hours...")
# Use a direct approach with get_by_timerange to avoid the datetime conversion issue
memory_agent = memory_system.get_memory_agent(agent_id)
memory_space = memory_system.get_memory_space(agent_id)

# Get memories from each store
ltm_memories = memory_agent.ltm_store.get_by_timerange(two_days_ago, now, limit=10)
stm_memories = memory_agent.stm_store.get_all(agent_id)
im_memories = memory_agent.im_store.get_all(agent_id)
ltm_memories = memory_space.ltm_store.get_by_timerange(two_days_ago, now, limit=10)
stm_memories = memory_space.stm_store.get_all(agent_id)
im_memories = memory_space.im_store.get_all(agent_id)

# Filter STM and IM memories by time
filtered_stm = []
Expand Down
Loading
Loading