liveBook · Manning

Conditional edge

As explained in Build Python Web Apps with Streamlit

A conditional edge is a graph transition whose next node is selected by evaluating a specified condition.

A conditional edge chooses the next graph node by evaluating a condition. In an agent workflow, it lets an assistant either call tools or finish the conversation. section 10.6.4

Build the routing around the assistant and tool nodes:

  • Define a condition function that returns the name of the next node for each branch. section 10.6.4
  • Use LangGraph's tools_condition to route an assistant response containing tool calls to ToolNode, or route directly to END. section 10.6.4
  • Connect the tools node back to the assistant so it can inspect the ToolMessage and decide whether another tool call is needed. section 10.6.4

Tool-enabled support agent

An assistant receives a customer request and decides whether to call a tracking or cancellation tool. A tool call sends execution to ToolNode; its result returns to the assistant. When no further tool call is present, the conditional edge ends the run.

How Build Python Web Apps with Streamlit covers it

How deep it goes
Explains branching, built-in routing, and the tool loop, but stops short of detailing the condition function's internal implementation.
Examples
Uses an agent graph that tracks or cancels orders through tool calls.
What it assumes
Assumes a graph with assistant and tool nodes, while defining conditional routing from a basic branching function.
What you can do after
Apply it via LangGraph to route tool-enabled assistant workflows and return tool results for further reasoning.
How it connects
Connects graph routing with ToolNode, tool calls, messages, LLM reasoning, and END.

Also explained in

Compare how 2 books explain conditional edge →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Build Python Web Apps with Streamlit. The section links point to the parts of the book it draws on.