Where should agent-written code run? Not in the Postgres backend. A per-call helper process, kernel-verified before it sees any input, and a WebAssembly guest for model-written Python.
Plexus wires five of my projects through a single Postgres: an agent runtime, evidence-backed memory, time-travel retrieval and a self-tuning harness. It handles refund tickets under a changing policy, rolls back a bad refund inside the transaction, and tunes itself from its own runs. It also failed its own test for most of the first day, and I kept the log.
Since July, pg_synapse picked up an app builder, agents that run as the calling role, secrets encrypted at rest, runs that outlive the session, and a tuner that improves an agent from its own history. Here’s what changed, and the security bug I had to fix on the way.
A defense of in-database AI agents: data gravity, security, transactional isolation, backups, replication, and why pg-synapse lives inside Postgres on purpose.
A working tutorial: install pg-synapse, write a tool, register an LLM profile, create an agent as a row, run it from SQL, attach a reactive trigger. All copy-pasteable.
pg-synapse is a Postgres-native agent loop runtime in Rust. Invoke LLM agents from SQL, with tools that read and write your database under the caller’s grants.
We added semantic search to agent memory, then benchmarked it against plain document RAG on the same questions. The boring baseline won by 6x. Here is why that is the point.
“Add memory to the agent” sounds like one feature. It is six different jobs that need three different mechanisms. Here is the map, with a concrete example for each.
The practical follow-up to the goldfish-memory post. Bring a Postgres database with pgvector and an agent that talks to users; an hour later you’ve got two-tier memory bolted on. Staging, realtime and consolidate cells, three scheduling options, three reader patterns, and an LLM fact extractor — Python and Rust both.
Agent memory has two completely different jobs — fast context for the next reply, and curated truth three weeks later — and most people try to do both with one tool. Here’s the two-tier pattern I built chunkshop’s memory layer around, the late-event bug that silently eats conversations, and why ‘just use pgvector’ isn’t the whole answer.