Show HN: MemState – Transactional, type-safe memory for AI agents (SQLite/Redis)

github.com

1 points by scream4ik 3 hours ago

I wanted to share MemState, an open-source library I've been building for strict agent state management.

It acts as a Git-like layer for Python agents: unlike standard vector memory, it enforces Pydantic schemas and supports transactional rollbacks (Time Travel) to prevent state corruption.

Key technical features:

* Strict Schemas: Uses Pydantic to validate memory on write. If an LLM tries to save a string into an int field, the transaction fails before corruption happens.

* Time Travel: Every change is an append-only transaction. You can call memory.rollback(1) to undo an agent's hallucination.

* Constraints: Enforce logic like Singleton facts (e.g., only one "User Profile" per session).

* No Vectors required: It uses SQLite's JSON1 extension for structured filtering, which is faster and deterministic for state lookups.

It includes a native checkpointer for LangGraph, so you can persist agent threads to SQLite with full history auditability.

It's open source (Apache 2.0). Would love to hear your feedback on the architecture!