LangChain Python (v1.3-focused)
Practical workflow for building reliable LangChain systems with correct 1.x APIs and strong multi-agent design.
When to activate
- Building or refactoring Python agents with
create_agent
- Designing multi-agent systems (subagents, handoffs, router, skills)
- Implementing middleware/context engineering/stateful tools
- Integrating Tavily or provider-specific tools
- Migrating snippets from stale pre-1.0 docs to current semantics
Version baseline (important)
Assume LangChain 1.3.x semantics (langchain-core on the 1.4.x line) with LangGraph 1.2.x unless the user explicitly requests another version.
- Prefer
from langchain.agents import create_agent
- Prefer middleware-based dynamics (
dynamic_prompt, wrap_model_call, wrap_tool_call)
- Use
Command(update=...) for state updates in tools/handoffs
- Treat old
langgraph.prebuilt.create_react_agent snippets as migration candidates — the langgraph.prebuilt module is deprecated; canonical home is langchain.agents
- Legacy chain abstractions (
LLMChain, initialize_agent, AgentExecutor, old memory classes) live in langchain-classic; AgentExecutor reaches end of maintenance December 2026 — migrate to create_agent or a raw LangGraph StateGraph
- LangGraph 1.2 adds per-node execution controls (timeouts, error-recovery policies, graceful shutdown hooks), the streaming API v3 (typed per-channel projections), and beta
DeltaChannel for incremental checkpoint writes on large state
If uncertain, load references/version-scope.md first.
Recommended workflow
- Scope: identify version, providers, and required capabilities (single agent vs multi-agent).
- Choose architecture:
- Single agent for simple tasks and small toolsets
- Subagents for domain separation and centralized coordination
- Handoffs for sequential/user-facing state transitions
- LangGraph custom workflow for deterministic control gates
- Define tools with strong names, typed signatures, and clear docstrings.
- Engineer context via middleware (prompt/tool/model/response format selection).
- Add memory/persistence with checkpointer/store only where needed.
- Harden with error middleware, interrupts (HITL), and traceability.
- Verify version correctness (no legacy imports/patterns).
Multi-agent design rules
- Subagents: supervisor calls specialists as tools; great for domain boundaries.
- Handoffs: tool-driven state transitions; best for staged conversational workflows.
- Router: classification + dispatch for fast parallel domain fan-out.
- Skills: on-demand context loading while one main agent remains in control.
When implementing handoffs:
- Keep message history valid (tool-call and ToolMessage pairing).
- Use
Command.PARENT only when explicit parent-graph routing is required.
- Pass minimal context between agents; summarize rather than dumping internal traces.
Tavily integration guidance
Use Tavily as a focused retrieval/search tool, not as a blanket dependency for every agent.
- Add Tavily mainly to research subagents.
- Keep
max_results and depth bounded to control token/latency costs.
- Use domain filters (
include_domains, exclude_domains) for precision.
Load references/tavily-integration.md for concrete patterns.
Anti-patterns
- Mixing pre-1.0 and 1.x APIs in same implementation
- Giving every agent every tool (routing degrades quickly)
- Handoffs without valid message/tool pairing
- Stateful workflows without checkpointer persistence
- Copy-pasting old blog snippets without migration audit
Outcome expectations
- Architecture choice is explicit and justified.
- Generated code is valid for LangChain 1.3.x / LangGraph 1.2.x.
- Multi-agent context boundaries are intentional and testable.
- Tooling and middleware are minimal but sufficient for reliability.
Resources
Load on demand:
references/version-scope.md — 1.3.x / LangGraph 1.2.x scope, migration-critical rules, changelog highlights
references/multi-agent-patterns.md — pattern selection and tradeoffs
references/handoffs-and-command.md — state-machine handoffs, Command, message validity
references/subagents-supervisor.md — supervisor/subagent layering and information flow
references/tavily-integration.md — LangChain + Tavily setup and practical constraints
references/api-cheatsheet.md — fast API checklist for create_agent, ToolRuntime, Command
1---2name: langchain-py3description: Build and maintain production-grade LangChain Python systems (LangChain 1.3.x / LangGraph 1.2.x baseline) with create_agent, middleware, tools, structured output, and multi-agent architectures (subagents, handoffs, router, skills). Activate for Python agent design, debugging, migrations from older APIs, context engineering, and Tavily-backed web search integration.4license: MIT5---67# LangChain Python (v1.3-focused)89Practical workflow for building reliable LangChain systems with **correct 1.x APIs** and strong multi-agent design.1011## When to activate1213- Building or refactoring Python agents with `create_agent`14- Designing multi-agent systems (subagents, handoffs, router, skills)15- Implementing middleware/context engineering/stateful tools16- Integrating Tavily or provider-specific tools17- Migrating snippets from stale pre-1.0 docs to current semantics1819---2021## Version baseline (important)2223Assume **LangChain 1.3.x** semantics (langchain-core on the 1.4.x line) with **LangGraph 1.2.x** unless the user explicitly requests another version.2425- Prefer `from langchain.agents import create_agent`26- Prefer middleware-based dynamics (`dynamic_prompt`, `wrap_model_call`, `wrap_tool_call`)27- Use `Command(update=...)` for state updates in tools/handoffs28- Treat old `langgraph.prebuilt.create_react_agent` snippets as migration candidates — the `langgraph.prebuilt` module is deprecated; canonical home is `langchain.agents`29- Legacy chain abstractions (`LLMChain`, `initialize_agent`, `AgentExecutor`, old memory classes) live in **`langchain-classic`**; `AgentExecutor` reaches **end of maintenance December 2026** — migrate to `create_agent` or a raw LangGraph `StateGraph`30- LangGraph 1.2 adds per-node execution controls (timeouts, error-recovery policies, graceful shutdown hooks), the streaming API v3 (typed per-channel projections), and beta `DeltaChannel` for incremental checkpoint writes on large state3132If uncertain, load `references/version-scope.md` first.3334---3536## Recommended workflow37381. **Scope**: identify version, providers, and required capabilities (single agent vs multi-agent).392. **Choose architecture**:40 - Single agent for simple tasks and small toolsets41 - Subagents for domain separation and centralized coordination42 - Handoffs for sequential/user-facing state transitions43 - LangGraph custom workflow for deterministic control gates443. **Define tools** with strong names, typed signatures, and clear docstrings.454. **Engineer context** via middleware (prompt/tool/model/response format selection).465. **Add memory/persistence** with checkpointer/store only where needed.476. **Harden** with error middleware, interrupts (HITL), and traceability.487. **Verify version correctness** (no legacy imports/patterns).4950---5152## Multi-agent design rules5354- **Subagents**: supervisor calls specialists as tools; great for domain boundaries.55- **Handoffs**: tool-driven state transitions; best for staged conversational workflows.56- **Router**: classification + dispatch for fast parallel domain fan-out.57- **Skills**: on-demand context loading while one main agent remains in control.5859When implementing handoffs:6061- Keep message history valid (tool-call and ToolMessage pairing).62- Use `Command.PARENT` only when explicit parent-graph routing is required.63- Pass minimal context between agents; summarize rather than dumping internal traces.6465---6667## Tavily integration guidance6869Use Tavily as a focused retrieval/search tool, not as a blanket dependency for every agent.7071- Add Tavily mainly to research subagents.72- Keep `max_results` and depth bounded to control token/latency costs.73- Use domain filters (`include_domains`, `exclude_domains`) for precision.7475Load `references/tavily-integration.md` for concrete patterns.7677---7879## Anti-patterns8081- Mixing pre-1.0 and 1.x APIs in same implementation82- Giving every agent every tool (routing degrades quickly)83- Handoffs without valid message/tool pairing84- Stateful workflows without checkpointer persistence85- Copy-pasting old blog snippets without migration audit8687---8889## Outcome expectations9091- Architecture choice is explicit and justified.92- Generated code is valid for LangChain 1.3.x / LangGraph 1.2.x.93- Multi-agent context boundaries are intentional and testable.94- Tooling and middleware are minimal but sufficient for reliability.9596---9798## Resources99100Load on demand:101102- `references/version-scope.md` — 1.3.x / LangGraph 1.2.x scope, migration-critical rules, changelog highlights103- `references/multi-agent-patterns.md` — pattern selection and tradeoffs104- `references/handoffs-and-command.md` — state-machine handoffs, `Command`, message validity105- `references/subagents-supervisor.md` — supervisor/subagent layering and information flow106- `references/tavily-integration.md` — LangChain + Tavily setup and practical constraints107- `references/api-cheatsheet.md` — fast API checklist for `create_agent`, `ToolRuntime`, `Command`