pgvector vs LangSmith for AI agents: Which Should You Use?
pgvector and LangSmith solve different problems, and people mix them up constantly.
pgvector is a PostgreSQL extension for storing and querying embeddings with SQL. LangSmith is an observability and evaluation platform for LLM apps and agents. For AI agents, use pgvector for retrieval, and LangSmith for tracing, debugging, and evals — if you have to pick one first, pick LangSmith for agent development, then add pgvector when your agent needs real semantic retrieval.
Quick Comparison
| Category | pgvector | LangSmith |
|---|---|---|
| Learning curve | Moderate if you know SQL and Postgres | Low if you already use LangChain/LangGraph |
| Performance | Strong for vector search inside Postgres; best with proper indexing | Not a query engine; focused on tracing/evals, not retrieval latency |
| Ecosystem | PostgreSQL, Prisma, Supabase, Rails, Django, any SQL stack | LangChain, LangGraph, OpenAI SDK integrations, agent tracing toolchain |
| Pricing | Open source; infra cost is your Postgres bill | Hosted SaaS with free tier and paid plans |
| Best use cases | Semantic search, RAG stores, hybrid search, metadata filtering | Tracing agent runs, debugging tool calls, prompt/version tracking, evals |
| Documentation | Solid extension docs and SQL examples; assumes database familiarity | Good product docs with quickstarts for traces, datasets, and evaluations |
When pgvector Wins
- •
You need retrieval that lives in your database.
- •If your app already runs on PostgreSQL, adding
pgvectoravoids a second datastore. - •You can keep embeddings next to business data like
customer_id,policy_id,tenant_id, ordocument_type.
- •If your app already runs on PostgreSQL, adding
- •
You need SQL-native filtering with vector search.
- •This is where pgvector is clean:
WHERE tenant_id = $1 AND status = 'active' ORDER BY embedding <-> $query_embedding LIMIT 10. - •For multi-tenant AI agents in banking or insurance, that filter layer matters more than people admit.
- •This is where pgvector is clean:
- •
You want simple operational ownership.
- •One backup strategy.
- •One access model.
- •One place to enforce row-level security.
- •If your team already knows Postgres operations, pgvector is the least painful path.
- •
You’re building RAG or memory storage, not agent observability.
- •pgvector handles nearest-neighbor search using indexes like
HNSWorIVFFlat. - •It does not tell you why the agent called the wrong tool or why the prompt regressed after a template change.
- •pgvector handles nearest-neighbor search using indexes like
When LangSmith Wins
- •
You need to see what your agent actually did.
- •LangSmith traces every step: prompts, model calls, tool invocations, retrieved documents, outputs.
- •For agent systems with branching logic or multiple tools, this is non-negotiable.
- •
You are iterating on prompts, tools, and workflows.
- •LangSmith gives you dataset-based evaluations and run comparisons.
- •That means you can test whether changing a system prompt improved tool selection or made hallucinations worse.
- •
You are using LangChain or LangGraph heavily.
- •LangSmith plugs directly into those stacks through tracing hooks and run management.
- •If your agent orchestration already lives there, LangSmith becomes the control plane.
- •
You need production debugging and QA.
- •When a customer says “the assistant answered incorrectly,” you want trace-level evidence.
- •LangSmith makes it easy to inspect runs by session, tag failures, compare outputs across versions, and build regression tests.
For AI agents Specifically
Use LangSmith first if you are building the agent itself. Agents fail in messy ways: bad tool selection, broken prompts, retrieval mistakes hidden behind good-looking answers. LangSmith shows you those failures fast; pgvector only helps once you know retrieval is part of the problem.
Then add pgvector when the agent needs durable semantic memory or document retrieval. In production AI systems for banks and insurers, that combination is common: pgvector stores the knowledge base inside Postgres, while LangSmith tells you whether the agent used it correctly.
Keep learning
- •The complete AI Agents Roadmap — my full 8-step breakdown
- •Free: The AI Agent Starter Kit — PDF checklist + starter code
- •Work with me — I build AI for banks and insurance companies
By Cyprian Aarons, AI Consultant at Topiax.
Want the complete 8-step roadmap?
Grab the free AI Agent Starter Kit — architecture templates, compliance checklists, and a 7-email deep-dive course.
Get the Starter Kit