State management keeps workflow data explicit, consistent, and available across processing steps. In LangGraph, nodes read the current state and return updates that accumulate through the graph, supporting memory, reasoning, and reliable control. section 5.3 section 5.4.2
A practical state-management design:
- Define a strongly typed state object containing fields such as the user question, search queries, search results, summaries, and final output. section 5.4.2 section 5.6
- Pass the current state into each node and return only that node's updates, keeping processing responsibilities modular. section 5.4.2 section 5.5.4
- Use runtime state to choose conditional edges, repeat work when results are insufficient, or proceed when quality conditions are met. section 5.5 section 5.6
Research assistant with a quality loop
A research workflow stores its question, queries, results, summaries, and report in typed state. After evaluating retrieved summaries, it either generates new search queries when fewer than 50% are relevant or proceeds to report writing. section 5.5 section 5.6
from typing import TypedDict, Optional, List
class ResearchState(TypedDict):
user_question: str
assistant_info: Optional[dict]
search_queries: Optional[List[dict]]
search_results: Optional[List[dict]]
research_summary: Optional[str]
final_report: Optional[str]
Use the typed ResearchState listing to see how workflow data is made explicit before nodes process it. section 5.4.2








