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
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:- Making significant changes to a memory’s content
- Updating beliefs based on new evidence
- Refining knowledge as more information becomes available
- Correcting errors in previous memories
What to Include in Temporal Layers
For each temporal layer, consider including:- The previous embeddings if they’re changing
- The relevant attributes that are being modified
- A clear, descriptive reason for the change
Memory Efficiency
Temporal layers can increase memory usage if overused. Consider these strategies:- Only store the attributes that are changing, not all attributes
- For minor updates, consider updating the memory without creating a temporal layer
- Implement a pruning strategy for very old temporal layers if memory becomes an issue

