pg_synapse
LLM agents you call from SQL, like stored procedures. A Postgres extension written in Rust.
A 90 second narrated tour of the live demo: an agent triages a support ticket and writes the result back to its row.
What it is
SELECT synapse.execute('triage_agent', 'Triage ticket 1.');
- Running the query starts a tool-calling loop against any OpenAI-compatible or Anthropic model, local or hosted.
- The agent's tools (
sql_query,sql_exec, HTTP, MCP, and more) read and write Postgres directly. - Agents, model profiles, runs, messages, and traces are ordinary tables in the
synapseschema. - A small kernel (six traits, three executors, an MCP client) with providers and tools as plugins.
Why agents in the database?
- The data is already there. No export step, no extra service, no copy going stale.
- Transactions. Each tool call runs in a subtransaction, so a failed call rolls back its writes.
- Permissions you already have. An agent runs as a constrained Postgres role, and every run is audited.
- Events for free. A trigger can start an agent: insert a row and it gets triaged.
- Observable with SQL. Runs, tool calls, and token counts are rows you can query and join.
The slides go through this in more detail.
Try it
git clone https://github.com/yonk-labs/pg-synapse cd pg-synapse docker compose up --build # then open http://localhost:8080
Point it at any OpenAI-compatible endpoint whose model supports function calling. The demo in the video ran on qwen3:4b-instruct under Ollama.