Gen-AI Developer Classroom notes 08/Jun/2025

Reducers

  • Lets build a graph which will have parallel nodes
    Preview
  • 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_messages to add message during nodes
  • Langgraph also has MessageState which 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.

By continuous learner

enthusiastic technology learner

Leave a Reply

Discover more from Direct AI Powered By Quality Thought

Subscribe now to keep reading and get access to the full archive.

Continue reading