← Production Insights

#15

Validator Nodes Protect Business Transitions

Do not let business nodes protect themselves from bad state.

Put a validator node before them.

In production LangGraph workflows, not every node should be allowed to run just because the graph reached it.

Some nodes are risky.

  • They call external tools.
  • They mutate business state.
  • They create orders.
  • They update carts.
  • They trigger payments.
  • They send messages.

Before those nodes run, the graph should ask one important question:

Is the current state safe enough to continue?

That is the role of a validator node.

A validator node does not perform the business action.

  • It protects the business action.
  • It checks whether the required state exists.
  • It checks whether the values are valid.
  • It checks whether the user input is complete.
  • It checks whether the next operation is allowed.
  • It checks whether the graph has enough context to continue safely.

For example, before addToCartNode runs:

  • Do we have a userId?
  • Do we have a selectedProductId?
  • Do we have a valid quantity?
  • Did we resolve "the first one" correctly?

If the answer is no, the graph should not call the cart tool.

It should route to the correct next step to get the missing state data.

A validator node is a gate before execution.

Reliable agentic systems are not only about what the graph can do.

They are also about what the graph refuses to do when the state is not safe.