Index of every page on this site: llms.txt
All skills
jeremylongshore avatar

/langchain-core-workflow

@0d57af8
Run it yourself

Compose LangChain 1.0 chains with RunnableParallel, RunnableBranch, RunnablePassthrough.assign, and RunnableLambda — correct input/output shapes, debug probes, and typed composition that catches dict-shape bugs before invocation. Use when wiring multi-step chains, parallel retrievals, conditional routing, or threading state through a chain for RAG, classification, or extraction pipelines. Trigger with "runnable parallel", "runnable branch", "langchain rag composition", "passthrough assign", "langchain lcel", "runnable lambda", "debug probe".

Use this Skill: https://skilld.dev/gh/jeremylongshore/tons-of-skills-marketplace/langchain-core-workflow

Nothing lands on disk. Nothing to clean up.

Fork this Skill

Edit a local copy. It keeps the author and licence.

referencesone-pager.md

≈811 tokens on demand. Your agent reads this file only when SKILL.md points to it.

langchain-core-workflow — One-Pager

Compose LangChain 1.0 chains with RunnableParallel, RunnableBranch, RunnablePassthrough.assign, and RunnableLambda — correct input/output shapes, debug probes, and typed composition that catches dict-shape bugs before invocation.

The Problem

An engineer wires a four-stage chain: classify → retrieve → format → generate. .invoke({"question": "..."}) returns KeyError: 'question' from deep inside runnable internals. The stack trace names _call_with_config and a transformer class but never the stage that produced the wrong dict shape. Swapping RunnablePassthrough() for RunnablePassthrough.assign(context=retriever) changes the schema in a way that downstream prompt.invoke(dict_in) cannot tolerate, but LCEL gives no pre-invocation check (P06). Meanwhile, legacy AgentExecutor silently turns tool exceptions into empty-string observations and the agent answers "I couldn't find that" — no error surfaces (P09).

The Solution

Add a RunnableLambda debug probe between every two stages (overhead <1ms per invocation) that prints or logs the dict's keys. For new code, annotate chains with RunnableSerializable[InputT, OutputT] plus pydantic BaseModel input/output types — mypy and pytest catch P06 at lint time, not at .invoke(). Fan-out independent retrievals with RunnableParallel for a 2–3× wall-clock win on 2 parallel calls. Route on input shape with RunnableBranch (always supply a default). Thread state through the chain with RunnablePassthrough.assign(field=...). For agent loops, skip AgentExecutor entirely and use LangGraph's create_react_agent — tool errors raise, not vanish.

Who / What / When

Aspect Details
Who Python engineers wiring multi-step LCEL chains — RAG composition, classification + extraction pipelines, parallel retrieval/tool-use stages, conditional routing
What RunnableParallel / RunnableBranch / RunnablePassthrough.assign / RunnableLambda patterns, debug-probe recipe, typed composition with RunnableSerializable[I, O], 4 deep references
When After langchain-sdk-patterns (composition primitives) and langchain-model-inference (chat models), before any multi-stage chain ships — P06's cryptic KeyError burns hours if the debug probes are not in from the start

Key Features

  1. Debug-probe pattern — A one-line RunnableLambda(lambda x: (print(f"[probe] keys={list(x.keys())}"), x)[1]) insertable between any two stages, <1ms overhead, surfaces the exact stage that changes the dict shape (P06 fix)
  2. Typed composition with RunnableSerializable[InputT, OutputT] — Annotate chain boundaries with pydantic BaseModel types so mypy flags shape mismatches before invocation; pairs with chain.input_schema.model_json_schema() for runtime assertion
  3. RAG composition recipe — End-to-end pattern (retriever + context formatter + prompt + llm + parser) with RunnablePassthrough.assign(context=retriever) that preserves the input question field through to the prompt, plus a parallel variant for hybrid dense + BM25 retrieval

Quick Start

See SKILL.md for full instructions.

Source: SKILL.md on GitHub

skilld matched fixed text patterns in SKILL.md and file names. Patterns miss obfuscated code.

skilld run checks every file with the same patterns. It asks for approval before it loads a Skill with a behavior marked Needs approval.

No alerts2mo3 checks · Risk SAFE
  • Gen Agent Trust Hub2mo

    This skill provides educational patterns and best practices for building LangChain 1.0 pipelines. It focuses on improving observability via debug probes and enhancing reliability through typed composition, with no malicious activity detected.

  • Socket2mo

    No alerts

  • Snyk2mo

    Risk: LOW · No issues

Signed by skilld at 0d57af8. This ties the file your Agent reads to that commit on GitHub. It does not review the instructions.

Last checked against GitHub yesterday.

Activeupdated 2 months ago
What it can do
Reads files Edits files Runs commands
version
2.7.0
author
Jeremy Longshore <jeremy@intentsolutions.io>
compatibility
Designed for Claude Code
All 4 allowed tools
ReadWriteEditBash(python:*)
Other metadata
tags
[
  "saas",
  "langchain",
  "langgraph",
  "python",
  "langchain-1.0",
  "lcel",
  "runnables",
  "rag"
]

README badge

README badge for jeremylongshore/tons-of-skills-marketplace/langchain-core-workflow