LangGraph enables human-in-the-loop interactions by using breakpoints to pause graph execution at specific nodes, allowing developers to collect user feedback through dedicated nodes and update the graph state via graph.update_state(), then resume execution using saved threads that preserve the graph's state trajectory.
LangGraph Agents: Implementing Human-in-the-Loop with User Feedback
Added:hey this is Lance from Lang chain I want to talk about some of the more advanced Lang graph features focusing here on waiting for user input so sometimes we have a graph and at a certain point in our graph we want explicitly get feedback from a user this could be clarifying questions in the case of like a chatbot or an assistant um but the point is we want to extract this information from the user at very particular points in our graph and add it to our graph state so that's kind of the motivation now this sits within a broader set of human the loop kind capabilities within Lang graph we already did a video on break points which basically allow you to to basically stop execution of your graph at a certain node and this ability to wait for us your input build on top of the idea of break points now two of the important dependencies just like with breakpoints for this idea of waiting for user input are checkpoints and threads so really in simple terms What's Happening Here is that as I run my graph every graph step can be saved I.E the state of the graph and the next nodes travel to in the graph can be saved by a checkpoint ter as a checkpoint so you can imagine your graph is going along at every step you're saving the checkpoint those checkpoints are then rolled up into what we call a thread and this thread is basically a kind of a persistent State uh trajectory of your graph which you can reference at a later point in time so for example if your graph is running you hit a break break point and you stop it you have a thread that allows you to return to where your graph stopped and proceed so this is obviously useful in the case of a breakpoint where you're like waiting for human uh human approval and it's useful here uh if you're actually waiting for user input in the case of like actual clarifying text so let's actually show this with some code I'll copy this over so here's a really simple graph our state just contains an input and a user feedback key we have three steps we have step one we have a step that collects our user feedback called human feedback and we have step three we've added these and it's a really simple flow just as shown here now you can see I've added a checkpoint her we just talked about why that's important and I've also added this Interruption I.E this is a breakpoint I'm going to break point before my human feedback node so again what's going to happen is I'm going to go ahead and ceed until I hit human feedback and then I'm going to break now let's show this in action copy this over cool so here we go we pass our input we create a thread we invoke our graph so our graph proceeds and we go ahead and hit step one and now before we hit human feedback we stop and then here's what our state is at this point in time our state is simply hello world now what I'm going to do is we're going to copy over here so right here this is just an example where I'm going to gather feedback from the user and this is the Crux of it what I'm going to do is I'm just going to call this graph update state I'm going to pass that user input in to uh this update under the key user feedback so remember our graph had two keys input in user feedback so I can insert that user feedback directly here that's it nice and easy and here's what's kind of cool I can actually insert this as a node so it's as if that human feedback node in my graph is running and I'm just populating it with feedback gathered from my user so if you look at my flow here here's the user feedback node I'm just going to run this node and Plum in the feedback I get from the user and that's what's going to happen right here so let's go ahead and do this let's say uh go ahead to step three cool and there we go so look at my state after the update is hello world and user feedback go ahead to state to uh step three so my State's been updated with that user feedback which I've plumbed in um and now you can see gra this graph.
getet state next tells me what's the next node I want to go to well what we've done is we've already run that human feedback node right here and so the next St My Graph wants to go to is that third step so there we go and now all I need to do because I have a thread that's gathered all this information all I need to do is invoke my graph with that thread I don't have to pass anything because it knows where to pick up because of that thread and it just goes to step three so that's really it very simple and if you pop all the way back up all we've done is we set up a graph we set up a node called human feedback which we're going to collect user feedback G and insert it into our state and all we need to do is very simply set a breakpoint before that node where we stop before we hit this node and then we just manually call this graph update State um we pass in the feedback here that we get from the user and we run that as a node human feedback so it's basically as if this node is running we update our state accordingly which we show here and then we move forward to step three because the thread saves all the prior information so we're able to pick up where we left off and we can proceed forward so this is very generally useful and in particular if you have graphs where you want to kind of encode places where you can ask clarifying questions or gather more user input along your control flow this kind of approach of asking for uh user feedback directly as a node in your graph is extremely useful thanks
Up Next

Advanced Python AI Agent Tutorial: Implementing RAG with LlamaIndex
@TechWithTim
183.4K views•2024-02-14

BitTorrent Protocol Explained: Piece Selection & Peer Choking
@StevenGordonAU
481 views•2013-02-22

HTTP Requests Explained: GET, POST, PUT, DELETE
@codecademy
103.1K views•2021-10-07

Enigma Machine Mechanics: WWII Encryption Explained
@JaredOwen
13.2M views•2021-12-11
Related Study Plans & Knowledge Roadmaps
Structured learning paths in Computer Science









![[JCD-CD05] Modelos de linguagem e agentes - Aula 03](https://i.ytimg.com/vi/rauXcajgdpA/maxresdefault.jpg)










![[Unity3D] Делаем Recall как у Tracer в Overwatch(Time Rewind)](https://i.ytimg.com/vi/K2EtXGah-wI/maxresdefault.jpg)






![[Paperclip × Bright Data] 시장조사 보고서 자동 생성 풀 가이드](https://i.ytimg.com/vi/vclOMBLqVEQ/maxresdefault.jpg)










