rohitg00/ai-engineering-from-scratch · error · RuntimeError
unknown node
Error message
unknown node {current!r} What it means
Runner.run resolves the current node name against the graph's node table; this RuntimeError fires when current (the entry, or a resume_from value, or a value returned by an edge/router) names a node that was never registered, so the step cannot be executed.
Solutions
- Register every node name the graph can route to before running
- Check resume_from strings for typos or stale node ids from an older graph version
- Make router functions return only names from the node table
- Add a graph validation pass that walks edges and asserts endpoints exist
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at phases/14-agent-engineering/13-langgraph-stateful-graphs/code/main.py:110 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of rohitg00/ai-engineering-from-scratch@39ea8a1c6d (2026-08-26).
Data as JSON: /api/errors/6992c59a26431501.
Report an issue: GitHub.
Appendix: source
Thrown at phases/14-agent-engineering/13-langgraph-stateful-graphs/code/main.py:110
def __init__(self, graph: StateGraph,
checkpointer: InMemoryCheckpointer) -> None:
self.graph = graph
self.checkpointer = checkpointer
def run(self, session_id: str, initial_state: State,
resume_from: str | None = None,
state_override: State | None = None) -> State:
if state_override is not None:
state = copy.deepcopy(state_override)
else:
state = copy.deepcopy(initial_state)
current = resume_from or self.graph.entry
if current is None:
raise RuntimeError("no entry node set")
while current is not None and current != END:
fn = self.graph.nodes.get(current)
if fn is None:
raise RuntimeError(f"unknown node {current!r}")
update = fn(state)
if update is None:
update = {}
state = {**state, **update}
self.checkpointer.save(session_id, current, state)
if state.get("_pause_reason"):
reason = state.pop("_pause_reason")
raise PausedAtNode(current, state)
current = self.graph._next(current, state)
return state
def _classify(state: State) -> Update:
text = state["input"].lower()
if "refund" in text or "money back" in text:
route = "refund"
elif "crash" in text or "bug" in text or "error" in text:
route = "bug"View on GitHub (pinned to 39ea8a1c6d)