pgvector vs LangSmith for AI agents: Which Should You Use?

By Cyprian AaronsUpdated 2026-04-21
pgvectorlangsmithai-agents

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

CategorypgvectorLangSmith
Learning curveModerate if you know SQL and PostgresLow if you already use LangChain/LangGraph
PerformanceStrong for vector search inside Postgres; best with proper indexingNot a query engine; focused on tracing/evals, not retrieval latency
EcosystemPostgreSQL, Prisma, Supabase, Rails, Django, any SQL stackLangChain, LangGraph, OpenAI SDK integrations, agent tracing toolchain
PricingOpen source; infra cost is your Postgres billHosted SaaS with free tier and paid plans
Best use casesSemantic search, RAG stores, hybrid search, metadata filteringTracing agent runs, debugging tool calls, prompt/version tracking, evals
DocumentationSolid extension docs and SQL examples; assumes database familiarityGood 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 pgvector avoids a second datastore.
    • You can keep embeddings next to business data like customer_id, policy_id, tenant_id, or document_type.
  • 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.
  • 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 HNSW or IVFFlat.
    • It does not tell you why the agent called the wrong tool or why the prompt regressed after a template change.

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

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

Related Guides