Skip to content

pg_agent_gate + pg_phasevec (0.x preview) · Apache-2.0 · PostgreSQL 18 and 19

Agents propose,PostgreSQL decides.

Teams are connecting AI agents to production Postgres. When the model hallucinates a DELETE without a WHERE, a DROP TABLE, or a read of another customer's rows, the database runs it. pg_agent_gate makes SQL not execute in an agent's session: the agent may only propose one statement; PostgreSQL verifies it against itself, shows its exact effect, and keeps it only if every guard agrees.

podman run -d -p 5432:5432 -e POSTGRES_PASSWORD=change-me ghcr.io/latamflows/ygg-pg:0.3.6
  • 7 extensions on PGXN
  • Apache-2.0
  • Enforced by hooks inside the server
  • No MCP server required

Try it without installing anything

Ask the assistant for something. Watch PostgreSQL decide.

Thirteen real requests from the public demo: six everyday tasks and seven dangerous ones. Pick one and follow the statement through the gate: which check stops it, how many rows it would touch, and what is left in the database.

agent "assistant" · max_rows 5 · no DDL · tenant 1 Pick a request to start.

The request, in plain language

Pick a request to start.

The statement the model proposed

  1. agent_gate.propose()the gate’s checks
    • kind_allowed
    • no_writing_cte
    • keeps_its_context
    • no_amplification
  2. agent_gate.commit()the real effect, measured by the database
    rows touched — limit 5

A replay, in your browser, of the public demo’s deterministic run (--model stub): the same SQL and the same verdicts anyone gets by running it. Nothing executes here. With the real model (Qwen3-8B on CPU) the SQL changes and the safety result does not: with the database deciding, 0 of 7 trap tasks broke out.

The two core pieces

One controls what the AI does with your data. The other, what the AI remembers about it.

These are the two pieces that let you connect AI to real data without losing control: no action without verification, no memory without a source. The other five extensions in the ecosystem surround them and watch everything else.

The gate pg_agent_gate · v0.4.3

The AI proposes. PostgreSQL decides.

No instruction from the AI runs until the database verifies it, shows its exact effect and approves it within the limits your team set. Everything is on record.

What you gain

  • Lives inside the server, enforced by hooks: no client, driver or protocol can go around it.
  • Shows the exact effect before anything is kept: how many rows change, and in which table. Over that agent's limit, it does not run.
  • Works with any model and any tool: the AI only needs to speak SQL. No MCP server required.
  • Every proposal, approval and rejection lands in a record that cannot be erased.
The memory pg_phasevec · v0.20.0 · preview 0.x

What the AI remembers, with a date and a source.

Everything the AI learned from your data knows who read it, from which exact text and when. If the data changed, the memory marks it as stale and never answers confidently from something that no longer exists.

What you gain

  • Every memory knows which row it came from, the exact text it read, with which model, and when.
  • If the row changes, the memory goes stale in the same transaction: the AI never answers confidently from something that no longer exists.
  • Your data never leaves for an external service: the model that reads is yours, and the memory lives in your database, next to the rows it describes.
  • Switch AI models whenever you want: one model's memories never mix with another's.

Together

With both, a company connects AI to its real data without building custom middleware or copying the data elsewhere: the AI acts on fresh, verifiable information, and never executes anything the database has not decided.

No MCP in between

The model writes SQL. No MCP server, no HTTP and no JSON between the agent and your data.

The usual setup puts an MCP server between the model and the database: that server holds the connection, hands the model a list of tools, and runs whatever the model asks. Here that piece does not exist. The agent arrives over psql, a driver or direct SQL: the statement travels over PostgreSQL's own protocol, with no HTTP and no JSON-RPC on the way, and what decides lives inside the database. For a client that only speaks MCP there is a shim, but it is a compatibility layer, not the product.

The usual way

  1. Model
  2. MCP server
  3. PostgreSQL

The data travels as JSON-RPC. The model decides, the server obeys, and the database executes.

With pg_agent_gate

  1. Model
  2. Native SQL
  3. PostgreSQL + the gate

PostgreSQL's own protocol: no HTTP and no JSON. With the model in process (ygg-agent 0.2.0), no HTTP end to end. The model proposes and PostgreSQL decides.

Services

What we do hands-on, besides the software.

PostgreSQL security audit, rescue of AI-built apps, custom development and consulting. Technical work with deliverables you can verify. In English and Spanish.

  • Service · Audit

    PostgreSQL security audit

    What every role, application and AI agent can touch in your database today. With the SQL evidence for every finding.

    • Roles and privileges
    • Row-level security (RLS)
    • Extensions and functions
    PostgreSQL security audit →
  • Service · Rescue

    Rescue of AI-built apps

    It crashes, it is slow, or the AI can no longer fix it. Evidence-based diagnosis, stabilization, and code that can be continued.

    • Evidence-based diagnosis
    • Stabilization
    • Basic security
    Rescue of AI-built apps →
  • Service · Development

    Custom development

    Backends, APIs and systems with PostgreSQL as the core: data model, security, and AI connected to your data.

    • Data model and schema
    • Backend and APIs
    • Security from the database up
    Custom development →
  • Service · Consulting

    PostgreSQL consulting

    Slow queries, migrations, operations and schema design. Diagnosis measured before and after.

    • Performance
    • Migration to PostgreSQL
    • Operations and availability
    PostgreSQL consulting →

Contact

Write to us. We will get back to you.

Enterprise edition, security audit or agent-to-database integration: one email with two lines about your case is enough. We answer in English and Spanish.

Email

manu@latamflows.com

A person reads the email. If you would rather write directly, the address is above.

Or tell us here

We only use this to reply to you. No lists, no newsletters.

Who is behind this

Manuel Reyes Bravo

The seven extensions, the image and the contributions to PostgreSQL core are signed by Manuel Reyes Bravo, from Chile. To talk code, repositories or the PostgreSQL lists, his personal email:

Personal email

manuelreyesbravo@gmail.com

Also through GitHub issues: pg_agent_gate/issues

Try it Talk