Reducers
- Lets build a graph which will have parallel nodes

- In the above graph, both B and C Execute at same time in parallel
- When we change state in parallel, Invalid Update Error is shown, to resolve this we can implement reducers
- Langgraph has inbuilt reducer
add_messagesto add message during nodes - Langgraph also has
MessageStatewhich uses add_messages reducer. - But this will add too many message if used continuously increasing the token count and therefore the cost.
- To reduce the cost, we have 2 popular approaches
- trim messages: maintain previous n messages rather than all
- summarize messages
- Refer Here for jupyter notebook.
