liveBook · Manning

State management

As explained in AI Agents and Applications

State management is the controlled maintenance and updating of information representing a workflow's current condition across its processing steps.

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

How AI Agents and Applications covers it

How deep it goes
Defines TypedDict state, node updates, graph routing, and accumulated execution history, without detailing storage or persistence internals.
Examples
Uses a typed research assistant whose search loop evaluates summary relevance before refining queries or writing a final report.
What you can do after
Build it from scratch with TypedDict, StateGraph, node functions, directed edges, and conditional routing.
How it connects
Connects LangGraph, LangChain chains, conditional branching, cyclical workflows, memory, reasoning, and TypedDict.

Also explained in

Compare how 9 books explain state management →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of AI Agents and Applications. The section links point to the parts of the book it draws on.