Reducer
In an agent graph, the rule for combining a node's update with the value already in the state, such as appending messages or adding up cost.
{state, update}replaces each key a node returns. That's right for a draft, where the new one should win, but wrong for a list of notes or a running cost: the second node's notes would wipe out the first's. A reducer says how to combine the old value with the new one for a particular key: for a list, add them end to end; for a cost, sum them. Keys without a reducer are replaced as before.
Try it now
The router reads the evaluator's verdict from the state; the round counter guarantees the loop ends.
Learn it properly
Agents as graphs · State, reducers and routing, a checkpoint after every step, and pausing for a person's approval. About 40 minutes.
Other terms from the same lesson
- human in the loop: A workflow that pauses for a person to approve, edit or answer before it carries on.
- state graph: An agent's workflow written as named steps (nodes) that read and update one shared state, with edges or routing functions choosing the next step.
Never trained an AI?
Teach a small one to write, right in your browser. It takes about 20 seconds and needs no account.