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.