Loading video player...
Hey everyone, this is Avani and I
welcome you back in the next episode of
Lang Graph Advance series. Today our
plan would be to check or to to give a
try how the unified human in the loop
works. So we'll go through several
examples and I will show why you need
this thing unified human in the loop
format. So join me and let's take a look
at that together. And traditionally
before we diving into this stuff, I
wanted to mention that this video is
supervised is extremely highly extremely
highly supervised by angry cats. So if
you are still curious what are those you
need to you have you have to check the
link the merch is there. So please do it
and well we continue. All right we are
there and before we dive into the
details let me maybe quickly recap of
what we had previously. I'm creating the
agent. So it uses the model. It has the
list of tools. And look at that. I'm
wrapping place order which I consider to
be a uh dangerous tool with add
approval. And we have this ask question.
So we have all this kind of human in the
loop in one place.
Right.
So here we are. We have the classical
react agent reasoning acting agent. It
has agent and tools. And since we
bundled everything in one place, let's
test it and see how it behaves. So I'm
starting a new thread. I'm providing the
basic request like buy some Tesla stocks
at the current price.
And I'm simply invoking the graph to see
the results. And what do we have here?
We have a lookup stock symbol for Tesla
because aent doesn't know about that.
It's TSLA. And then fetch stock data for
TSLA. Like everything the same as
previously. No changes here and a lot of
financial data back from the tool call
and then it stopped right it stopped on
the tool with the name ask question and
it's uh there's a question how many
shares of Tesla would you like to buy
like we saw this already and this is
really expected behavior from the whole
system and if you check the current
state we can see that okay the graph was
interrupted so it's human in the loop is
in place
if I check the interruption object then
I have uh I have seen that uh I can see
this uh JSON object with a key question
and the question itself so how many
shares of Tesla TSLA would I like to buy
the current price of something something
and as a matter of fact I have 1,000 so
I'm continuing the execution I'm saying
okay I want to invest a th00and backs
maximum to the Tesla stocks and I'm the
graph is common so I'm putting here
resume and user response and this is
just a plain string. So what we have
here we have the same pieces from the
previous from the past and just
scrolling until the question tool and
then we have the user response. So it
was uh it's a JSON format this time and
I'm saying okay I want to invest 1,000
and then it stopped there right so we
can see the interruption is true in the
same if I check the interruption object
I can see some details so it's a place
order tool and some arguments as well so
we can just continue we are proving we
we we are providing back user response
approve true and the same command resume
as user response and finally we can see
the last steps in the whole flow Have
you noticed the main problem here in the
whole uh execution of the graph? And I
would tell you what's that. This is the
format of request and response. Because
if you think about that, we had two
interruptions basically. One was for a
question and another one was for
approving the tool and in both cases the
format was very very different. So the
first time was user response. I wanted
1000 and even that was not a format. It
was converted to JSON. So users response
as a key and I want to invest 1,00 as a
value
and for executing the place and order
tool it was another JSON was a proof
true and that's it right so it's it's
it's very bad situation right because
you have very different formats from
every single tool in your human in the
loop cycles and the basic idea is that
it would be really good cool idea to to
unify that to provide something which is
very standardized here and the good
thing is that lang graph provides some
primitives for you. So basically we are
talking about standard classes uh you
have in line graph. So this human
interruption, human interrupt and human
response and here's an example of such
objects kind of generated and as a
simple response back it could be human
interrupt object and the type accept
which means okay I'm allowing this
function. That's it. Okay. Okay, so now
once you know the whole story, we can
try to rewrite our previous graph using
this standard types and just see how it
works, how it looks like and then I will
show you the graphical tool where you
can run your graphs agents very quickly.
So here we are starting with tool with
ask question and this is the one when LM
thinks that it needs some information
from a user and what happens here we are
creating our request and then it's human
interruption and we are setting action
as a tool name as question we have
arguments as a question itself and this
is area responsibility for llm then we
allowing what we allowing to ignore it
meaning cancel I can provide some text
input back and this is really what we
want. This is the answering on the
question and the description I'm just
duplicating. Please answer the following
questions and I'm repeating the question
itself. The rest is more or less the
same. We are doing the interruption and
we are passing the request as a
parameter here and then we have back the
response and then based on the response
we can analyze the type of the response
and if it was a response meaning the
answer of the question then we just
returning it back as a tool call result
right if uh the answer was ignore
meaning cancel we are saying okay user
choose not to answer this question. So
this the main two parts how to access
this tool and the same we have to modify
add approval our wrapper which you can
use to wrap any tool in general. So
what's happening here? We are I'm just
uh going to touch some significant
points here and we have a human
interruption. The same we are creating
action request and here we put in the
main tool name. We put in the tool
arguments and this is very dynamic
nature. Then for configuration we
allowing to ignore it meaning cancel the
execution rejecting it. We're not
allowing to provide any response back.
We are not uh well uh it's interesting
thing we allow to accept it and
basically we also can allow to edit
parameters and this is depends on
on this thing right so it's possible
when you wrapping your function for
example you can mainly decide okay for
this function I'm allowing user to
define some parameters or change them
but by default it's false and uh what
happens next we are providing some
description please review and approve
the tool name tool call and interruption
process here. Then we have a response
and then if the execution was accepted
we just blindly invoke the main tool and
returning back the result. If it was an
edit then okay we invoking still the
main tool just we are passing the edited
attributes arguments of this here right
and we taking them from the response.
If it's ignored then we we returning
back that it was canceled by human
continues that executing the tool and
provide next steps and that's it and
this is just safeguard if something is
really wrong here. So I'm creating agent
and it's the same configuration. Take a
look at that. I have an ask question but
this time it's standardized parameters
interruption response in use. I'm
providing you updated ad approval. I'm
not providing here the second parameter.
So it's not allowing to modify the
parameters but basically the look should
be the same right it's the same graph
react agent agent tools everything is
hidden under the hood all right and
let's perform the same series of tests
uh buy some stock test at current price
and run it
and expectation be exactly the same
right we should stop at question ask
question two but then we will check the
parameters there what the response and
request test looks like and here we are
we have Tesla TSLA we have financial
data back and we have tool call for ask
questions
and this time it's interrupted and if I
take a look at the format the data we
have it's much more comprehensive right
now right it contains a lot of data so
what do we have here it's an action
request the action called ask question
and arguments list is a question how
many shares of Tesla
then configuration would allow us to
ignore this question completely to
respond to it and everything else is
forbidden. So I cannot edit I cannot
accept it. So what you will do here we
cannot just resume the graph providing
single string we have to provide it back
as a human response object. And here's
what we have. So type is response
meaning we are providing some feedback
information and the information itself
is in arguments. So I want to invest
1,000 and then we are just user
response. We are assuming the graph is
comment and writing user response as an
input
and look at that we had a question ask
question I want to invest and
immediately we have a tool call for
placing an order and uh let's take a
look at the format right now.
So again action request action is place
order and the args list is much more
bigger right now we have a symbol action
shares limit price
the configuration would allow us to
ignore this tool call for true uh it's
not allowing us to provide any feedback
we don't know how to edit the parameters
because of the variable by default false
but you can enable this guy and we
allowed to accept the tool execution so
finally I'm defining type accept and no
arguments and I'm resumeuming the graph
and then the result is pretty
expectable. All right. And another thing
why we talked so much about the
standardized formats it's that because
you have multiple tools and they're
becoming even more in the future I guess
where if you're following this rules
then your life becomes much much easier.
And as an example I wanted to show you
this agent chat UI. This is an interface
you can run your
uh agents very fast and very quickly. So
what you would need to do for this you
have to run your agent locally first.
Well we will try the easiest
configuration running everything locally
on my local uh machine.
So for that you have to run it in the
studio and for example I copied already.
So I have the studio folder here. I have
the single graph definition and
basically if you're not familiar with
that I would recommend you show or take
a look at l graph introduction series
where we use that technique a lot like
we created bunch of agents there but
basically this is the studio for running
locally your agents. So when you have it
once you have it in your configuration
in a studio you can run it locally and
you go to the studio folder
and you just run langraph dev system
and here you are we are in a studio you
can see your graph uh you can't let me
shrink it a bit so we have the same
graph we can give it a try like writing
something input it will be executed here
but the good thing is that it's already
run locally and this thing the web
interface is connected to our local run.
So what we should do here we can go to
the adding chat and this is this adding
chat versel.app app and you can use it
also it's kind of an internet this
provided by lang graph so what you have
to provide here is a deployment URL and
the assistant graph id and you can take
it from here from the logs so the URL we
have is well it's basically the same
right it's 2024 local host
as the same and the agent name here I
can take it from the configuration
let me take it from here. So it's
financial advisor
and I'm putting it here.
And also additionally optionally you can
provide lens API key if you want to
debug it and see the details but I'm not
going to do this right now just I wanted
to show you the way how you can use it
and why this specific format of human
loop is very useful. And here we are. We
are in the chat. And uh let's just try
and replicate the same conversation we
had previously. And let's start from buy
some Tesla stocks.
And here you have option you can hide
tool calls or you can leave it here. And
let's uh let's give it a try without
tool calls. And then we can start
another chat and just repeat the same
kind of dialogue with this tool calls.
So I'm sending it here. It's a way
around. I'm not hiding any tool called
maybe it's a better way. So look at
that. We have a tool called for look up
stock symbol. We have back Tesla company
name. Then it was looks look look up for
stock financial data for TSOA.
And uh back we have a lot of data which
is hidden here. And then it was a
question ask a question call. So how
many shares of Tesla would you like to
buy? Look at that. Since we provided the
standardized response request type, the
chat knows how to process it correctly.
So we can see this dialogue and what you
can do here. We have a question. You
have opportunity to put your response
here and send it back or you can just
ignore it kind of I'm not going to
answer your question.
And here we need to provide this I want
to invest 1,000 as a response because
this was our testing previously.
And I'm sending the response.
And look at that. We have a place order
function tool call called with some
arguments here. And we have another
dialogue.
So it says okay there's a place order
and you can ignore it cancel and
simultaneously buy and shares two limit
price and you can accept it if you want
to run it or you can just simply ignore
it which means reject.
So if I'm accepting it
and we have the final message like the
two call responded back with the status
field and we have the final message from
the model itself.
This is the beauty of it, right? And
this is because it knows the standard
formats. And that's what I I would
assume you would keep on from now,
right? And if I hide the two calls, just
let's quickly try the same question and
see how it looks like. If it's just
normal chatting, you don't want to see
any details.
And here we are. We have an ask question
immediately dialogue and how many shares
of Tesla
and we are providing the response about
1,000.
And this reminds me already like kind of
chatbot already. Response was submitted
successfully. And then we have another
question. Please uh ignore or accept it.
And maybe this time I want to say no no
no I am rejecting this one. And it says
okay since daughter of buying Tesla
shares was canceled you have some
options. And here we can continue if you
want right. for example. Yeah.
And again the same place order because
the rest is clear already. And this time
for example I'm accepting it and it was
filled. M this is the end of the video
and I really appreciate that you stick
with me till the end and I really hope
that you've learned something new that
you saw different ways how you can work
with human loop and that will give you a
huge help like kind of drive when you're
working on your own agents and Vi thanks
a lot for watching this video and we'll
see each other in the next one about
Lang graph agents and artificial
intelligence so let's stay tuned and see
you
bye-bye
In this video, we take the messy world of HITL interruptions and show how LangGraph Advanced – Standardize Human-in-the-Loop Workflows in AI Agents with Unified HITL Format helps bring everything into one predictable structure. Instead of juggling different JSON formats for questions, approvals, and tool interruptions, we switch to LangGraph’s standard HITL classes so every agent pause works the same way. You’ll see how this unified approach keeps Ai agents easier to debug, easier to scale, and far more reliable — especially when building complex autonomous systems with tools, prebuilt agents, or reAct architecture. We rebuild earlier HITL examples step-by-step, apply the new interruption/response format to multiple tools, and then test the workflow both in the notebook and inside the LangGraph Studio UI. If you’re learning how to create ai agents, how to build ai agents, or how to make ai agents using LangGraph or LangChain agents, this lesson will give you a cleaner, more future-proof way to handle Human-In-The-Loop decisions in your own generic agent architecture. I get it—tech content takes time to research, code, and polish. If my videos have helped you save time, avoid headaches, or just made debugging less painful, a coffee would be highly appreciated! https://buymeacoffee.com/grabduck 🔗 Related Videos ▶️ 4. LangGraph Advanced – Use Dynamic Human in the Loop Interruption in Prebuilt AI Agents https://www.youtube.com/watch?v=8_UQNWTbvEQ ▶️ 15. LangGraph Advanced – Let AI Agents Ask Humans: Build Dynamic Human-in-the-Loop Workflows https://www.youtube.com/watch?v=QS2NjzAQGUY 🌟 Related Courses & Tutorials • LangGraph Introduction Series – Learn how to build AI agents with LangGraph in this step‑by‑step course. From basic graphs to memory, human‑in‑the‑loop (HITL), streaming, FastAPI, and React integration — this playlist covers everything you need to create autonomous AI agents and real‑world applications. https://www.youtube.com/playlist?list=PLaWfw53gNyzaZB3paLG0WmJPLSPj3idpS • LangSmith Introduction Series – Master AI app monitoring and debugging with LangSmith. This tutorial series covers tracing, run types, and step‑by‑step methods for understanding, testing, and improving LLM and LangChain applications. Perfect for developers learning how to monitor AI apps and build more reliable AI agents. https://www.youtube.com/playlist?list=PLaWfw53gNyzY2tEVkPJNCpmfPbRSPKXLw 💡 Explore More: Check out the GitHub repo with all the code we used in this session: https://github.com/esurovtsev/langgraph-advanced #aidevelopment #aiintegration #aiprogramming ============================= Hi, I’m Evgeny, a freelance software engineer passionate about solving complex problems with technologies like Java, Kotlin, Spring Boot, TypeScript, Python, and Node.js. On this channel, you’ll find content centered around AI, search technologies, and security, with in-depth coding sessions and theoretical discussions to enhance your knowledge. Join me as we explore the latest innovations in backend development and beyond. ============================= Just Meditate It is our own mindfulness & design brand. Operated by ECONOR s.r.o., Czech Republic. Legal Notice: Operated by ECONOR s.r.o., Czech Republic This channel and website are intended for an international English-speaking audience.