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.
Long-running agents are usually given a memory system that stores facts and retrieves them by similarity, borrowed straight from RAG. We argue that’s the wrong default: cheaply re-derivable facts are net-negative to cache, while the expensive, non-re-derivable thing an agent accumulates, process, is exactly what the field under-builds. We present the Agentic Context and Protocol Ledger, validate it with two policy simulations and a four-model adversarial review, and report four empirical results on staleness, dependency-checked reuse, and the mechanisms that make imperfect dependency declaration safe.
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.
A 150-row benchmark grid looks like the output of a robot having a stroke — until you know the three things each row tells you. A field guide to reading our RAG bake-off: read the parametric floor first, decode the system and lane columns, and ask the only two questions that matter — is it right, and what did it cost?