liveBook · Manning

Tools_condition

As explained in Build Python Web Apps with Streamlit

tools_condition is a LangGraph routing function that sends execution to a tool node when the latest language-model message contains tool calls and otherwise sends execution to END.

tools_condition is a LangGraph routing function for agent graphs. It sends execution to a ToolNode when the latest language-model message contains tool calls; otherwise, it sends execution to END. section 10.6.4

Use it as a conditional edge from an assistant node. After a tool runs, connect the tools node back to the assistant so the model can inspect the ToolMessage, call another tool, or finish without further calls. section 10.6.4

Routing support actions

A support agent can decide to track or cancel an order. A tool call routes the request through ToolNode, then returns the result to the assistant; a normal response routes to END and is displayed to the user. section 10.6.4

How Build Python Web Apps with Streamlit covers it

How deep it goes
Defines conditional routing and the assistant-tool loop, but does not descend into the function's internal implementation.
Examples
Uses an agent graph that tracks or cancels orders through a tools node before returning control to the assistant.
What it assumes
Assumes familiarity with assistant nodes, ToolNode, tool calls, graph edges, and the END marker.
What you can do after
Apply it via LangGraph to build an agent loop that invokes tools and ends when the model produces no further tool calls.
How it connects
Connects conditional edges, ToolNode, tool calls, ToolMessage, assistant nodes, and END in LangGraph.

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.