Skip to content

Sequential Graph

Updated
17 Sept 2026
1 min read
0 sections
Page 13 of 18
Langgraph

Objectives ✅

  1. Create multiple Nodes that sequentially process and update different parts of the state.
  2. Connect Nodes together in a graph.
  3. Invoke the Graph and see how the state is transformed step-by-step.
python
from typing import TypedDict
from langgraph.graph import StateGraph

class AgentState(TypedDict):
    name: str
    age: str
    final: str
python
def first_node(state: AgentState) -> AgentState:
    """This is the first node of our sequence."""
    state['final'] = f'Hi, {state['name']}'

    return state

def second_node(state: AgentState) -> AgentState:
    """This is the second node of our sequence."""
    state['final'] += f'You are {state['age']} years old.'

    return state
python
graph = StateGraph(AgentState)

graph.add_node('first_node', first_node)
graph.add_node('second_node', second_node)

# START
graph.set_entry_point('first_node')

# EDGE
graph.add_edge('first_node', 'second_node')

# END
graph.set_finish_point('second_node')

app = graph.compile()
python
result = app.invoke({"name": "Alice", "age": "30"})

print(result['final'])
sequential graph
sequential graph
powershell
OUTPUT:

'Hi, AliceYou are 30 years old.'