Agent skill · AI & Agents

agentsop-state-reducer

Tool skill for declaring reducers on LangGraph state keys so parallel writes merge instead of crashing. Activates whenever a coder agent designs a StateGraph with parallel branches, fan-out via Send, multi-agent topologies, or whenever a run raises `InvalidUpdateError: At key '<k>': Can receive only one value per step`. Encodes the rule "every state key is single-writer or has a reducer — nothing in between."

agentsopegithub.com/agentsopeGitHub ↗
claude-codeMIT
Install
npx skills add agentsope/SkillAlchemy --skill agentsop-state-reducer --agent claude-code

Same command for any agent — swap --agent for codex, cursor, copilot.

Facts
Files in the skill folder: 1
SKILL.md size: 18 KB
Bundled scripts: none
Version: 0.1.0
Path: skills/agentsop-state-reducer/SKILL.md
Open the folder on GitHub →
Where it comes from
Stars: 255
Language: Python

Weekly change comes from our own snapshots, not the repository page — it measures attention, not adoption.

From the SKILL.md

# State Reducer · Tool Skill > Scope: a single decision — for each state key, declare a reducer or > guarantee single-writer. Out of scope: checkpointers, HITL, supervisor vs. > swarm — see `langgraph-sop` for those. --- ## 1. 何时激活 (Activation Rules) Activate when **any** trigger fires: - The task involves a LangGraph `StateGraph`, `TypedDict`/`BaseModel` schema, or `Annotated[..., <reducer>]` typing. - The graph has ≥1 of: parallel branches via static fan-out, `Send` API, multiple agents writing shared state, or a supervisor pattern where workers return concurrently. - The run raises `langgraph.errors.InvalidUpdateError` — message looks like `At key 'messages': Can receive only one value per step. Use an Annotated key to handle multiple values.` - The user pastes a state schema and asks "why does this crash on parallel?" or "do I need a reducer here?". - The user is migrating a linear chain to a fan-out / map-reduce shape. Do **not** activate if every key is written by exactly one node per superstep (see §6: over-reducing single-writer keys is an anti-pattern). --- ## 2. 核心心智模型 (Core Mental Model) **LangGraph state is either single-writer or has a reducer. Nothing in between.** Wh

What's inside
Steps it walks through
  1. 1. 何时激活 (Activation Rules)
  2. 2. 核心心智模型 (Core Mental Model)
  3. 3. SOP 工作流 (Agentic Protocol)
  4. Step 1 · Enumerate writers per key
  5. Step 2 · Classify each key
  6. Step 3 · Pick the reducer
  7. Step 4 · Probe-test the parallel update
  8. Step 5 · Document the contract
  9. 4. 操作模型 (Operation Models)
  10. OP-1 · Declare addmessages for a chat history key
  11. OP-2 · Declare operator.add for an accumulating list
  12. OP-3 · Declare operator.add for a counter
  13. OP-4 · Single-writer key (no reducer)
  14. OP-5 · Custom reducer — keep latest by timestamp
More from SkillAlchemy
All skills →
About this skill
What does the agentsop-state-reducer skill do?

Tool skill for declaring reducers on LangGraph state keys so parallel writes merge instead of crashing. Activates whenever a coder agent designs a StateGraph with parallel branches, fan-out via Send, multi-agent topologies, or whenever a run raises `InvalidUpdateError: At key '<k>': Can receive only one value per step`. Encodes the rule "every state key is single-writer or has a reducer — nothing in between."

How do I install it?

Run `npx skills add agentsope/SkillAlchemy --skill agentsop-state-reducer --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 agentsope/SkillAlchemy, a repository with 255 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.

Keep going