liveBook · Manning

Node

As explained in AI Agents and Applications

A node is a LangGraph workflow component that performs processing by reading the current state and returning state updates.

A node is one processing step in a LangGraph workflow. It receives the current state, performs a task, and returns updates that merge into the workflow state. Nodes are usually Python functions; edges determine which node runs next. This separation is useful when an application must do more than follow a fixed sequence—for example, searching again when research results are insufficient. section 5.4 section 5.4.2 section 5.5.2

To add a node, decide:

  • What state it needs. A research query generator, for example, reads the user's question. section 5.4.3
  • What one task it performs and which state fields it returns. The query generator calls a query-generation function and returns search queries, rather than replacing the entire state. section 5.4.3 section 5.4.2
  • How execution reaches and leaves it. Register the function with `graph.add_node(...)`, then use an edge for a fixed next step or a conditional edge to choose a path from the runtime state. section 5.4.3

A research node

`generate_search_queries(state)` reads `state["user_question"]`, generates queries, and returns `{"search_queries": queries}`. Registering it as `graph.add_node("generate_queries", generate_search_queries)` makes it a graph step. A subsequent edge can send execution to `perform_searches`; a later conditional edge can send weak results back for refinement instead of proceeding to a summary. section 5.4.3 section 5.5.2

Listing 11.8 Graph of the tool-based agent
builder = StateGraph(AgentState)  #1
builder.add_node("llm_node", llm_node)  #2
builder.add_node("tools", tools_execution_node)  #2

builder.add_conditional_edges("llm_node",
    tools_condition)  #3

builder.add_edge("tools", "llm_node")  #4

builder.set_entry_point("llm_node")  #5
travel_info_agent = builder.compile()  #6

See how a `StateGraph` registers separate LLM and tool-execution nodes, routes conditionally after the LLM, and connects tool execution back to it. section 11.3

A node need not call an LLM. In a tool-based agent, an LLM node reads messages and returns a response message; a tools node executes requested tools. A conditional edge sends tool calls to the tools node or ends the graph when no tool call is needed. A node can even be a no-op: a guardrail refusal node returns `{}` and provides a direct path to `END` after a router has prepared the refusal. Keeping tasks separate makes errors and their input data easier to locate, and nodes easier to test or change. section 11.2.6 section 11.4 section 14.2.1 section 5.5.4

How AI Agents and Applications covers it

How deep it goes
Works through node inputs, returned state updates, registration, and edge routing; advises single-task nodes without detailing execution internals.
Examples
Uses research query generation, an LLM-and-tools agent loop, and a no-op guardrail refusal node.
What it assumes
Introduces LangGraph nodes, edges, and state before showing Python functions and typed state definitions.
What you can do after
Build it from scratch by defining state-reading functions, returning updates, registering nodes, and connecting them with fixed or conditional edges.
How it connects
Links nodes to typed state, StateGraph, directed edges, conditional edges, LLM tool calling, and guardrails.

Also explained in

Compare how 19 books explain node →

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.