LangChain and LangGraph: Python agent setup tutorial
Learn Python agent setup, tool calling and conditional routing with LangChain and LangGraph, starting with a mock model that needs no API key.
Player not loading? Watch on YouTube
This tutorial builds a Python AI agent workflow with LangChain and LangGraph, progressing from a fixed input-and-output script to tool calling and conditional routes. The presenter describes runtime decisions as the distinction between an agent and a fixed workflow, then compares when plain Python, LangChain or LangGraph fits the examples.
Setup covers a virtual environment, package installation and verification. The demonstration uses Python 3.13.5; the presenter states a minimum requirement of Python 3.10 and gives setup guidance for Linux and Windows. A mock chat model returns predefined responses locally without an API key or internet connection. This is an offline testing example, rather than a demonstration of running an actual local LLM.
The security examples load requests from JSON files and turn Python functions into approved tools for retrieving vulnerability records. A structured response adds fields such as risk level, confidence and next action, with validators that restrict accepted values.
LangGraph examples pass shared state through nodes before adding branches for direct answers, source retrieval, human review or rejection. The demonstrated retrieval uses an internal script, not an external API. The walkthrough also points viewers to TryHackMe's Agent Foundations room for practice.