Memory infra for AI agents

Your agent forgets users between sessions. That's the bug.

MemexAI gives your agent a persistent memory layer backed by Postgres. Memories are human-readable Markdown files with revision history, access logs, and scoped permissions. You can inspect every fact, fix mistakes, and trace what the agent remembered and why.

Read Quickstart

Paste the prompt into Cursor, Claude, or Antigravity to automate setup.

user/profile.mdRev 1 · 0s ago
The problem

Where agent memory breaks in production.

Session 2 starts from scratch.

Your agent wrote what it learned last time. But nothing loaded that context into the new session. The model isn't broken — the memory injection layer is missing. Users re-explain themselves. The product feels stateless because it is.

session_start({ userId: "u_4821" })
context_files: [] // user/profile.md exists, never injected

Similarity retrieval serves the past, not the present.

Vector search returns what's similar, not what's current. A detailed old entry outranks a brief recent update. You can't fix one embedding — you'd have to re-extract the full conversation. The wrong fact keeps winning.

[0.91] "prefers 2BHK" — written 4 months ago[0.87] "now open to 3BHK" — written last week→ stale entry ranked first

Rules, facts, and history share one unstructured blob.

Escalation policy, user preferences, and last week's conversation all arrive as one context string. The model can't distinguish what always applies from what happened once. Priority is undefined.

context: "no cold calls | budget 80L |
viewed ParkRegalia last week..."
// rules mixed with history, equal weight

The solution

Memory as Markdown files in your Postgres

MemexAI stores what your agent knows about each user as structured Markdown files — not embeddings as the source of truth. Files live in your own Postgres database. Optional pgvector ranking can improve recall, while the memory record stays readable and editable.

Memory Files
user/
shared/
user/profile.md Private
name: Alex Chen
location: London
prefers: dark mode, concise replies
timezone: GMT
last_topic: apartment search in Shoreditch
Private · Writable · 3 revisions
user/**Private per tenant

Each user gets their own memory directory. Agents read and write freely. Other users can't see it.

shared/**Global read-only

Project-wide policies, style guides, and workflows. Agents read but can't write by default.


Global Knowledge

Give all your agents a shared brain

The shared/ namespace holds global policies, product schemas, and behavioral rules. Update a schema or rule once, and it instantly propagates to every agent session. No code deployments required.

Behavioral Rules

Store shared/playbook.md to define how agents should handle specific situations (e.g., support escalations). The agent reads it before every session.

Memory Schemas

Define what a "good" user profile looks like. If you add a new required field to the schema, agents will automatically start asking users for it.

Auto-Injection

shared/index.mdis automatically injected into every prompt block. It acts as a routing catalog for your agent's collective knowledge.

Collective Memory

Optionally configure shared/ as read-write. Trusted agents can update project canon, backed by full audit trails and the ability to revert any change.


Maintenance

Background Dreaming keeps memory clean

Memory files can get messy over time with duplicate facts or scattered notes. MemexAI's Dreaming is a background optimization loop that runs when a user session goes quiet.

Compaction & Deduplication

Merges repeated preferences, removes outdated or corrected facts, and consolidates fragmented notes into a stable record without blocking the main user request.

Zero Audit Noise

Dream runs that find nothing to change complete silently. When they do make updates, they create normal revisions authored by the dream-agent.


Debuggability

When the AI gets a fact wrong, open the file and fix it.

Edit the Markdown line, and the next prompt block updates instantly. Hybrid deployments refresh optional pgvector ranking on writes. Revisions track every write. Access logs track every read. You can trace exactly which tool call wrote the wrong fact.

user/profile.mdRev 4 (current)
name: Alex Chen location: New York moved_from: null prefers: dark mode, concise replies
Access Log
14:22:01READuser/profile.mdtool_call_id: tc_a83f
14:22:03WRITEuser/profile.mdreason: "user corrected location"

Get started

Add memory to your agent in 4 lines

Start with Docker. Connect with the TypeScript SDK or MCP. Or paste a setup prompt into your coding agent and let it wire everything automatically.

# Start Postgres + MemexAI service
docker compose up -d

# In your agent code:
const memex = MemexAI({
url: 'http://localhost:8080',
apiKey: 'dev-agent-key'
})
const memory = memex.memory('user-123')
const tools = memory.createMemorySubagentToolset()
memory subagentRecommended default

Give the model memory_remember and memory_context; MemexAI decides what is durable, retrieves relevant context, and handles file bookkeeping.

raw file toolsExact file control

Use file-level tools when your app or agent owns the memory layout and needs exact path control over durable files.

Or copy this into your coding agent:
Setup MemexAI by following https://memexai.space/setup.md

Why not just build it?

Every team builds half of this. The other half shows up at scale.

These aren't design decisions — they're failure modes that appear as usage grows. Each one is a weekend of work that pulls engineers away from the product.

Failure mode
DIY outcome
MemexAI
Agent reads another user's memory
Manual validation or silent data leak
Path layer blocks physical paths
Bad write corrupts context, no rollback
Overwritten and gone
Full snapshot on every write
“What does the agent currently know?”
Open the DB or hope for logs
Admin UI + access logs + revision history
Loading too much memory degrades output
Full file dumped in prompt
Context budget enforced at assembly
Share policy globally, keep user data private
Two stores or manual conditional logic
shared/ + user/ isolation, path-enforced
Write-on-every-call grows storage unbounded
Manual cleanup scripts or skip it
Dreaming compacts and deduplicates

No moat claims. These are failure modes that appear as usage scales, and the mechanisms that prevent them.


Compare

How MemexAI compares

MemexAI
Mem0
Zep
DIY
Storage
Your Postgres
Their cloud
Their cloud
Varies
Memory format
Markdown files
JSON blobs
Knowledge graph
Custom
Human-readable
✓ Open the file
✗ API-only
✗ API-only
Depends
Fix a wrong fact
Edit one line
Re-extract
Re-process
Write migration
Revision history
✓ Built-in
Build it yourself
Self-hosted
✓ Docker
Paid cloud
Paid cloud
See full comparison
Build the record

Give your agent memory your team can trust.

Start with Docker, MCP, or the TypeScript SDK. Store memory, inject context, verify the next answer changes.