Skip to course content
Free LangChain course

LangChain for LLM Applications and RAG

Unit 01.02: The abstraction cost you are accepting

Every abstraction has a price. Naming it up front means you pay it deliberately rather than discovering it during an incident.

Five costs across five categories

Debugging, understanding, maintenance, capability and operations. None of these argues against the framework; they are what it costs.

The code lists all five.

COSTS = [
    ("a stack trace goes through framework internals", "debugging"),
    ("the wire format is one layer away",              "understanding"),
    ("upgrades can change behaviour you did not write", "maintenance"),
    ("a provider feature may be unreachable",          "capability"),
    ("one more dependency to pin and audit",           "operations"),
]

print(f"{'cost':50} category")
for cost, category in COSTS:
    print(f"{cost:50} {category}")

print("""
None of these is an argument against using the framework. They are the price,
and the price is worth paying when you are composing several pieces or
swapping providers.

The one to plan for is the second. Print the resolved prompt at least once per
chain you build, so you have seen what actually goes over the wire.
""")

The second - the wire format being one layer away - is the one to act on immediately, and the action is trivial. Print the resolved prompt once per chain you build, so you have seen what actually goes to the model. The next module does exactly that.

The third is the one that surprises teams. A minor version bump can change behaviour in code you did not write and did not review, which is why pinning versions and re-running the eval set after upgrades is not optional.

The mistake this prevents

The mistake is paying these costs for a system that never composes anything. If your chain is one prompt and one model, you are carrying the whole price list for the convenience of a template - which str.format also provides.

Takeaway

The costs are real and worth paying when you compose. Print the resolved prompt at least once per chain, pin your versions, and re-run the eval set after an upgrade.