1---2name: modbender-skill-library-mcp-langchain3description: ---4---5---6name: LangChain7description: Avoid common LangChain mistakes — LCEL gotchas, memory persistence, RAG chunking, and output parser traps.8metadata: {"clawdbot":{"emoji":"🦜","requires":{"bins":["python3"]},"os":["linux","darwin","win32"]}}9---1011## LCEL Basics12- `|` pipes output to next — `prompt | llm | parser`13- `RunnablePassthrough()` forwards input unchanged — use in parallel branches14- `RunnableParallel` runs branches concurrently — `{"a": chain1, "b": chain2}`15- `.invoke()` for single, `.batch()` for multiple, `.stream()` for tokens16- Input must match expected keys — `{"question": x}` not just `x` if prompt expects `{question}`1718## Memory Gotchas19- Memory doesn't auto-persist between sessions — save/load explicitly20- `ConversationBufferMemory` grows unbounded — use `ConversationSummaryMemory` for long chats21- Memory key must match prompt variable — `memory_key="chat_history"` needs `{chat_history}` in prompt22- `return_messages=True` for chat models — `False` returns string for completion models2324## RAG Chunking25- Chunk size affects retrieval quality — too small loses context, too large dilutes relevance26- Chunk overlap prevents cutting mid-sentence — 10-20% overlap typical27- `RecursiveCharacterTextSplitter` preserves structure — splits on paragraphs, then sentences28- Embedding dimension must match vector store — mixing models causes silent failures2930## Output Parsers31- `PydanticOutputParser` needs format instructions in prompt — call `.get_format_instructions()`32- Parser failures aren't always loud — malformed JSON may partially parse33- `OutputFixingParser` retries with LLM — wraps another parser, fixes errors34- `with_structured_output()` on chat models — cleaner than manual parsing for supported models3536## Retrieval37- `similarity_search` returns documents — `.page_content` for text38- `k` parameter controls results count — more isn't always better, noise increases39- Metadata filtering before similarity — `filter={"source": "docs"}` in most vector stores40- `max_marginal_relevance_search` for diversity — avoids redundant similar chunks4142## Agents43- Agents decide tool order dynamically — chains are fixed sequence44- Tool descriptions matter — agent uses them to decide when to call45- `handle_parsing_errors=True` — prevents crash on malformed agent output46- Max iterations prevents infinite loops — `max_iterations=10` default may be too low4748## Common Mistakes49- Prompt template variables case-sensitive — `{Question}` ≠ `{question}`50- Chat models need message format — `ChatPromptTemplate`, not `PromptTemplate`51- Callbacks not propagating — pass `config={"callbacks": [...]}` through chain52- Rate limits crash silently sometimes — wrap in retry logic53- Token count exceeds context — use `trim_messages` or summarization for long histories5455---56> Source: [modbender/skill-library-mcp](https://github.com/modbender/skill-library-mcp) — distributed by [TomeVault](https://tomevault.io).57<!-- tomevault:4.0:skill_md:2026-06-16 -->
Run npx skillmds@latest add tomevault-io/modbender-skill-library-mcp-langchain in your terminal (requires Node.js), paste this page's agent-chat prompt into Claude, Cursor, or any MCP-connected agent, or download the SKILL.md file and copy it into your agent's skills directory.
--- It is listed under AI & ML on SkillMD.
This skill has not completed SkillMD's automated safety review yet. Independent scanners report: SkillSpector: PASS, Skill Scanner: PASS. SkillMD never runs a skill's scripts for you; review the SKILL.md before installing.
This skill is tagged as working with Claude Code, Claude.ai, OpenAI Codex. SKILL.md is an open format, so most agents that read a skills directory can load it too.
Yes. Installing skills from SkillMD is free, and the skill stays under its author's original license.
tomevault-io (@tomevault-io) published this skill. Their other Agent Skills are listed on their SkillMD profile.