Sitemap

Member-only story

Design Smarter AI Workflows with LangGraph: State, Messages, Context, and Control Flow Demystified

5 min readAug 5, 2025

--

Design Smarter AI Workflows with LangGraph: State, Messages, Context, and Control Flow Demystified

LangGraph isn’t just another workflow engine — it’s a flexible, stateful, and intelligent system for managing complex AI flows. Whether you’re building a chatbot, a multi-agent orchestration system, or a retrieval-augmented generator (RAG), LangGraph gives you tools to:

  • Maintain evolving state
  • Control the flow of execution
  • Track full message history
  • Inject runtime dependencies
  • Speed up performance with caching

In this blog, we explore State, add_messages, Send, Command, and Runtime Context through clear examples and visual diagrams.

🔢 Understanding State: The Core of LangGraph

In LangGraph, State is a shared, typed dictionary that flows through your graph. Nodes read from and write to this state, which evolves over time.

✅ Use Case: RAG (Retrieval-Augmented Generation) Workflow

📄 State Definition

from typing_extensions import TypedDict
from langgraph.graph.message import add_messages
from langchain_core.messages import AnyMessage
from…

--

--

Guangya Liu
Guangya Liu

Written by Guangya Liu

AI, Observability, Cloud Native and Open Source. Not a Medium member? Visit https://gyliu513.github.io/