Skip to main content

Working with Temporal Layers

Temporal layers are a key feature of EngramDB that allow you to track how memories evolve over time. This document explains how to work with temporal layers effectively.

What are Temporal Layers?

A temporal layer represents a version of a memory node at a specific point in time. Each layer contains:
  • A unique identifier
  • A timestamp when the layer was created
  • Optionally, the vector embeddings at that point in time
  • Optionally, the attributes at that point in time
  • A reason explaining why this layer was created
Temporal layers enable EngramDB to maintain a history of how memories change and evolve, which is crucial for agent systems that learn and update their knowledge over time.

Creating Temporal Layers

When you want to update a memory node but preserve its previous state, you should create a temporal layer before making changes.

Rust Example

Python Example

Accessing Temporal Layers

You can access the temporal layers of a memory node to examine its history.

Rust Example

Python Example

Use Cases for Temporal Layers

Knowledge Evolution

Temporal layers are ideal for tracking how an agent’s knowledge evolves over time. For example, an agent might initially have a low-confidence understanding of a concept, which becomes more refined as it learns more.

Belief Revision

Temporal layers can track how an agent’s beliefs change when new evidence contradicts previous assumptions.

Debugging and Auditing

Temporal layers provide an audit trail that can help debug agent behavior by showing how and why memories changed over time.

Best Practices

When to Create Temporal Layers

Create temporal layers when:
  1. Making significant changes to a memory’s content
  2. Updating beliefs based on new evidence
  3. Refining knowledge as more information becomes available
  4. Correcting errors in previous memories

What to Include in Temporal Layers

For each temporal layer, consider including:
  1. The previous embeddings if they’re changing
  2. The relevant attributes that are being modified
  3. A clear, descriptive reason for the change

Memory Efficiency

Temporal layers can increase memory usage if overused. Consider these strategies:
  1. Only store the attributes that are changing, not all attributes
  2. For minor updates, consider updating the memory without creating a temporal layer
  3. Implement a pruning strategy for very old temporal layers if memory becomes an issue

Querying with Temporal Awareness

When querying memories, consider their temporal aspects:

Conclusion

Temporal layers are a powerful feature of EngramDB that enable tracking the evolution of memories over time. By effectively using temporal layers, you can build agent systems that maintain a rich history of knowledge evolution, belief revision, and learning processes.