Agent2DB lets an LLM agent work against a real PostgreSQL database without being trusted with it.
Reads use a ranked schema index (BM25 with optional embeddings and foreign-key expansion) instead of dumping 500 table names into the prompt. Writes pause for approval, showing the parsed statement type, warnings and a planner row estimate, and run through a separate least-privilege write role. Pending approvals survive a backend restart via a LangGraph Postgres checkpointer.
Runs track tokens and cost, fall back across models, and trim history. A question benchmark runs against the live model as a CLI.
Hard parts
- Schema retrieval that scales past hundreds of tables (BM25 + embeddings + FK expansion)
- Human-in-the-loop writes with planner estimates, through a separate DB role
- Durable approvals that survive restarts (LangGraph Postgres checkpointer)