LangChain
LangChain is an open-source framework for building LLM-powered applications and agents. It belongs to the Agent App / Orchestration Framework layer, not the software delivery workflow layer.
Primary reference: https://docs.langchain.com/oss/python/langchain/overview
Where LangChain fits
mermaid
flowchart TB
A[LLM / Model] --> B[LangChain]
B --> C[Tools]
B --> D[Prompt / instructions]
B --> E[Retriever / data sources]
B --> F[Agent logic]
F --> G[AI app or agent service]LangChain answers:
How do I build an AI app or agent that connects models, prompts, tools, data, and application logic?
It does not primarily answer:
How should an AI coding agent manage specs, plans, approvals, and delivery artifacts?
Core concepts
| Concept | Role |
|---|---|
| Model | The LLM or chat model used by the app |
| Prompt/instructions | How the app guides model behavior |
| Tools | Functions the model/agent can call |
| Retriever | Component that fetches relevant external knowledge |
| Agent | Model-driven loop that decides whether to respond or use tools |
| Middleware | Custom control around agent behavior |
| Messages/state | Conversation and execution context |
Simple agent flow
mermaid
flowchart LR
A[User request] --> B[Prompt / agent]
B --> C[Model]
C --> D{Need tool?}
D -->|Yes| E[Tool call]
E --> B
D -->|No| F[Response]RAG app flow
mermaid
flowchart TB
A[User question] --> B[Retriever]
B --> C[Documents / Vector DB]
C --> D[Context]
D --> E[Prompt]
E --> F[LLM]
F --> G[Answer]When to use LangChain
Use LangChain when:
- You are building an AI application or backend service.
- You need tools, model calls, prompts, retrievers, or structured outputs.
- You want a fast way to build agents that call functions.
- You need integrations with model providers, vector stores, tools, and observability.
- Your workflow is application runtime behavior, not software delivery governance.
When not to use LangChain
Do not use LangChain as a replacement for:
| Need | Better layer |
|---|---|
| Spec-first software delivery | Spec Kit or OpenSpec |
| Enterprise approval/audit lifecycle | AWS AI-DLC |
| Agent CLI/harness for coding in a repo | Codex CLI, Claude Code, Hermes |
| TDD/review discipline | Superpowers |
| Multi-phase coding project memory | GSD |
LangChain and workflow frameworks
LangChain can be the app framework inside a repo whose development is governed by another workflow.
Example:
mermaid
flowchart TB
A[OpenSpec change] --> B[Implement LangChain app]
B --> C[Retriever + tools + prompts]
C --> D[Tests and evals]
D --> E[Sync/archive specs]In that stack:
- OpenSpec owns change artifacts.
- LangChain implements the AI app behavior.
- Superpowers can enforce TDD/review.
- CI/evals prove correctness.
Step-by-step: build a RAG chatbot
- Define the feature with OpenSpec or Spec Kit.
- Identify knowledge sources.
- Create retriever/vector store.
- Write prompt/instructions.
- Create LangChain chain or agent.
- Add citations or source references.
- Add tests/evals for answer quality.
- Add latency and cost monitoring.
- Review and ship.
Definition of done
An AI app built with LangChain is done when:
- Inputs/outputs are defined.
- Tool permissions are explicit.
- Retrieval behavior is tested.
- Prompt behavior is evaluated.
- Errors and fallbacks are handled.
- Cost and latency are measured.
- Observability exists for production use.