langgraph-state
在 LangGraph 中管理状态:模式、reducer、通道和消息传递,用于协调 Agent 执行
npx skills add majiayu000/claude-skill-registry --skill langgraph-state-evanfang0054-cc-system-creator-sc --agent claude-code
Same command for any agent — swap --agent for codex, cursor, copilot.
Weekly change comes from our own snapshots, not the repository page — it measures attention, not adoption.
# langgraph-state (JavaScript/TypeScript) --- name: langgraph-state description: 在 LangGraph 中管理状态 - 模式、reducer、通道和消息传递,用于协调 Agent 执行 --- ## 概述 状态是 LangGraph 中的核心数据结构,在整个图执行期间持久存在。正确的状态管理对于构建可靠的 Agent 至关重要。 **核心概念:** - **StateSchema**:定义状态结构和类型 - **Reducers**:控制如何应用状态更新(ReducedValue) - **通道(Channels)**:低级状态管理原语 - **消息传递**:节点如何通过状态更新进行通信 ## 决策表:状态更新策略 | 需求 | 解决方案 | 使用场景 | |------|----------|----------| | 覆盖值 | 普通 Zod 模式 | 简单字段如字符串 | | 追加到列表 | `ReducedValue` 与 concat | 日志、累积数据 | | 自定义逻辑 | 自定义 reducer 函数 | 复杂合并、验证 | | 消息 | `MessagesValue` | 聊天应用程序 | ## 代码示例 ### 基本状态管理 ```typescript import { StateGraph, StateSchema, START, END } from "@langchain/langgraph"; import { z } from "zod"; const State = new StateSchema({ input: z.string(), processed: z.string(), count: z.number(), }); const process = async (state: typeof State.State) => { return { processed: state.input.toUpperCase(), count: state.count + 1, }; }; const graph = new StateGraph(State) .addNode("process", process) .addEdge(START, "process") .addEdge("process", END) .compile(); const result = await graph.invoke({ input: "hello", count: 0 }); console.log(result); // { input: 'hello', processed: 'HELLO', count: 1 } ``` ### 带Reducer
- 概述
- 决策表:状态更新策略
- 代码示例
- 基本状态管理
- 带Reducer 的消息
- 使用 ReducedValue 的自定义 Reducer
- 使用 ReducedValue 的列表累积
- 使用通道 API
- 部分状态更新
- 边界
- 您能够配置的
- 您不能配置的
- 注意事项
- 1. 忘记为 Arrays 添加 Reducer
What does the langgraph-state skill do?
在 LangGraph 中管理状态:模式、reducer、通道和消息传递,用于协调 Agent 执行
How do I install it?
Run `npx skills add majiayu000/claude-skill-registry --skill langgraph-state-evanfang0054-cc-system-creator-sc --agent claude-code` — it drops the skill into your project so the agent can pick it up. Swap the --agent value for codex, cursor or copilot if you use one of those.
Where does this skill come from?
From majiayu000/claude-skill-registry, a repository with 534 stars. We read it straight from the repository tree rather than a submitted listing, so what you see here is what is actually published.
Is a popular skill a good skill?
Not necessarily. Stars measure attention, not adoption — a repository can trend for a week and be abandoned. That is why we show the weekly change from our own snapshots next to the total, instead of a single flattering number.
