deepagents-planning-to…
Use the write_todos tool effectively for task planning and decomposition in Deep Agents. Use when users want to (1) implement…
Design state schemas, implement reducers, configure persistence, and debug state issues for LangGraph applications. Use when users want to (1) design or define state schemas for LangGraph graphs, (2) implement reducer functions for state accumulation, (3) configure persistence
Claude Code
$ npx -y skills add soba-labs/langchain-agent-skills --skill langgraph-state-management --agent claude-code
Codex
$ npx skills add soba-labs/langchain-agent-skills --skill langgraph-state-management -a codex -y
Cursor
$ npx skills add soba-labs/langchain-agent-skills --skill langgraph-state-management -a cursor -y
Gemini CLI
$ npx skills add soba-labs/langchain-agent-skills --skill langgraph-state-management -a gemini-cli -y
GitHub Copilot
$ npx skills add soba-labs/langchain-agent-skills --skill langgraph-state-management -a github-copilot -y
OpenCode
$ npx skills add soba-labs/langchain-agent-skills --skill langgraph-state-management -a opencode -y
Windsurf
$ npx skills add soba-labs/langchain-agent-skills --skill langgraph-state-management -a windsurf -y
name: langgraph-state-management description: Design state schemas, implement reducers, configure persistence, and debug state issues for LangGraph applications. Use when users want to (1) design or define state schemas for LangGraph graphs, (2) implement reducer functions for state accumulation, (3) configure persistence with checkpointers (InMemorySaver/MemorySaver, SqliteSaver, PostgresSaver), (4) debug state update issues or unexpected state behavior, (5) migrate state schemas between versions, (6) validate state schema structure, (7) choose between TypedDict and MessagesState patterns, (8) implement custom reducers for lists, dicts, or sets, (9) use the Overwrite type to bypass reducers, (10) set up thread-based persistence for multi-turn conversations, or (11) inspect checkpoints for debugging.
Follow this workflow when designing or modifying state for a LangGraph application:
1. **Identify data requirements** — What data flows through the graph? 2. **Choose a schema pattern** — Match the use case to a template 3. **Define reducers** — Decide how concurrent updates merge 4. **Configure persistence** — Select and set up a checkpointer 5. **Validate and test** — Run schema validation and reducer tests
from langgraph.graph import StateGraph, START, END, MessagesState
from langchain_core.messages import AIMessage
class State(MessagesState):
pass
def chat_node(state: State):
return {"messages": [AIMessage(content="Hello!")]}
graph = StateGraph(State).add_node("chat", chat_node)
graph.add_edge(START, "chat").add_edge("chat", END)
app = graph.compile()For convenience, subclass the built-in `MessagesState` (includes `messages` with `add_messages` reducer):
from langgraph.graph import MessagesState
class State(MessagesState):
documents: list[str]
query: strimport { StateGraph, StateSchema, MessagesValue, ReducedValue, START, END } from "@langchain/langgraph";
import { AIMessage } from "@langchain/core/messages";
import { z } from "zod/v4";
const State = new StateSchema({
messages: MessagesValue,
documents: z.array(z.string()).default(() => []),
count: new ReducedValue(
z.number().default(0),
{ reducer: (current, update) => current + update }
),
});
const graph = new StateGraph(State)
.addNode("chat", (state) => ({ messages: [new AIMessage("Hello!")] }))
.addEdge(START, "chat")
.addEdge("chat", END)
.compile();Choose the pattern matching the application type. See [references/schema-patterns.md](references/schema-patterns.md) for complete examples with both Python and TypeScript.
| Pattern | Use Case | Key Fields | |---------|----------|------------| | **Chat** | Conversational agents | Built-in `messages` from `MessagesState` | | **Research** | Information gathering | `query`, `search_results`, `summary` | | **Workflow** | Task orchestration | `task`, `status` (Literal), `steps_completed` | | **Tool-Calling** | Agents with tools | `messages`, `tool_calls_made`, `should_continue` | | **RAG** | Retrieval-augmented generation | `query`, `retrieved_docs`, `response` |
**Template files** are available in `assets/` for each pattern:
For RAG state patterns, use reference examples in [references/schema-patterns.md](references/schema-patterns.md).
Reducers control how state updates merge when nodes write to the same field.
from typing import Annotated
import operator
from langgraph.graph import MessagesState
class State(MessagesState):
# Overwrite (no reducer)
query: str
# Sum integers
count: Annotated[int, operator.add]
# Custom reducer
results: Annotated[list[str], lambda left, right: left + right]const State = new StateSchema({
query: z.string(), // Last-write-wins
messages: MessagesValue, // Built-in message reducer
count: new ReducedValue( // Custom reducer
z.number().default(0),
{ reducer: (current, update) => current + update }
),
});| Reducer | Import | Behavior | |---------|--------|----------| | `add_messages` | `langgraph.graph.message` | Append, update by ID, delete | | `operator.add` | `operator` | Numeric addition or list concatenation | | `MessagesValue` | `@langchain/langgraph` | JS equivalent of `add_messages` |
Replace accumulated state instead of merging:
from langgraph.types import Overwrite
def reset_messages(state: State):
return {"messages": Overwrite(["fresh start"])}from langchain_core.messages import RemoveMessage
from langgraph.graph.message import REMOVE_ALL_MESSAGES
# Delete specific message
{"messages": [RemoveMessage(id="msg_123")]}
# Delete all messages
{"messages": [RemoveMessage(id=REMOVE_ALL_MESSAGES)]}For advanced reducer patterns (deduplication, deep merge, conditional update, size-limited accumulators), see [references/reducers.md](references/reducers.md).
Persistence enables multi-turn conversations, human-in-the-loop, time travel, and crash recovery.
| Backend | Package | Use Case | |---------|---------|----------| | **InMemorySaver** | `langgraph-checkpoint`
A comprehensive collection of agent-optimized skills for AI coding assistants working in the LangChain ecosystem.
Use the write_todos tool effectively for task planning and decomposition in Deep Agents. Use when users want to (1) implement…
Initialize, validate, and troubleshoot Deep Agents projects in Python or JavaScript using the `deepagents` package. Use when…
Implement multi-agent coordination patterns (supervisor-subagent, router, orchestrator-worker, handoffs) for LangGraph…
Implement LangGraph error handling with current v1 patterns. Use when users need to classify failures, add RetryPolicy for…
Initialize and configure LangGraph projects with proper structure, langgraph.json configuration, environment variables, and…
Use this skill when you need to test or evaluate LangGraph/LangChain agents: writing unit or integration tests, generating test…
Use your assigned AgentMail inbox to read email tasks, explicitly send or reply, and check delivery. Provided automatically by…
Create a new Architecture Decision Record with sequential numbering and AgentDB registration