LangChain

Avoid common LangChain mistakes — LCEL gotchas, memory persistence, RAG chunking, and output parser traps.

Safety Notice

This listing is from the official public ClawHub registry. Review SKILL.md and referenced scripts before running.

Copy this and send it to your AI assistant to learn

Install skill "LangChain" with this command: npx skills add ivangdavila/langchain

LCEL Basics

  • | pipes output to next — prompt | llm | parser
  • RunnablePassthrough() forwards input unchanged — use in parallel branches
  • RunnableParallel runs branches concurrently — {"a": chain1, "b": chain2}
  • .invoke() for single, .batch() for multiple, .stream() for tokens
  • Input must match expected keys — {"question": x} not just x if prompt expects {question}

Memory Gotchas

  • Memory doesn't auto-persist between sessions — save/load explicitly
  • ConversationBufferMemory grows unbounded — use ConversationSummaryMemory for long chats
  • Memory key must match prompt variable — memory_key="chat_history" needs {chat_history} in prompt
  • return_messages=True for chat models — False returns string for completion models

RAG Chunking

  • Chunk size affects retrieval quality — too small loses context, too large dilutes relevance
  • Chunk overlap prevents cutting mid-sentence — 10-20% overlap typical
  • RecursiveCharacterTextSplitter preserves structure — splits on paragraphs, then sentences
  • Embedding dimension must match vector store — mixing models causes silent failures

Output Parsers

  • PydanticOutputParser needs format instructions in prompt — call .get_format_instructions()
  • Parser failures aren't always loud — malformed JSON may partially parse
  • OutputFixingParser retries with LLM — wraps another parser, fixes errors
  • with_structured_output() on chat models — cleaner than manual parsing for supported models

Retrieval

  • similarity_search returns documents — .page_content for text
  • k parameter controls results count — more isn't always better, noise increases
  • Metadata filtering before similarity — filter={"source": "docs"} in most vector stores
  • max_marginal_relevance_search for diversity — avoids redundant similar chunks

Agents

  • Agents decide tool order dynamically — chains are fixed sequence
  • Tool descriptions matter — agent uses them to decide when to call
  • handle_parsing_errors=True — prevents crash on malformed agent output
  • Max iterations prevents infinite loops — max_iterations=10 default may be too low

Common Mistakes

  • Prompt template variables case-sensitive — {Question}{question}
  • Chat models need message format — ChatPromptTemplate, not PromptTemplate
  • Callbacks not propagating — pass config={"callbacks": [...]} through chain
  • Rate limits crash silently sometimes — wrap in retry logic
  • Token count exceeds context — use trim_messages or summarization for long histories

Source Transparency

This detail page is rendered from real SKILL.md content. Trust labels are metadata-based hints, not a safety guarantee.

Related Skills

Related by shared tags or category signals.

Web3

OpenClaw News Watcher

Monitors CoinDesk or PANews for new crypto articles, summarizes them, and sends updates to Telegram without API keys or login.

Registry SourceRecently Updated
Web3

research analyst

AI-powered stock & crypto research with 8-dimension analysis, portfolio tracking, and trend detection | AI 驱动的股票与加密货币研究工具,提供 8 维度分析、投资组合追踪和趋势检测

Registry SourceRecently Updated
01
Profile unavailable
Web3

PredictClash

Predict Clash - join prediction rounds on crypto prices and stock indices for PP rewards. Server assigns unpredicted questions, you analyze and submit. Use w...

Registry SourceRecently Updated
1642
Profile unavailable