Skip to content
Faeez Shabbir
WorkServicesAboutCVBlogContact
← BlogOct 19, 20264 min readAI Development

LangChain Made My Code Worse

LangChain made my code worse.

I used it on Postlin, my AI LinkedIn assistant. I started with it because that is how a lot of people begin building AI features. For a while it felt productive. Then I had to change a prompt, debug a bad response, or follow what the code was actually doing.

The abstraction hid the part I needed to see: the request going out, the response coming back, and the logic in between. I was learning the framework's metaphors instead of fixing the product.

Plain API calls are boring, and that is the point. You can read them. You can test them. You can change one thing without unpacking a chain.

Why I reached for it

On Postlin, drafting went through a small LangChain layer with a provider for Gemini. The idea was simple. I did not want Gemini baked into every route. If I wanted another model later, I would add a new provider file instead of rewriting the app.

That is a reasonable goal. I still want a single place that talks to the model. What I do not want is a framework that invents its own world around that call: chains, runnables, memory objects, and helpers that wrap helpers.

The selling point was flexibility. In practice I was still calling Gemini. The extra layer was there for a future I had not reached yet, and it sat in the way of the work I was doing now.

Where the abstraction got in the way

I could not see the call. When a draft came back wrong, I wanted to look at the exact prompt, the exact model settings, and the exact response. The more of that sitting behind a chain, the longer it took to find the thing I needed to change. A plain function that builds a prompt and calls the model is easy to log. A stack of abstractions is not.

Small changes got expensive. "Make the tone shorter" or "do not invent a hook the person did not write" should be a prompt change, maybe a token cap. If you have to reason about which part of a chain owns that behaviour, the framework is costing you time.

The framework moves. Helper names change. Examples go stale. You spend a morning checking whether the thing you copied still exists. That is fine for a large system with a dedicated owner. It is a poor tax on a product with a few AI jobs.

I was debugging two systems. There was my product, and there was the library's idea of my product. When something failed, I had to ask whether the bug was my prompt, the model, or the wrapper. I would rather have fewer places to look.

None of this means LangChain is useless for every team. If you are orchestrating a genuinely complex set of steps, a framework can help. A lot of AI features are not that. They are a prompt, a model call, and some code that checks the result.

What I do instead

I keep the AI layer small and obvious.

A function takes the input, builds a prompt, calls the model, and returns text or a checked object. If I need a second model later, I still isolate that call behind a short adapter. The adapter is a few lines, not a framework.

On PathWise AI, roadmaps, project ideas and tutor answers come from Genkit flows running on Gemini. Each flow has a clear job. That made it easier to change prompts and keep outputs usable in the UI, instead of pasting raw model text into the page. It is still an abstraction, but it stays close to "this job, this prompt, this model."

In later Next.js work I have also used the AI SDK directly: streamText or generateText, a model, a prompt, a token cap. Switching providers is one import. The rest of the code stays readable.

A short call looks like this:

ts
import { generateText } from "ai";
import { google } from "@ai-sdk/google";

export async function draftPost(idea: string) {
  const { text } = await generateText({
    model: google(process.env.GEMINI_MODEL!),
    prompt: `Draft a LinkedIn post from this idea:\n\n${idea.slice(0, 4000)}`,
    maxOutputTokens: 800,
  });

  return text.trim();
}

There is no magic in that function. That is why I like it. I can log the prompt. I can cap the input. I can write a test that stubs the model. I can change the wording without opening a chain.

If the feature later needs tools, retrieval or multiple steps, I add those as explicit functions I can read. I do not start with a general purpose agent layer and hope the product fits inside it.

A better test for a framework

I now ask a simpler question before I add a library around a model.

Does this make the request, the response and the logic easier to see, or harder? If I cannot explain the call to someone else without drawing the framework's diagram, I do not want it in the product yet.

Frameworks help when the problem is genuinely complex. A lot of AI features are not. They need a clear prompt, a tight output, a fallback, and a person who can edit the result. You can build that with ordinary code.

What I take from this

LangChain helped me get started on Postlin, and then it got in the way. The abstraction hid the request, the response, and the logic in between.

I still isolate model calls. I just keep that isolation thin. Plain API calls are boring, and that is the point. You can read them. You can test them. You can change one thing.

If you have used LangChain or something like it, and you are trying to peel it back without breaking the product, I am happy to take a look.

Keep reading

  1. Nov 18, 2026

    Stop Adding a Vector Database to Everything

    Software Development
  2. Nov 12, 2026

    How X.509 Certificates Work, Using the One on This Site

    Software Development

Have somethingto build?

Email

usually back within 24h

Click to copy, or use Email. Usually replies within 24h.

30 min call on Calendly

Hire me on Upwork
Prefer a form? Open the classic form

Project inquiry

Timeline
Budget range
Your range for this project. Not a price from me.

  • Work
  • Services
  • About
  • CV
  • Blog
  • GitHub ↗
  • LinkedIn ↗
  • Instagram ↗
  • Back to top ↑
© 2026 Faeez ShabbirLahore --:-- PKTOpen to new projects