Getting it into your agent
One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.
npx agentmods add skills/agentsope/skillalchemy/agentsop-state-reducernpx skills add agentsope/SkillAlchemy --skill agentsop-state-reducergit clone --depth 1 https://github.com/agentsope/SkillAlchemyWrote this? Show the measurements
A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.
[](https://agentmods.dev/skills/agentsope/skillalchemy/agentsop-state-reducer)<a href="https://agentmods.dev/skills/agentsope/skillalchemy/agentsop-state-reducer"><img src="https://agentmods.dev/badge/skills/agentsope/skillalchemy/agentsop-state-reducer.svg" alt="Measured on agentmods" height="20"></a>What it costs to keep this loaded
Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.
| Model | Per session | Once invoked |
|---|---|---|
| Fable 5 | $0.00097 | $0.04668 |
| Opus 5 | $0.00048 | $0.02334 |
| Sonnet 5 | $0.00019 | $0.00934 |
| Haiku 4.5 | $0.00010 | $0.00467 |
Grade A, and why
agentsop-state-reducer scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 4d ago.
A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.
Nothing flagged
None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.
How it starts
The opening of the file, as written. The whole thing — 390 lines — stays where its author put it; the contents beside it link to each section on GitHub.
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-sopfor those.
1. 何时激活 (Activation Rules)
Activate when any trigger fires:
- The task involves a LangGraph
StateGraph,TypedDict/BaseModelschema, orAnnotated[..., <reducer>]typing. - The graph has ≥1 of: parallel branches via static fan-out,
SendAPI, multiple agents writing shared state, or a supervisor pattern where workers return concurrently. - The run raises
langgraph.errors.InvalidUpdateError— message looks likeAt 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.
When a node returns {"k": v}, LangGraph must decide how to merge v into
existing state["k"]. There are exactly two legal regimes:
- Single-writer / "set" semantics (default, no
Annotated). At most one node writes the key per superstep. The new value replaces the old. Two concurrent writers →InvalidUpdateError. - Reducer / "merge" semantics
(
Annotated[T, reducer_fn]). Any number of writers may write per superstep; LangGraph folds them viareducer_fn(current, new).
The reducer is commutative-enough algebra that lets the engine schedule parallel writes without you reasoning about interleavings. Three canonical reducers cover ~90% of real graphs:
| Reducer | Type | Behaviour |
|---|---|---|
add_messages (from langgraph.graph.message) |
list[BaseMessage] |
Append; dedupe-and-update by message id (in-place edit when IDs match) |
operator.add |
list, int, float, str |
List concat / numeric sum |
Custom (curr, new) -> merged |
anything | Domain-specific merge (keep-latest, dedupe-by-id, LLM-summarise) |
What this file has done since we first saw it
Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.
- 4d ago First seen · 390 lines · 97 tokens per session scan A db42852ec6ce
agentsop-state-reducer is a skill published in the GitHub repository agentsope/SkillAlchemy (357 stars, last pushed 2d ago), licensed MIT. It adds 97 tokens to every session and 4,668 once invoked, about $0.0005 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.
Other skills, from other repositories
shellgames
Play board games on ShellGames.ai — Chess, Poker, Ludo, Tycoon, Memory, and Spymaster. Use when the agent wants to play games against humans or other AI agents, join tournaments, chat with players, check leaderboards, or manage a ShellGames account. Triggers on "play chess/poker/ludo/memory", "shellgames", "join…
curl-search
Web search using curl + multiple search engines (Baidu, Google, Bing, DuckDuckGo). Activates when user asks to search, look up, or query something online. Includes security enhancements: input sanitization, command injection protection, and URL encoding.
skills-vote-local
Use when retrieving the most relevant skills from a local or private skill library instead of relying on network-based skill discovery.
skills-vote
Find the most relevant external agent skills for the current task, then submit grounded feedback about which skills were actually used and useful in the same session. Whenever you start a task, use this skill first.
Use this skill whenever the user wants to do anything with PDF files. This includes reading or extracting text/tables from PDFs, combining or merging multiple PDFs into one, splitting PDFs apart, rotating pages, adding watermarks, creating new PDFs, filling PDF forms, encrypting/decrypting PDFs, extracting images, and…
xlsx
Use this skill any time a spreadsheet file is the primary input or output. This means any task where the user wants to: open, read, edit, or fix an existing .xlsx, .xlsm, .csv, or .tsv file (e.g., adding columns, computing formulas, formatting, charting, cleaning messy data); create a new spreadsheet from scratch or…