Guide
LangChain vs Custom RAG Pipeline
When Agentic Academy Labs keeps LangChain for a prototype and when we extract a custom RAG path for Next.js, Bun, and Postgres production.
Published 2026-08-08 · Updated 2026-08-14
Interns at Agentic Academy Labs can stand up a LangChain demo in a day. That is the point of the framework. The Bangalore fintech assistant, and most customer-facing work we ship from Sikar, did not stay on default chains. We prototype fast, freeze a retrieve-assemble-generate-log interface, then keep or replace internals based on eval, tenancy, and cost. LangChain is not the villain. Unowned abstraction is.
Comparison from delivery, not Twitter
| Factor | LangChain or similar | Custom RAG on our stack |
|---|---|---|
| Time to first demo | Hours to a few days | Longer until the interface exists |
| API churn | You inherit release notes | You own a small surface |
| Debugging a bad citation | Stack through chains and callbacks | One request path in Bun logs |
| Multi-tenant filters | Easy to forget in a helper | First-class if Postgres RLS or query filters are designed |
| Cost control | Easy to nest extra model calls | You see every call site |
| Best fit | PoC, intern spikes, internal tools | Customer-facing production |
What week 1 looks like either way
- Write eval questions before installing a package. Framework choice does not invent quality.
- Index a real folder, not the README. Measure recall on those questions.
- Log query, chunk ids, tokens, and latency to Postgres. If the framework hides that, wrap it.
- Put org_id on retrieval. We have failed this on a LangChain spike and on a hand-rolled path; the bug is human.
- Decide the service interface: retrieve, assemble, generate, log. Names stay stable when we rip out a chain.
When we keep the framework
- Internal tool, one tenant, founder is the only user this quarter.
- The intern project is a learning spike, not a billed SLA.
- We need loaders and splitters this week and will throw the code away after discovery.
When we extract a custom pipeline
- Answers go to paying users or to Slack in a regulated fintech. See the RAG fintech case study.
- Eval harnesses fight the chain more than they help (hidden retries, duplicate embeddings).
- We need Next.js admin to show the exact chunks, not a chain dump.
- Token cost per successful answer is unexplainable because tools nested extra calls.
Failure modes we have hit
- Default text splitters cutting tables in half. Custom chunking around headings and rows fixed recall more than a new model.
- Memory classes that stored the wrong tenant's chat. We now persist threads in Postgres ourselves.
- Upgrading a patch version that changed retriever defaults. Pin versions and re-run the golden set on every bump.
- Copy-pasting a cookbook agent into production. That is an agentic workflow vs chatbot problem, not a RAG problem.
Practical path we recommend
- Prototype retrieval and prompts with whatever gets you to eval fastest.
- Freeze the four-step interface and the log schema.
- Replace internals only where latency, tenancy, or cost demand it. Do not rewrite for taste.
- Keep RAG for changing docs; do not fine-tune facts. RAG vs fine-tuning.
Agentic Academy Labs ships both shapes under custom AI development, usually on Next.js, Bun, and PostgreSQL. Schedule a call if you want a review of an existing chain before it becomes the product.
Frequently asked questions
- Is LangChain bad for production?
- No. It is often fine for internal tools. Customer-facing systems usually need clearer ownership of retrieval, tenancy, and logs than default chains provide.
- When should we rewrite?
- When evaluation, tenant isolation, or cost controls fight the framework more than they benefit from it. Rewrite behind a stable interface, not as a big-bang.
- Do you use LangChain in Sikar internships?
- Yes for spikes. Interns still have to log citations and pass an eval set. We do not ship internship cookbooks to paying Slack workspaces unchanged.
- Does a custom pipeline mean you write a new vector database?
- No. It means we own chunking, filters, prompt assembly, and logging. Postgres plus pgvector is still a common store.