You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
<strong>Demo:</strong> Without MemState → memory gets inconsistent ❌ | With MemState → atomic, type-safe, rollbackable agent state ✅
16
-
<br>
17
-
<em>All demo scripts are available in the <code>examples/</code> folder for reproducibility.</em>
18
-
</p>
13
+
## Why MemState exists
19
14
20
-
---
15
+
AI agents usually store memory in two places:
16
+
17
+
***SQL** (structured facts)
18
+
***Vector DB** (semantic search context)
19
+
20
+
These two **drift** easily:
21
+
22
+
### ❌ Example of real-world corruption
21
23
22
-
## The Problem: Agent State Corruption
24
+
```python
25
+
# Step 1: SQL write succeeds
26
+
db.update("user_city", "London")
27
+
28
+
# Step 2: Vector DB update fails (timeout)
29
+
vectors.upsert("User lives in London") # ❌ failed
23
30
24
-
In most frameworks, agent state is treated as a second-class citizen:
25
-
* Scattered JSON blobs.
26
-
* Ad-hoc RAG embeddings that drift from the source of truth.
27
-
* Inconsistent partial updates during failures.
28
-
* No rollback mechanisms.
31
+
# Final state:
32
+
SQL: London
33
+
Vectors: New York
34
+
→ Agent retrieves stale context and behaves unpredictably
35
+
```
29
36
30
-
This leads to **Data Drift**: The SQL database says one thing, the Vector DB says another. The agent becomes unpredictable and hallucinates because its memory is fractured.
37
+
Failures, crashes, retries, malformed payloads — all silently accumulate “ghost vectors” and inconsistent state.
31
38
32
-
**Agents need reliable state. Not a document dump.**
39
+
**Vector DBs don't have transactions.
40
+
JSON memory has no schema.
41
+
Agents drift over time.**
33
42
34
43
---
35
44
36
-
## MemState: A Consistency Layer
45
+
## What MemState does
37
46
38
-
MemState treats agent memory as a transactional system, offering database semantics for application logic:
47
+
MemState makes all memory operations **atomic**:
39
48
40
-
***⚛️ Atomicity** — SQL and Vector DB changes succeed or rollback together.
41
-
***🛡️ Isolation** — Intermediate steps in a workflow never leak to the main memory.
42
-
***⏪ Rollback** — Revert any number of committed steps instantly.
43
-
***🔒 Schema Safety** — Pydantic validation prevents data corruption at runtime.
49
+
```
50
+
SQL write + Vector upsert
51
+
→ succeed together or rollback together
52
+
```
53
+
54
+
Also provides:
44
55
45
-
It is the missing architecture between your Agent Logic and your Storage.
0 commit comments