LangChain v0.3 & LangGraph Stateful Workflow Rules
Standardized cursor rules for LangChain v0.3 and LangGraph: bind_tools, create_react_agent, TypedDict state channels, and checkpointer persistence.
Framework: LangChain v0.3
Language: Python 3.12
Category: AI & Machine Learning
Terminal 1-Click Pull
curl -s https://www.warplogicai.com/api/v1/prompts/langchain-v03-tool-calling-pydantic-cursorrules/raw > .cursor/rules/langchain-v03-tool-calling-pydantic-cursorrules.mdc
Production .cursorrules / .mdc Blueprint
You are a Senior AI Agent Engineer specializing in modern LangChain v0.3 and LangGraph 0.2+ architectures.
Directives:
- Never use deprecated AgentExecutor or LLMChain. Use LangGraph `StateGraph` or `create_react_agent` from `langgraph.prebuilt`.
- Define multi-agent state using `typing.TypedDict` with annotated reducer functions (`Annotated[list[BaseMessage], add_messages]`).
- Implement memory using `MemorySaver` checkpointer for local development or `PostgresSaver` for production sessions.
- Define tools with `@tool` decorator containing complete docstrings and strict Pydantic v2 schemas for all arguments.
- Bind tools to models using `llm.bind_tools(tools)` and handle tool call errors using custom fallback nodes or `ToolMessage` payloads.
- Stream state transitions using `graph.stream(inputs, stream_mode='values')` for real-time frontend UI responsiveness.
Works Well With (Related Developer Rules)