YouTube2Text

How to Debug, Evaluate, and Ship Reliable AI Agents with LangSmith — Transcript

by LangChain · 10,462 words · 1,430 segments · language en · Watch on YouTube

Full transcript

  1. 0:02All right. Um, so we'll go ahead and get
  2. 0:05started. Um, today we're going to be
  3. 0:06talking primarily about how to um,
  4. 0:10essentially debug, evaluate, and ship
  5. 0:11reliable AI agents. Um, and we're going
  6. 0:13to talk about it in the context of
  7. 0:15Langmith. Um, so a lot of what we see
  8. 0:18today um, is built into our Langmith
  9. 0:21product in terms of the way to ship
  10. 0:23reliable and production agents. So I'm
  11. 0:25excited to jump into all of those
  12. 0:27topics. I'm I'm Victor. I'm one of our
  13. 0:29deployed engineers here at Langchain. So
  14. 0:31really excited to get into all of this
  15. 0:33and if you have any questions afterwards
  16. 0:35um please feel free to reach out to me
  17. 0:37or reach out to our team and we can
  18. 0:38definitely um help you along your agent
  19. 0:41building journey. Cool. Um so go ahead
  20. 0:44and jump right into it. So um let me
  21. 0:49There we go.
  22. 0:51Cool. [clears throat] So um the AI
  23. 0:54imperative is here. Um this is something
  24. 0:55we talk about a lot is you know every
  25. 0:57company is trying to figure out how to
  26. 0:59use AI. Um we're seeing generally that
  27. 1:02the challenge of AI is less of like a if
  28. 1:05we're going to do AI and more of when
  29. 1:07and the speed and reliability at which
  30. 1:09you can do so is very very important. Um
  31. 1:12so that's kind of the high level of of
  32. 1:14what we're seeing with AI with different
  33. 1:16companies. um essentially wanting to
  34. 1:18generate more revenue per employee um
  35. 1:20improving their products and experiences
  36. 1:22and also um increasing the efficiency of
  37. 1:24your internal teams. Those are kind of
  38. 1:25like the three paradigms that we see
  39. 1:27people wanting to use AI for. Um a quick
  40. 1:30little poll here. I'm just curious where
  41. 1:32everyone might be in their AI journey,
  42. 1:35whether they're still figuring it out.
  43. 1:36Um actively piloting some AI initiatives
  44. 1:39currently building agents already have
  45. 1:41agents in production. Um would just be
  46. 1:44curious to hear where you're all at
  47. 1:45today. Cool.
  48. 2:00Um, so you should be able to respond to
  49. 2:02that panel. Um, let me check on my side
  50. 2:04really quickly.
  51. 2:17Let me pull this up.
  52. 2:21Awesome. Thank you. Cool. Um, yeah. So,
  53. 2:23that's exactly where um, you know, we we
  54. 2:25see most people kind of start coming to
  55. 2:27Langmith is is when Okay, cool. I just
  56. 2:30got the results. So, it looks like the
  57. 2:31majority are still looking to scale
  58. 2:33agents in production. Um, and we're
  59. 2:35seeing that there are a lot of different
  60. 2:37people in this kind of phase. um and
  61. 2:39still kind of also piloting different AI
  62. 2:41initiatives and trying to figure out
  63. 2:42where to use agents. Um this is exactly
  64. 2:45where LinkSmith can come into play and
  65. 2:46help you build reliable agents. Um so
  66. 2:50building with AI is a little bit
  67. 2:52different than our traditional software
  68. 2:54engineering workflow, right? Um
  69. 2:56traditionally if you're building in
  70. 2:57software, you would have very
  71. 2:58deterministic code that you could see it
  72. 3:00whether it compiles or not. Um and
  73. 3:02that's pretty pretty easy to determine
  74. 3:05um if your code is going to work or not.
  75. 3:07with LLMs, we started to see more
  76. 3:09constrained apps, right? So, we have
  77. 3:11like one LLM call, like a one-time call
  78. 3:14with with just that context of that
  79. 3:16particular LLM run. Um, and that has
  80. 3:18been probably the most common way that
  81. 3:20we see people get started with LMS is
  82. 3:22just like some some generation or some
  83. 3:25sort of like filling out of a of a
  84. 3:26document or something like that on
  85. 3:28behalf of the u user. So, those are kind
  86. 3:31of fuzzier. Um, they're still kind of
  87. 3:33easy to see if they're working or not.
  88. 3:35you know, you'll see like a a an error
  89. 3:37if it doesn't run properly, things like
  90. 3:38that. Um, as we get into agents, this is
  91. 3:41where the really interesting um portions
  92. 3:45of evaluating and building with AI and
  93. 3:48where things really start to differ from
  94. 3:50traditional software with agents. Um,
  95. 3:52the majority of our logic will now live
  96. 3:54in our agents reasoning. So, um, if an
  97. 3:57error happens, if things like that
  98. 3:59happen, we can't really go into a stack
  99. 4:01trace and see what happened. um or we
  100. 4:02can't look at our code and and try and
  101. 4:04figure out where in our logic there's
  102. 4:06something wrong. We need to kind of be
  103. 4:08able to dig into what's going on with
  104. 4:10our agents. So, it's really important to
  105. 4:12be able to have the observability to go
  106. 4:14in and start to evaluate our agents. And
  107. 4:16this is one of the core things of of
  108. 4:18Langmith and one of the core things that
  109. 4:20we've seen building a lot of agents with
  110. 4:22different enterprises is your agent uh
  111. 4:24your agents and app logic no longer
  112. 4:26lives fully in code. there's kind of
  113. 4:28this like uh different space within the
  114. 4:30agents own logic that these things
  115. 4:32happen.
  116. 4:34Cool. So on to um Langmith itself. So
  117. 4:37Langmith allows us to basically turn
  118. 4:40these traces that we get from our agents
  119. 4:43into um a systematic improvement or what
  120. 4:46we refer to as a flywheel. Um and this
  121. 4:48is done using our agent engineering
  122. 4:50platform. So the idea is is that we
  123. 4:52start to observe our agents in
  124. 4:54production using our tracing and
  125. 4:55monitoring features. we can then start
  126. 4:57to evaluate them and curate data sets
  127. 5:00based on um that production data. From
  128. 5:03there, we can then redeploy our agent or
  129. 5:05deploy it for the first time using
  130. 5:06deployments um and then kind of continue
  131. 5:08on in this flywheel. So, we're going to
  132. 5:10go through all of these in high levels.
  133. 5:12So, I'm excited to kind of jump into
  134. 5:13them. So, um let's go ahead and do that.
  135. 5:19Great. So, [clears throat]
  136. 5:21here we are in Langmith. We're in a
  137. 5:23little uh demo workspace that we have
  138. 5:25here. And LinkSmith is a really good way
  139. 5:28to be able to understand what your
  140. 5:30agents are doing. So on the far left,
  141. 5:33you'll see tracing, monitoring, data
  142. 5:34sets, etc. What we'll do first is um you
  143. 5:38know, see how we can set up tracing. So
  144. 5:40if you click here on this tracing quick
  145. 5:42start, you'll see that um with Langchain
  146. 5:44and Langraphph, our open source
  147. 5:46frameworks, it's really easy to get
  148. 5:47started with tracing. Um, all you need
  149. 5:49to do is set these environment variables
  150. 5:51here and everything's ready to go.
  151. 5:53Additionally, we have integrations with
  152. 5:55all of these different popular
  153. 5:56frameworks. So, if I click here in our
  154. 5:58docs, you'll see we have, you know, all
  155. 6:00of the most popular agent frameworks out
  156. 6:02there um for easy setup and easy
  157. 6:05tracing. Additionally, you can manually
  158. 6:07instrument um your code as well in
  159. 6:10Python and TypeScript. And we also if I
  160. 6:13go back to our integrations um we do
  161. 6:16have the ability to trace with open
  162. 6:18telemetry as well. So this is another
  163. 6:19popular option that we see.
  164. 6:22Cool. So that's how we can set up
  165. 6:24tracing on an existing agent. Um one of
  166. 6:27the agents that I really like to demo is
  167. 6:29called chat lang chain. So anyone can go
  168. 6:31to this today. Chat lang chain is fully
  169. 6:34open to the public. Um and I can select
  170. 6:36a different model to use. Let's just use
  171. 6:38uh a fast model here. And I can say how
  172. 6:40do I use lang to improve my agents.
  173. 6:46Cool. So um chat lang chain is built
  174. 6:49actually um with lang chain and lang
  175. 6:51graph. It is all plugged into lang. So
  176. 6:53all of the tracing and observability
  177. 6:54that we'll see today. And then lastly we
  178. 6:56have the ability to deploy on lang. So
  179. 6:59it is actually also deployed on
  180. 7:00linksmith. So we can see here that it's
  181. 7:02giving us a nice trace on the agent's
  182. 7:05performance and that looks like it did a
  183. 7:07great job. So this is just a demo of
  184. 7:09what this agent does. Now to kind of get
  185. 7:11into the logic of what just happened is
  186. 7:13I can jump into our tracing projects
  187. 7:15here. I can filter down on just chat
  188. 7:18lang chain as an application and we can
  189. 7:20see just the resources associated with
  190. 7:22chat lang chain and then from there I
  191. 7:24can open up our actual project.
  192. 7:28Great. So you'll see in the last day or
  193. 7:30so. So we're we're filtering by the last
  194. 7:31day. I can see the last 6,000 runs here.
  195. 7:34Um in the past day I can also like set a
  196. 7:37different time period. So I can go to
  197. 7:38last week and I can look at traces from
  198. 7:40last week if I wanted to and start to
  199. 7:42understand how our agent is performing
  200. 7:43then. Um and we can pop open any one of
  201. 7:46these traces. So I could pop this open
  202. 7:49and we can see exactly how this agent
  203. 7:51works. So on the far left side in the
  204. 7:53tracing view um we'll be able to see the
  205. 7:55different steps that our agent has taken
  206. 7:57and you'll see here that you know the
  207. 7:58first step is we jump into this
  208. 8:00guardrail here. It then goes to this
  209. 8:02guardrail LLM call and anytime we make
  210. 8:04an LM call we can see the system prompt.
  211. 8:07We can see the tools I had access to. So
  212. 8:09we can see this is a pretty basic
  213. 8:10guardrail. It just basic just just
  214. 8:12checks like is this question related to
  215. 8:14lane chain or langraph and this allows
  216. 8:15us to gate our actual agent from you
  217. 8:17know malicious queries or prompt
  218. 8:19injection things like that. So this is
  219. 8:21actually built into the architecture of
  220. 8:22our agent and then from there it
  221. 8:24responds with whether the decision is
  222. 8:26allowed or rejected. It then continues
  223. 8:28into this model tool calling loop. So
  224. 8:30this is a simple like reason and action
  225. 8:32style agent right? So it has access to a
  226. 8:34few different um has access to a few
  227. 8:37different tools. So if I jump into this
  228. 8:39LM call, we can see it can search our
  229. 8:41docs, it can search support articles,
  230. 8:43check links, etc. We have a nice system
  231. 8:45prompt here and our agent decided to
  232. 8:47call two tools and then it finally
  233. 8:50responded back to the user. So we can
  234. 8:51see that full context gets sent to our
  235. 8:54LLM here and it finally responds. If I
  236. 8:57click on output here, we can see the
  237. 8:59update and right here is the full
  238. 9:01response. So this is really nice to be
  239. 9:03able to debug our agents. We can also
  240. 9:05jump into a waterfall view and we can
  241. 9:07see um related to latency uh kind of how
  242. 9:10all of these steps took place and it's
  243. 9:12really nice to be able to see all of
  244. 9:14these happen. Um and we can see for
  245. 9:16example these tools were executed in
  246. 9:17parallel and we can see that that
  247. 9:19drastically reduced the latency of our
  248. 9:21agent. So that's really nice. Um one
  249. 9:24thing that we have inside of Langmith as
  250. 9:27well is Pauly. So on the far right side
  251. 9:29we'll see Paulie is here. I can ask
  252. 9:32Pauly any question. So Polly can help
  253. 9:34you filter things. It can answer
  254. 9:35questions you have related to Langmith.
  255. 9:37Um it can show you recent errors, things
  256. 9:39like that. But I can ask Pauly to filter
  257. 9:41down
  258. 9:43on runs from the past two days.
  259. 9:51Poly will always have the context of the
  260. 9:54pages that you're on. So it's able to
  261. 9:56see what page you're on and it's able to
  262. 9:57just show you. For example, I asked it
  263. 9:59to show me the runs and the runs would
  264. 10:00show us all the intermediate steps. I
  265. 10:02can switch it back to traces and we can
  266. 10:04see all the traces from the past two
  267. 10:07days. So this is a great way to interact
  268. 10:09with our agents.
  269. 10:11Cool. So [clears throat] one other thing
  270. 10:13that we can do is view our traces in a
  271. 10:15thread style view.
  272. 10:17So threads um you can think of as like
  273. 10:19full conversations. So if I continue
  274. 10:21this conversation here and say like hi,
  275. 10:23you can see that we're going to kind of
  276. 10:25continue on to a second turn of the
  277. 10:26conversation.
  278. 10:28It can be really useful to see how your
  279. 10:29agent performs over multiple turns of a
  280. 10:32conversation. So what we can do in this
  281. 10:34thread view is pop any one of these open
  282. 10:36and we can see sort of the back and
  283. 10:38forth between our user and our agent and
  284. 10:40we can see all of these different steps.
  285. 10:42I can switch to a trace view again and I
  286. 10:45can go to like step nine or sorry turn
  287. 10:47nine. So this is like the ninth back and
  288. 10:49forth that our user and our agent is at.
  289. 10:51And maybe our agent as that context
  290. 10:52window grows starts to struggle. So we
  291. 10:54can find traces and threads that are
  292. 10:56happening way down the conversation
  293. 10:58stream and see how it's performing as
  294. 11:00the context grows. So that can be very
  295. 11:03important as well.
  296. 11:05Awesome. So um we covered how we can get
  297. 11:07traces into Langmith and filter on them
  298. 11:10and and debug um exactly what's going on
  299. 11:12our agent using poly and being able to
  300. 11:14look at different things. We've seen the
  301. 11:15thread view. Um next, how can we like
  302. 11:18start to automate this and see how we
  303. 11:20can evalu?
  304. 11:23This is what we refer to as online
  305. 11:25evaluators. We also have offline
  306. 11:26evaluators which we'll get to when we
  307. 11:28get to data sets and experiments and how
  308. 11:29we can test and improve our agents. Um
  309. 11:32but essentially these online evaluators
  310. 11:34will allow us to observe our production
  311. 11:35agents and calculate how they're
  312. 11:37performing. So one of the things that we
  313. 11:40can do here is um so I see a question
  314. 11:43here about the option to eval sub agents
  315. 11:45which are using tools and skills on
  316. 11:47their own decisions and demand. So yeah,
  317. 11:49we can absolutely eval sub agents and
  318. 11:51full endto-end agents. There's there's a
  319. 11:53variety of different eval strategies
  320. 11:55that you can explore inside of Langmith.
  321. 11:58Um, one of the ways that we can set
  322. 12:00these up is on the top right. I can
  323. 12:02click new. Under new, you'll see this
  324. 12:04new evaluator button. And then you'll
  325. 12:06see we have a variety of different
  326. 12:07options for eval um for our tracing
  327. 12:10project. I can either do LLM as a judge,
  328. 12:12I can um create one from scratch, or I
  329. 12:16can create an LM as a judge from one of
  330. 12:17these pre-builts. I can also use a
  331. 12:20custom code evaluator um for more
  332. 12:21deterministic type uh queries. And then
  333. 12:23we also have the ability to evaluate a
  334. 12:25full thread. So that is really helpful
  335. 12:27for being able to determine how our
  336. 12:29agents performing over full conversation
  337. 12:31and is a pretty unique feature to
  338. 12:33Langmith. So to show you how to set one
  339. 12:35of these up, I'll show you one that's
  340. 12:36already created. So, for example, we
  341. 12:38have this kind of more simplistic
  342. 12:39helpfulness one that I think does a good
  343. 12:41job of demonstrating this. Um, when we
  344. 12:45set up our eval, we'll set up a name for
  345. 12:47it. We can set up a sampling rate, you
  346. 12:50know, from one to 100% of the traces.
  347. 12:52I'm going to leave it at 10%. Um, and
  348. 12:54this just helps control cost. So,
  349. 12:56what'll happen is as these traces flow
  350. 12:57into Linksmith, we can set a sampling
  351. 12:59rate for, you know, a random sampling
  352. 13:01rate to send these traces off to be
  353. 13:02evaluated.
  354. 13:04From there, we can filter down on
  355. 13:06different runs. So, the default for your
  356. 13:08evaluators is going to evaluate the
  357. 13:10entire run. Um, you asked about
  358. 13:12evaluating sub aents and things like
  359. 13:14that. I could remove this and I could go
  360. 13:16into a run name and I could say I just
  361. 13:18want to evaluate my guardrail, for
  362. 13:19example. We could do that. And now we're
  363. 13:22only going to be filtering down on the
  364. 13:24runs for our guardrail. You could do the
  365. 13:26exact same with a sub aent um and be
  366. 13:28able to evaluate just those sub aents as
  367. 13:30well. Um, but I'll leave this on is
  368. 13:32trace, which means is it an endto-end
  369. 13:34trace.
  370. 13:36Um, from there, what we can do is
  371. 13:38actually set up this eval. So, this is
  372. 13:39an LM as a judge. So, I do need to bring
  373. 13:41an LLM into the into the picture. Um, so
  374. 13:44in Langmith, we can set an API key um
  375. 13:47and use any one of our providers that
  376. 13:49we'd like to use. So, we have all the
  377. 13:51popular model providers here. We have
  378. 13:53cloud providers here as well, including
  379. 13:55Azure, Google, and Bedrock. And then we
  380. 13:57also can bring in custom models via
  381. 13:59OpenAI compliant endpoints. So we just
  382. 14:01need to make sure that they're OpenAI
  383. 14:02compatible and we're able to bring in
  384. 14:04any custom models as well. So um I'm
  385. 14:06going to leave this on GBT5 Nano for
  386. 14:08now.
  387. 14:10From there we can set up a system
  388. 14:11prompt. So we can say you're an expert
  389. 14:13um evaluator assessing how helpful a
  390. 14:16chat's response can be. So this is
  391. 14:18basically going to score on a 1 to 10
  392. 14:20how helpful our agent was for our user.
  393. 14:23From there we will pass in the original
  394. 14:25user's message. So all we're doing here
  395. 14:27is injecting in a variable and and
  396. 14:29finding that original user's message
  397. 14:31which you can see highlighted here. And
  398. 14:33then we'll grab the last message from
  399. 14:34our AI or from our agent. So we'll send
  400. 14:36those off to be evaluated. We can then
  401. 14:38set a feedback kind of configuration. So
  402. 14:41we can say on a scale of 1 to 10. I
  403. 14:43could also say boolean or I could even
  404. 14:45make it categorical if I wanted it to
  405. 14:47dump it into different categories as
  406. 14:48well.
  407. 14:51Great. So once that is set up, all of
  408. 14:53these traces will start going through.
  409. 14:56And the other thing that we can do is we
  410. 14:59can also set up a multi-turn evaluator.
  411. 15:02So the way that this will work is kind
  412. 15:04of same thing. We'll hit that add new.
  413. 15:06And I'll show you one that's already set
  414. 15:07up. So this one we're going to be trying
  415. 15:10to see if our agent actually
  416. 15:11accomplished the task that our user
  417. 15:13initially set out to do. And the way
  418. 15:15that we'll do that is again we can set a
  419. 15:16sampling rate. But what's a little bit
  420. 15:18different about these thread evaluators
  421. 15:20is we can set a thread idle time here.
  422. 15:22So this will be how long we'll wait
  423. 15:23until the last user message to mark a
  424. 15:26thread as completed. So for chat lang
  425. 15:28chain we have it set to an hour. I can
  426. 15:30also set it to a day. I can set it to 7
  427. 15:31days however you might have won.
  428. 15:34From there I can go ahead and you know
  429. 15:37set up the same exact way that we set up
  430. 15:38the other elements as a judge a system
  431. 15:40prompt a human message. But what's
  432. 15:42really nice and and kind of like a
  433. 15:44really nice DevX here is that we can
  434. 15:46basically select which messages we want
  435. 15:48to pass to this evaluator. So I can grab
  436. 15:51all the messages and that would include
  437. 15:52all of the intermediary tool messages,
  438. 15:55sub aent calls, etc. Um, but that might
  439. 15:57be a little bit noisy and a little bit
  440. 15:58too much context to send an LM as a
  441. 16:00judge. So I can actually just grab out
  442. 16:02the human and AI pairs, which will be
  443. 16:04the human messages, the final AI
  444. 16:07response, the human message, the final
  445. 16:08AI response. So, it's just going to be
  446. 16:09the back and forth between the user and
  447. 16:11the agent. And that'll kind of map to
  448. 16:12what you see here in the UI, right? Like
  449. 16:14what the user experiences here.
  450. 16:16So, we can go ahead and do that. And
  451. 16:18then we can set a boolean of whether
  452. 16:20this user's issue was resolved over the
  453. 16:22course of the conversation. So, this can
  454. 16:24be a great way to evaluate how your
  455. 16:25agent's performing. When you think about
  456. 16:27how agents work in the wild, a lot of
  457. 16:28times they'll they'll generate responses
  458. 16:30that look semantically correct, but the
  459. 16:32user might immediately after be like,
  460. 16:33"No, that's wrong." Or, "No, I tried
  461. 16:35that and that didn't actually work." Um,
  462. 16:36so it's good to see over the course of a
  463. 16:38conversation if the agent is actually
  464. 16:39able to accomplish the goal.
  465. 16:43Awesome. So that is online evals um in
  466. 16:46the context of LLM as a judge and thread
  467. 16:48level evals. You can also do custom
  468. 16:49code. Um I'll kind of skip over that
  469. 16:52today just to make sure we cover all of
  470. 16:53the different topics we're looking to
  471. 16:54cover. But essentially we could just
  472. 16:56write custom code that will run in a
  473. 16:57sandbox. Um it can't make external
  474. 16:59requests. So it's just more for like
  475. 17:01deterministic things that you're trying
  476. 17:02to evaluate. So we have one that checks
  477. 17:04for example if lang chain products are
  478. 17:06mentioned using code and it just looks
  479. 17:08for strings. Um cool. So when these
  480. 17:10evaluators run they're actually going to
  481. 17:12write feedback either on threads or on
  482. 17:14the runs. So if it's a normal element as
  483. 17:15judge it's going to write to our runs.
  484. 17:17We can actually filter down and find
  485. 17:19traces that this happened. So here we
  486. 17:22are. We can go into this LM as a judge
  487. 17:24or sorry we can go into this tracing
  488. 17:26project and you can see I have a
  489. 17:27pre-made view for helpful traces. And
  490. 17:30all this does here is it's going to
  491. 17:31filter down on feedback scores where the
  492. 17:34key for helpfulness is greater than or
  493. 17:36equal to eight. So now we have all of
  494. 17:38these traces that got high helpfulness
  495. 17:40scores. And I can pop any one of these
  496. 17:42open and we can see, you know, this one
  497. 17:44got a score of nine. I can open this up
  498. 17:47further and we can see the reasoning as
  499. 17:48to why it got a nine. So our our LM as a
  500. 17:51judge will also include reasoning as
  501. 17:52well. So that's really helpful. Um, so
  502. 17:55that's how we can kind of find all of
  503. 17:56these traces and start to see what's
  504. 17:58going on here.
  505. 18:00Great. Um, I'll talk in a little bit how
  506. 18:02we can use automations to actually
  507. 18:04automate this process of of grabbing
  508. 18:05these traces and sending them to more
  509. 18:07interesting places. But, uh, before I
  510. 18:09jump into that, um, I do want to show
  511. 18:11you insights really quickly. And
  512. 18:13insights are going to be how we can
  513. 18:14start to understand how our agents are
  514. 18:17performing. Once you start getting, you
  515. 18:18know, hundreds or or thousands of traces
  516. 18:20and you're trying to um essentially
  517. 18:23ensure that your agent is going to be
  518. 18:25performing as you want it to and you can
  519. 18:27find these edge cases. You can find
  520. 18:29different ways that users are using your
  521. 18:31agents. As anyone that has worked in
  522. 18:32software or product knows, people tend
  523. 18:34to use your your agents or your products
  524. 18:36in ways that you don't intend. So, it's
  525. 18:37really helpful to be able to find those
  526. 18:39um in real time. So, we have a few
  527. 18:41different examples of insights reports
  528. 18:43here that we've ran. To create a new
  529. 18:45one, you just go up here in the top
  530. 18:46right and we'll click new insights
  531. 18:48report. And you can do this manually
  532. 18:51where you'll kind of go through and set
  533. 18:52all these different things. Um, we also
  534. 18:54have an auto setup where you just start
  535. 18:56chatting with um, our insights agent and
  536. 18:58it will basically configure this
  537. 19:00insights job for you. But essentially
  538. 19:02what's going to happen is our agent is
  539. 19:04going to go through and cluster and
  540. 19:06categorize all of these traces depending
  541. 19:08on what you're trying to find out. So,
  542. 19:09if you're trying to find failure modes,
  543. 19:11it's going to find all of the traces
  544. 19:12that your agent made uh mistakes and
  545. 19:14start to cluster those together into
  546. 19:16different categories. So, you can see
  547. 19:18what types of questions are leading to
  548. 19:19the most errors. Um, if you're doing
  549. 19:21like a broad usage pattern one, it'll
  550. 19:23show you all the different ways that
  551. 19:24people are using your agent. Um, so
  552. 19:26that's kind of up to you how you want to
  553. 19:27categorize things or have your agent
  554. 19:29analyze them, but you can also include
  555. 19:31attributes alongside your insights that
  556. 19:33will help you um parse through all of
  557. 19:35this data. So, it'll basically just like
  558. 19:36an online evaluator, it'll show you
  559. 19:38these different metrics related to these
  560. 19:40clusters or these categories. And that
  561. 19:42might sound a little confusing. Um, but
  562. 19:44let me switch over into one of these
  563. 19:46that has already ran so we can kind of
  564. 19:48see what this looks like. So, you can
  565. 19:49see we have these kind of three that
  566. 19:51run. Um, you can set a schedule if you
  567. 19:53want. You'll be able to see the
  568. 19:55distribution over time. So, it's going
  569. 19:57to go ahead and start categorizing
  570. 19:59things for us. So we can see here that
  571. 20:01um we are basically trying to identify
  572. 20:04how people use chat lang chain and I
  573. 20:06wanted to put these top level categories
  574. 20:08for it to cluster them into. So um we
  575. 20:10asked it to categorize it into lang
  576. 20:12chain, langraph, lang and deep agents. I
  577. 20:15can also um not put any categories and
  578. 20:18it will automatically create those
  579. 20:19clusters. So if I go to like Q&A topics
  580. 20:21for example, it just came up with these
  581. 20:23categories on its own as it was
  582. 20:25summarizing and grouping together these
  583. 20:27these different um categories. Uh so
  584. 20:30that's that's essentially how the deep
  585. 20:32or sorry how the insights agent will
  586. 20:33work. So if I go back to this usage
  587. 20:35pattern one, you see that it starts to
  588. 20:36give us insights on all of this data
  589. 20:38that it's analyzed and summarized. So
  590. 20:39this is like over thousands of traces.
  591. 20:41It's gone through and seen how people
  592. 20:42are using um chat link chain and it's
  593. 20:45saying you know people that are chatting
  594. 20:46with chat link chain are building
  595. 20:48production agents not prototypes. Rag
  596. 20:50still dominates around 30% of the the
  597. 20:52usage in terms of how people are asking
  598. 20:54chat link chain questions. Um and people
  599. 20:57are having some issues with some growing
  600. 20:58pains with the ecosystem. So that's
  601. 20:59helpful to know. Um and we can see the
  602. 21:01distribution between two different runs.
  603. 21:03So this happened on March 1st. This
  604. 21:05happened on March 8th. We can see kind
  605. 21:07of how things are changing over time and
  606. 21:08how people are asking different
  607. 21:09questions. Um and if I jump into one of
  608. 21:12these clusters here, so I can go into
  609. 21:15here. We can see what questions people
  610. 21:17are asking about link chain versus link
  611. 21:18graph versus deep agents. So these are
  612. 21:20all our open source packages and then
  613. 21:23also in langmmith. So what are people
  614. 21:24asking about linksmith and I could dive
  615. 21:26into any one of these uh subcategories
  616. 21:28here. We can see summaries of these
  617. 21:30different traces. I can also look at
  618. 21:31these individual traces one by one as
  619. 21:33well. So very very helpful for
  620. 21:36understanding your agents performance.
  621. 21:37And one little anecdote here of how
  622. 21:39we've used this um actually at Langshade
  623. 21:42is for chat lang chain when we released
  624. 21:44our deep agent package which is our um
  625. 21:46open- source agent harness uh very
  626. 21:48similar to like claude code or agents
  627. 21:50like manis um we were really excited
  628. 21:52about it we released it we blasted on
  629. 21:54socials and then people went to chat
  630. 21:55lang chain to ask how to build with deep
  631. 21:57agents um but we had failed to update
  632. 21:59that guardrail that you saw earlier so
  633. 22:01everyone was asking about deep agents
  634. 22:02and they were getting blocked by our
  635. 22:03guardrail so we saw a big big um kind of
  636. 22:06issue or error analysis or failure mode
  637. 22:08under deep agents and we were able to
  638. 22:10identify that very quickly and find out
  639. 22:12that oh it was just our guardrail that
  640. 22:14was off. Everything else is fine. We
  641. 22:16really quickly update our guardrail
  642. 22:17prompt and everything kind of continued
  643. 22:19without a hitch. So really helpful to
  644. 22:21identify those edge cases that you may
  645. 22:23not consider or may forget to update
  646. 22:24when you're building your agents.
  647. 22:28Great. So that is our that is our um
  648. 22:32insights agent. So I talked earlier
  649. 22:35about how when we have feedback that's
  650. 22:37written to traces, how we can filter
  651. 22:38down on these here. The really nice
  652. 22:41thing about Langmith is, you know, when
  653. 22:43you have all of this data being
  654. 22:44collected, it's it's not really the best
  655. 22:46thing in the world to come in and filter
  656. 22:48on these and then grab them and then
  657. 22:49maybe add them to a data set or
  658. 22:51something like that. So what we can do
  659. 22:52in Langsmith is we can set up
  660. 22:54automations.
  661. 22:56So in this plus button on the top right,
  662. 22:57same place as the evals and the insights
  663. 23:00report, we can set up a new evaluator.
  664. 23:02So these new evaluators will allow you
  665. 23:04to automate that process for you. So for
  666. 23:07example, the helpful traces, if I open
  667. 23:09this up, I have some filters here where
  668. 23:12I'm filtering down where feedback for
  669. 23:14helpfulness is greater than or equal to
  670. 23:168. Um, so this is identifying, you know,
  671. 23:18traces that are getting either an 8 out
  672. 23:20of 10, 9 out of 10, or a 10 out of 10 on
  673. 23:22the helpfulness score evaluator. And I'm
  674. 23:24able to essentially filter down on those
  675. 23:27particular traces, set a sampling rate,
  676. 23:29and then I can do something with it. So
  677. 23:30I can automatically send that into an
  678. 23:32annotation queue which I'll show you in
  679. 23:33a moment. Um which is essentially a
  680. 23:35place for subject matter experts,
  681. 23:37product managers, etc. to to come in and
  682. 23:39review traces for you. We can also just
  683. 23:41add this directly to a data set if we
  684. 23:43wanted to. Um we could trigger web hooks
  685. 23:45to send it off to a different um
  686. 23:46different environment.
  687. 23:48So that's really helpful to be able to
  688. 23:50set up these. Um, the other thing that
  689. 23:52we can do is in chat lang chain here I
  690. 23:55do have the ability to collect feedback
  691. 23:57and this is a feature of lang
  692. 23:59deployments is with our built-in agent
  693. 24:01server you can get like thumbs up thumbs
  694. 24:03down um and collect feedback directly on
  695. 24:05the traces. So if I left a thumbs down
  696. 24:08um it might be a good indication that we
  697. 24:10should go and review that trace. So I
  698. 24:11can set up another automation that every
  699. 24:13time a user leaves a thumbs down, which
  700. 24:15would be a zero, I can actually send
  701. 24:17every one of those traces to a different
  702. 24:19annotation queue so that we can uncover
  703. 24:21why users are getting frustrated with
  704. 24:22our agent. So that's how we can set up
  705. 24:25automations. Um typically these will
  706. 24:27send to an annotation queue. So in these
  707. 24:29annotation cues, um this is an example
  708. 24:31one that we have here that is for that
  709. 24:33helpfulness score. So if it gets greater
  710. 24:34than or equal to 8 and we'll be able to
  711. 24:36see everything here on this um
  712. 24:38annotation queue for subject matter
  713. 24:40experts and PMs and people alike we can
  714. 24:43set up instructions for them. We can ask
  715. 24:45them to leave feedback on the traces. So
  716. 24:47whether it was correct or not. They can
  717. 24:48also leave notes to each other. So I
  718. 24:50left a note to myself in this case. Um
  719. 24:52but you can see those here.
  720. 24:55Additionally, what's really nice about
  721. 24:56this annotation cue is as a reviewer, I
  722. 25:00might have way more context of what this
  723. 25:01agent should say in in reality, like the
  724. 25:04golden ground truth of what it should
  725. 25:05say here. Um, and those can be very very
  726. 25:08valuable when you go to test your agent
  727. 25:10later on. Um, even if your agent made a
  728. 25:12mistake, it's helpful to correct that
  729. 25:13mistake and save that as part of your
  730. 25:15data set to give it a hill to climb as
  731. 25:17you start to try and improve your agent.
  732. 25:18Um, and we'll talk about that in a
  733. 25:20moment as well. But what I can do is I
  734. 25:22can start to remove these. So, let's
  735. 25:24just remove these intermediary messages
  736. 25:26because, you know, I don't want to cloud
  737. 25:27the final output um with all of these
  738. 25:29different tool calls and intermediary
  739. 25:31messages. So, I can remove some of
  740. 25:33those. Now, we arrive at the final
  741. 25:35message. So, we have the original human
  742. 25:36message from chat lang chain and the
  743. 25:38final AI message that our agent made. I
  744. 25:40can hit edit here and I can start to
  745. 25:42clean this up. So, maybe I don't want
  746. 25:44chat lang chain to actually ever provide
  747. 25:46code. I just want it to link to the
  748. 25:47appropriate docs when relevant. So, I
  749. 25:49can go ahead and grab all of this code.
  750. 25:52I can delete it [clears throat] and I
  751. 25:54can go ahead and hit save. And now we
  752. 25:56just have a nice response that is just
  753. 25:57going to link uh kind of broadly explain
  754. 25:59the topics and then link to the relevant
  755. 26:01docs. So once that's done, I can go
  756. 26:03ahead and hit add to data set and we can
  757. 26:05add that to a data set for further
  758. 26:06testing. So I have this chat lane chain
  759. 26:08golden data set and I can go ahead and
  760. 26:10add it to that. Once that gets added,
  761. 26:12we'll see it in this data sets and
  762. 26:14experiments. So right here I have this
  763. 26:16chat chain golden data set and you'll
  764. 26:19see here we have a bunch of examples
  765. 26:21that are stored. We have around 10 in
  766. 26:22this demo data set. I typically
  767. 26:24recommend anywhere from like 50 to 100
  768. 26:27um once you're kind of actually trying
  769. 26:29to improve your agent and get some good
  770. 26:31data on it. And you'll want to have um
  771. 26:33you'll want to have data in your data
  772. 26:35set that's on both ends of the spectrum.
  773. 26:36So, kind of examples that are, you know,
  774. 26:39tried and true that your agent should
  775. 26:40always be able to answer and then
  776. 26:42questions that are kind of difficult,
  777. 26:43um, but you want your agent to be able
  778. 26:45to answer in the future. And you'll want
  779. 26:47to have those reference outputs mapped
  780. 26:48to exactly what you want your agent to
  781. 26:50say in the wild in production. So, we'll
  782. 26:52curate that data set of reference inputs
  783. 26:54and outputs and then we can start doing
  784. 26:56experiments. So, experiments are going
  785. 26:58to be offline eval.
  786. 27:01And there's a few different ways that we
  787. 27:02can do it. on the top right. We can
  788. 27:04either run these in playground and
  789. 27:05that's great for testing like a single
  790. 27:07step of your agent. We can also run them
  791. 27:09in lang studio which is you know
  792. 27:11available if you're using link chain and
  793. 27:13langraph. You can run a local server
  794. 27:15very very easily from our CLI and you
  795. 27:17can go ahead and test your agent in
  796. 27:19studio. The final is going to be running
  797. 27:21it via the SDK. So if I click run an SDK
  798. 27:25you'll see we have a small little guide
  799. 27:26here. Um basically you just need the
  800. 27:28langu client. You'll point to the data
  801. 27:30set by its name. Define whatever
  802. 27:33evaluators you want to run. So, similar
  803. 27:35to the ones that we set up in the UI,
  804. 27:36you can do these in code. Um, and you
  805. 27:38can actually set up very robust
  806. 27:40evaluators in code since you'll have
  807. 27:42access to, you know, any libraries you
  808. 27:43might want, things like that. And then
  809. 27:45from there, we'd use this evaluate
  810. 27:46function to evaluate and log all of
  811. 27:49these different um test cases against
  812. 27:52our new agent. So you'll use evaluate.
  813. 27:55You'll pass in your target function
  814. 27:56which would be your agent or your LLM
  815. 27:58application. Point to the data set by
  816. 28:00its name to find any of the evaluators
  817. 28:02and let that run.
  818. 28:05So the other thing that we can do um
  819. 28:07before I show you like an experiment is
  820. 28:08you know I showed you how you could set
  821. 28:09up an evaluator in code when you run
  822. 28:11that evaluate function. You can also set
  823. 28:13them up in your UI. So I have this code
  824. 28:15checker one that I created and it's
  825. 28:17essentially the same process that we saw
  826. 28:18with the evaluators on the tracing
  827. 28:20projects. um you just define it in the
  828. 28:22UI. Um and what'll happen is once I have
  829. 28:25this defined here with my you know input
  830. 28:27output and reference output mappings
  831. 28:30what'll happen now is when I run these
  832. 28:32experiments here. So we see we ran a few
  833. 28:34different experiments it'll actually run
  834. 28:36that code checker no matter what. So you
  835. 28:38can have these like standardized
  836. 28:39evaluators on a data set that will run
  837. 28:40no matter what environment you run them
  838. 28:42in whether it's studio or playground or
  839. 28:44the SDK. So it can be a really nice way
  840. 28:46to kind of ensure that these certain
  841. 28:47evaluators run no matter what
  842. 28:49environment your team's running them in.
  843. 28:52Great. Um, so we see here that we wanted
  844. 28:55to test out chat lang chain against this
  845. 28:56golden data set and we wanted to
  846. 28:59basically try out four different models.
  847. 29:01We tried out haiku 45, GPT5 mini, GBT 52
  848. 29:05and sonnet 46 and I can kind of scroll
  849. 29:08over to the side here and we can see
  850. 29:10that we included metadata as to the
  851. 29:12provider we use, the model we use, etc.
  852. 29:14So it can be really easy to filter down
  853. 29:15on this later. So, it's always nice to
  854. 29:17include metadata so that you can kind of
  855. 29:19understand what different knobs you
  856. 29:21turned with your agents. And these
  857. 29:22experiments are going to be a great way
  858. 29:23to test out different um architectures,
  859. 29:26different prompts, different models, um
  860. 29:28anything that might be a change that you
  861. 29:30want to make in your agent and ensure
  862. 29:31that it actually improves your agent and
  863. 29:33doesn't cause any regressions. And one
  864. 29:35of the ways that we can do that is by
  865. 29:36setting a baseline, which is like a
  866. 29:37newer feature in Linksmith. So, we can
  867. 29:39set a baseline here. If I unset it,
  868. 29:41you'll see they all get kind of get
  869. 29:43mapped. But let's say I'm using um let's
  870. 29:45say I'm using Haiku 45 in production. I
  871. 29:48could go ahead and set that as the
  872. 29:49baseline. And then every time I run a
  873. 29:51new experiment, they'll all get compared
  874. 29:53to this baseline. So we can see, you
  875. 29:55know, every one of these more powerful
  876. 29:56models did a bit better than Haiku. Um
  877. 29:59but we can see like the latency went up
  878. 30:02um and the cost went up and things like
  879. 30:03that. So we can see these kind of side
  880. 30:05by side in this dashboard. But what I
  881. 30:07can also do is grab Haiku and I can grab
  882. 30:10let's say, you know, Sonnet looks the
  883. 30:11best to me. So I can go ahead and grab
  884. 30:13those two and I can go ahead and hit
  885. 30:15compare.
  886. 30:19So what's really great about this is,
  887. 30:20you know, I I'm looking at my traces.
  888. 30:22I'm trying to identify which one is best
  889. 30:23or sorry, looking at my experiments. I
  890. 30:25can actually go side by side and make a
  891. 30:27very nice comparison here. So we can
  892. 30:28see, you know, side by side which ones
  893. 30:31are doing better based on these
  894. 30:32different evaluators I set. So I set one
  895. 30:34related to accuracy, a code checker, um
  896. 30:36including docs if the if the docs that
  897. 30:38are included are relevant to the answer,
  898. 30:40faithfulness, which is essentially like
  899. 30:42hallucination. We can see latency
  900. 30:44metrics, we can see cost metrics, token
  901. 30:46count, etc. So we can see that um across
  902. 30:49the board it seems like Sonnet is a lot
  903. 30:51better um in terms of the way that it
  904. 30:53performed on those test cases. Um but
  905. 30:55the cost is nearly double. So this is
  906. 30:57one of those things that you might need
  907. 30:58to consider when you're building agents
  908. 30:59is like is it worth the improvement
  909. 31:01versus the cost and things of that
  910. 31:02nature. Um so that's essentially how we
  911. 31:04can use experiments. Um one thing I'll
  912. 31:06shout out here too is is Paulie is with
  913. 31:08you here as well. Um I can create a new
  914. 31:11thread here and I can ask it to ask uh
  915. 31:14what was the best experiment
  916. 31:18in your eyes.
  917. 31:21So, it's going to go ahead and look at
  918. 31:22our current data set and see if it's
  919. 31:24able to um basically evaluate that um
  920. 31:27and find the the best experiment. So, it
  921. 31:28says based on the experiments, Cloud 46
  922. 31:30looks like the strongest performer
  923. 31:32overall. GBDT5 mini came close but lag
  924. 31:34behind. So, that's really helpful. Uh
  925. 31:36Pauly could also suggest prompt
  926. 31:37improvements and things like that. Um
  927. 31:40but to show you that prompt improvement,
  928. 31:41what we can do is go into our prompt
  929. 31:43playground. So, I like to talk about the
  930. 31:46prompt playground in the context of a
  931. 31:48trace. Um, so if I go back into our
  932. 31:51tracing project here for chat lang
  933. 31:53chain,
  934. 31:57[clears throat and cough]
  935. 31:58we'll be able to see all of these traces
  936. 32:00flowing in. And again, I can filter
  937. 32:02down, you know, like last week or
  938. 32:03something like that. Um, and find these
  939. 32:06different relevant traces.
  940. 32:09And then in here, we'll be able to see
  941. 32:10any one of these LLM calls here. So we
  942. 32:12can see, you know, one, two, three
  943. 32:13different LM calls. Whenever I click on
  944. 32:16any run type that is the type of LLM, we
  945. 32:18can actually pull these directly into
  946. 32:20our prompt playground. And the reason
  947. 32:22why you might want to do this is you
  948. 32:23might notice a particular trace that
  949. 32:24your agent did poorly on. Maybe you
  950. 32:26filter down on one that it did poorly
  951. 32:27on. Um or maybe for this guardrail it,
  952. 32:29you know, it didn't allow something that
  953. 32:30it should have. We can come in here now
  954. 32:33and we can actually pull this prompt in
  955. 32:34with the context of the actual trace
  956. 32:36that we were looking at. So this pulled
  957. 32:38in the actual human message here where
  958. 32:40someone asked about custom middleware
  959. 32:42and it looks like it did well. It
  960. 32:43decided to allow I could also remove
  961. 32:45this and I could say what is the weather
  962. 32:48in SF.
  963. 32:51I could then you know just like those um
  964. 32:53online evals I can choose which model I
  965. 32:56want to use. So I could switch to
  966. 32:57entropic for example switch to a smaller
  967. 33:00model like haiku hit apply and I can
  968. 33:03give this a try again. So we see now
  969. 33:06because we have this output schema
  970. 33:07defined as decision um and it can either
  971. 33:10be approved or blocked. It's always
  972. 33:11going to either respond in approved or
  973. 33:13blocked. Um, and we see here that, you
  974. 33:15know, weather isn't being allowed, which
  975. 33:17is which is best. I I think that's a
  976. 33:18good idea that weather isn't allowed.
  977. 33:20One thing I can do is I can ask Poly to
  978. 33:22actually improve this prompt. So, I can
  979. 33:24go over here. I can click new thread and
  980. 33:26I can just say improve this prompt using
  981. 33:28best practices.
  982. 33:30What Poly will do here is it's going to
  983. 33:32use all of the best practices that we've
  984. 33:34seen from building a variety of
  985. 33:35different agents and working with
  986. 33:36different, you know, enterprises,
  987. 33:37startups, etc., and it's going to apply
  988. 33:40some of those best practices. So, um,
  989. 33:42one of those is being is most likely
  990. 33:44going to be using XML tags. So,
  991. 33:46typically, uh, XML tags are going to
  992. 33:48help your performance a lot. Um, the
  993. 33:50other is maybe some few shot examples,
  994. 33:52some positive examples of what it should
  995. 33:54or shouldn't. Um, and that'll really
  996. 33:56help improve the prompt over time. So,
  997. 33:58it might take Poly a bit to do this, so
  998. 34:00we'll see if it goes right away. Um,
  999. 34:03usually it takes like around a minute or
  1000. 34:04so to go through the whole prompt and
  1001. 34:06make all the updates. But, there we go.
  1002. 34:08So it added some XML tags here, added
  1003. 34:10some explicit context, some enhanced
  1004. 34:12clarity, some concrete examples. Um, and
  1005. 34:15this can really help us when we build
  1006. 34:17our agents.
  1007. 34:19Cool. Um, the next thing that we can do
  1008. 34:21is, you know, for whether it got
  1009. 34:22blocked, um, I can also like add in a
  1010. 34:25dynamic variable. So I could say, uh,
  1011. 34:27runtime allowed
  1012. 34:31topics and we could say, um, let's say
  1013. 34:35weather. And now it should go ahead and
  1014. 34:37allow it. So that allows us to like
  1015. 34:38dynamically inject in things that we
  1016. 34:40want. So typically you could inject in
  1017. 34:42things like memory or things like that
  1018. 34:43in your actual agent. So it can be very
  1019. 34:45[clears throat] helpful to to do that.
  1020. 34:47Um from there you can go ahead and hit
  1021. 34:48save and that'll save the prompt into
  1022. 34:50the prompt hub. Prompt hub is where you
  1023. 34:52get everything saved and versioned. So
  1024. 34:54this works as like a repo under the
  1025. 34:55hood. Um we'll see full commit
  1026. 34:57histories. We can then pull in our
  1027. 34:59prompts into our applications using our
  1028. 35:01Langmith client um in both Python and
  1029. 35:03TypeScript. And we would just use this
  1030. 35:05pull prompt method and define it by its
  1031. 35:07name and its commit ID here. So very
  1032. 35:10very helpful to be able to pull these
  1033. 35:11into our application.
  1034. 35:14All right. Um so that is a high level of
  1035. 35:17Langmith um observability eval um that
  1036. 35:20sort of thing. There's so much more to
  1037. 35:22Langmith as well including our
  1038. 35:23deployments product which makes it
  1039. 35:25really easy to deploy an agent in just a
  1040. 35:27few clicks here. You just point to a
  1041. 35:28repo, you set some environment variables
  1042. 35:30and that is it. you're ready to go and
  1043. 35:32deployed your your lang chain or lang
  1044. 35:34graph agents. We also have agent builder
  1045. 35:37here which is a no code way to build
  1046. 35:39your agents. Um and it is a very very
  1047. 35:42powerful tool. So that isn't in the
  1048. 35:43scope today but I like to mention them
  1049. 35:45since I think they're both fantastic
  1050. 35:46products. Um so that is pretty much it
  1051. 35:49for my presentation. Um I'll go ahead
  1052. 35:52and shift over to a Q&A now if there are
  1053. 35:55any questions. Um so I'll go through the
  1054. 35:58chat now. Let me get this pulled up.
  1055. 36:02and we can start to go. All right. So, I
  1056. 36:05see some questions. Um,
  1057. 36:08how can we use uh can Paul use whatever
  1058. 36:11LM we want? Can I have an a bedrock
  1059. 36:13configured to it? Um, that's a really
  1060. 36:14good question. So, in here, if I go into
  1061. 36:16our settings and I scroll down to
  1062. 36:19integrations, you'll see model
  1063. 36:20configurations. Um, and this is a new
  1064. 36:22feature that shipped recently. Um, as
  1065. 36:24admins, we can configure which models
  1066. 36:26are available to our users and
  1067. 36:28especially for things like poly
  1068. 36:29insights, etc. Um, and yes, we're able
  1069. 36:32to use, you know, any one of these cloud
  1070. 36:33providers. You can set those cloud
  1071. 36:35provider models here and then set that
  1072. 36:37as the default model for Poly, etc. So,
  1073. 36:39you have full ability to, um, do all
  1074. 36:42this configuration here and set it for
  1075. 36:43everyone in your workspace as well.
  1076. 36:46All right. Um, all right. So, let's see.
  1077. 36:51Can we use poly uh model thread? Yep. Uh
  1078. 36:56use some enterprise SAS application.
  1079. 37:00Sorry, let me make this a little bit
  1080. 37:01bigger. It's kind of small on my screen.
  1081. 37:04Okay, we use some enterprise SAS
  1082. 37:06applications. They have started offering
  1083. 37:07agentic capabilities within their
  1084. 37:09platform. Will Langmith be able to
  1085. 37:11integrate with and monitor such agents?
  1086. 37:13Um yes. I I think uh majority of of
  1087. 37:16these platforms that are offering agents
  1088. 37:18are exposing them in some way for us to
  1089. 37:20trace and monitor them. Um I would love
  1090. 37:23to hear which particular agents you're
  1091. 37:24you're talking about, but I know we have
  1092. 37:26integrations for example with cloud
  1093. 37:27code, cloud agents SDK, um you know, any
  1094. 37:31of those those popular ones. Uh Bedrock
  1095. 37:33agents, things like that um can trace
  1096. 37:36directly. Uh if there's any agents that
  1097. 37:38that you're using that you you don't see
  1098. 37:40an integration for in our docs page or
  1099. 37:41anything like that, please reach out. Um
  1100. 37:43I'm happy to help and see if there's any
  1101. 37:45way that we could get you um set up with
  1102. 37:47tracing there. Um let's see. Langmith be
  1103. 37:50able to integrate with and monitor such
  1104. 37:52agent. Oh, sorry that was a cut off. Uh
  1105. 37:55my problem is there's no way to know
  1106. 37:56ahead of time which sub agents my agents
  1107. 37:58will choose. Is there a way to give a
  1108. 37:59dynamic eval? Um yeah, so this is
  1109. 38:02something that I probably do off like on
  1110. 38:04my data sets and experiments and my
  1111. 38:06offline emails. So um we have a nice
  1112. 38:08guide on this. Um, so I can find it and
  1113. 38:12send it through.
  1114. 38:14Um, one moment. Um, but essentially you
  1115. 38:17can do what's called a trajectory
  1116. 38:18evaluation. And these trajectory
  1117. 38:20evaluations are going to be how we can
  1118. 38:22decide uh for different inputs if our
  1119. 38:25agent's going to choose the right sub
  1120. 38:26agent, if that sub aent is going to use
  1121. 38:28the right tools, etc. So like those
  1122. 38:30those can be very very important when
  1123. 38:32you're building out your agents is is
  1124. 38:34not only like looking at end toend tests
  1125. 38:36or you know what they're producing but
  1126. 38:39actually just monitoring the trajectory.
  1127. 38:41So you can actually just run evals on is
  1128. 38:43it calling the right agents in the
  1129. 38:44correct order things of that nature. So
  1130. 38:46there are the docs here on trajectory
  1131. 38:50evals.
  1132. 38:52Cool.
  1133. 38:54All right. Um,
  1134. 38:57how do you evaluate your LLM as a judge?
  1135. 38:59Evaluators are performing as as
  1136. 39:01expected. Uh, this is a great one
  1137. 39:03actually. We have a feature for this.
  1138. 39:05So, um, this is common issue that we see
  1139. 39:07people have. You can go into your
  1140. 39:09evaluators here. I can click new
  1141. 39:11evaluator either on a tracing project or
  1142. 39:14in an offline uh, you know, data set and
  1143. 39:16experiment. But if I wanted to create a
  1144. 39:18new evaluator and kind of make sure that
  1145. 39:20it's aligned to how I want it, we can
  1146. 39:22actually create it from labeled data.
  1147. 39:23And this will send us down what we refer
  1148. 39:25to as the align eval path. And basically
  1149. 39:27what'll happen is you'll select some
  1150. 39:29runs to annotate yourself. You will then
  1151. 39:32get sent into like a unique annotation
  1152. 39:34queue to annotate that data. So you know
  1153. 39:36you select like five to 10 runs or or 50
  1154. 39:38runs whatever you want. You then as a
  1155. 39:40user will you know for let's say I'm
  1156. 39:42doing uh helpfulness right or I'll just
  1157. 39:45say helpful.
  1158. 39:48And what I'll do is as I'm going through
  1159. 39:49I can say like this is helpful yes or no
  1160. 39:52for these like 10 traces. And then I can
  1161. 39:54start crafting a prompt for an LMS as a
  1162. 39:55judge. And we'll basically get to see if
  1163. 39:58our LM as a judge is aligned with our
  1164. 39:59preferences as a human or what we would
  1165. 40:01say as a human. So it's pretty pretty
  1166. 40:03important to um do that as well.
  1167. 40:07Great. Um how do I detect and measure
  1168. 40:08hallucinations? Um typically you would
  1169. 40:10want to in your ground truth have like
  1170. 40:11the documents or data set or the
  1171. 40:14documents that your agent is retrieving
  1172. 40:15or should reference. Um, and you can
  1173. 40:18check with your LMS judge if the final
  1174. 40:20response is grounded in the information
  1175. 40:21from those documents.
  1176. 40:24Um, cool. How do we budget costs
  1177. 40:26overall? Can we set thresholds? Um, yes.
  1178. 40:28So, you can set thresholds in the
  1179. 40:29settings. Um, it's pretty pretty
  1180. 40:31straightforward there. Is there a simple
  1181. 40:33way to evaluate tool call success
  1182. 40:35whether it was the right tool or in the
  1183. 40:36right sequence? Um, I think that would
  1184. 40:38go back to trajectory eval. Um, I would
  1185. 40:40probably do that. Uh, we have some
  1186. 40:42guides on that in the docs. Um, and some
  1187. 40:44notebooks for that as well. Um, from
  1188. 40:46Chase, where do we set the API key for
  1189. 40:48Bedrock? I tried in the provider secrets
  1190. 40:50and could not get it working. Um, you
  1191. 40:53might have some more luck if you go
  1192. 40:54directly into the playground and try and
  1193. 40:56hit um,
  1194. 40:58Bedrock here. It should ask you to do
  1195. 41:00these different things and then on the
  1196. 41:02top right there's like the secrets and
  1197. 41:03you can add all these different secrets.
  1198. 41:05Um, there's also like an IM ro so you
  1199. 41:07can set an IM ro um, in your AWS account
  1200. 41:09and that will basically get the
  1201. 41:11permissions to like refresh the tokens.
  1202. 41:13Um, so that should should work.
  1203. 41:16Um okay I don't understand how data set
  1204. 41:19is used in the links the ecosystem does
  1205. 41:22the idea is to use it as a retrieval
  1206. 41:24database to insert gold examples for a
  1207. 41:25few examples. Um no so I think uh I
  1208. 41:28think a good way of thinking about this
  1209. 41:29is like part of our agent engineering
  1210. 41:31flywheel. So the idea is you know we
  1211. 41:34have these traces flowing in right so
  1212. 41:36these are like production traces um and
  1213. 41:39we don't really have a way to compare
  1214. 41:42how our agent should perform versus how
  1215. 41:44it actually did perform. So the way that
  1216. 41:46we can do that is we can curate these
  1217. 41:47data sets of golden examples. So we have
  1218. 41:50you know all of these you know we have
  1219. 41:51these 10 examples. So for this given
  1220. 41:53input this is exactly what I want my
  1221. 41:54agent to say in the wild likely for this
  1222. 41:57one as well. So for this given input of
  1223. 41:59how to you know what is the linksmith
  1224. 42:01Python SDK equivalent to the runs
  1225. 42:02endpoint. So this is kind of a
  1226. 42:04complicated question. There's a lot of
  1227. 42:05different ways that it could go. So this
  1228. 42:07is the reference output of like once it
  1229. 42:09does all of its research and responds
  1230. 42:10back to the user. This is what I want it
  1231. 42:12to say and how I want it to say it. So
  1232. 42:14what we can do now is I can go and run
  1233. 42:17my production agent against all of these
  1234. 42:19examples and see if it's going to
  1235. 42:21perform well. Um and we can get a
  1236. 42:23baseline. So that's what we did here for
  1237. 42:25this haiku 45 is we got a baseline that
  1238. 42:28for a given input.
  1239. 42:31So this is the golden input. We
  1240. 42:33basically passed that into our
  1241. 42:34production agent using haiku45 and we
  1242. 42:36got this output here. And this output um
  1243. 42:39it looks you know decent to me and it
  1244. 42:42might look decent to an LLM as a judge
  1245. 42:44but the benefit of having this reference
  1246. 42:46output is now it knows exactly how it
  1247. 42:48should have responded. So we can have
  1248. 42:50different things like this code checker,
  1249. 42:52this accuracy checker on a scale of 1 to
  1250. 42:54five, uh answer relevance, things like
  1251. 42:56that. And we can see okay compared to
  1252. 42:58our reference output, how does this
  1253. 43:00output compare? Um and this is what
  1254. 43:02really helps us improve our agents and
  1255. 43:03start iterating. So we can see okay um
  1256. 43:06for example for accuracy it got a one um
  1257. 43:08because it made some factual errors.
  1258. 43:09It's it said that uh to use the langraph
  1259. 43:12SDK instead of the lang SDK um and
  1260. 43:15that's a pretty big like error that it
  1261. 43:16made here. So it should have defaulted
  1262. 43:18to using the linksmith SDK for querying
  1263. 43:20runs versus creating runs. Um and that
  1264. 43:23was kind of the issue there. So what the
  1265. 43:25benefit is is how we can start to
  1266. 43:27improve and start to create this this
  1267. 43:29whole holistic strategy of going through
  1268. 43:31and building out these agents um and
  1269. 43:33improving them over time. So now I can
  1270. 43:35do all of this offline testing outside
  1271. 43:36of my production environment. I could
  1272. 43:38figure out how I could improve my agent
  1273. 43:39to do better on these test cases and
  1274. 43:41then I could deploy a new version of
  1275. 43:43this agent into production that will
  1276. 43:45work a lot better. Um, I hope that was
  1277. 43:47helpful, Rodrigo.
  1278. 43:49Cool. Um, is there a simple way to
  1279. 43:51evaluate tool call success? So, I think
  1280. 43:53we just answered that a moment ago. Um,
  1281. 43:56blacklist, can we spec out what our
  1282. 43:57agents should not do? Um, good question.
  1283. 43:59I I I would probably put that in
  1284. 44:01prompting. Um, or you could also have
  1285. 44:03hooks. So, in your actual agent
  1286. 44:05architecture, and this is more on like
  1287. 44:06the agent building side rather than the
  1288. 44:08linksmith side. Um you could have hooks
  1289. 44:10in that process in the agent tool
  1290. 44:11calling loop that if it does a certain
  1291. 44:12thing you could kind of kick it out or
  1292. 44:14cancel the run or restart it or
  1293. 44:15something like that. Um so a lot of
  1294. 44:17people are doing that now with like
  1295. 44:18cloud code to ensure that it doesn't uh
  1296. 44:21do like destructive things. You can they
  1297. 44:23just recently added hooks which we have
  1298. 44:24in our deep agents package as well um
  1299. 44:26where you can just kind of like hook in
  1300. 44:27and and prevent any dangerous actions
  1301. 44:29from happening. Um
  1302. 44:33cool. Can you comment on a typical life
  1303. 44:35cycle strategies for developing high
  1304. 44:37quality evals plus graders prior to prod
  1305. 44:39approaches to online evals and how to um
  1306. 44:42how online evals inform refinement? Um
  1307. 44:46yeah, so this is a a great question in
  1308. 44:48terms of like the life cycle. Um
  1309. 44:51[clears throat] I think quality evals
  1310. 44:53and quality experiments like start with
  1311. 44:55great traces. So even if you're not in
  1312. 44:56prod um passing in a bunch of different
  1313. 44:59inputs into your agent and seeing how
  1314. 45:00it'll respond um is really helpful to
  1315. 45:03then have your graders go through change
  1316. 45:05that data annotate it in a way that it
  1317. 45:07should be and then adding that to the
  1318. 45:08data set for more for better
  1319. 45:10experimentation. I think like starting
  1320. 45:12with a example of what your agent has
  1321. 45:14already produced and then editing that
  1322. 45:16to where you want it to be is a bit
  1323. 45:18easier than trying to generate like
  1324. 45:19synthetic data which is what a lot of
  1325. 45:21people start with. Um, so I typically do
  1326. 45:23that even like for my own use cases when
  1327. 45:25I'm building agents. I'll just like come
  1328. 45:26up with, you know, 10 to 20 to 50 inputs
  1329. 45:29and I'll just pass them into my graph.
  1330. 45:31Um, and then or into my agent and then
  1331. 45:34from there I will, you know, use the
  1332. 45:35annotation Q, clean them up, put them at
  1333. 45:37exactly how I want them and then add
  1334. 45:38them to the data set cuz it's a little
  1335. 45:40bit easier than trying to like go
  1336. 45:42through and synthetically generate data
  1337. 45:43or have your your subject matter experts
  1338. 45:45generate them, things like that. Um, and
  1339. 45:47then on online eval side, I think these
  1340. 45:49are more like benchmarks rather than
  1341. 45:50ground truths. So I think your your data
  1342. 45:53sets and experiments are really where
  1343. 45:54you do all of your like ground truth
  1344. 45:56testing. Make sure your agent is at like
  1345. 45:58a point that you think it's ready for
  1346. 45:59production. And I view my online eval as
  1347. 46:02more of a way to monitor our agents as
  1348. 46:04they're in production. Um and one of the
  1349. 46:06ways that we can do that is if I go over
  1350. 46:07to this monitoring tab, we do get a
  1351. 46:10pre-built dashboard with every
  1352. 46:11deployment. So you'll see things related
  1353. 46:13to like your trace metrics, um your LLM
  1354. 46:15calls, like your latency, your cost,
  1355. 46:17etc. Um different tool calls your agents
  1356. 46:20are making. So you can see you know by
  1357. 46:21tool count which which tools are getting
  1358. 46:23called the most. You can see the latency
  1359. 46:25by tool as well which can be helpful. Um
  1360. 46:27and then the error rate as well. So we
  1361. 46:29can see like for example today um we
  1362. 46:31usually don't have any errors but we can
  1363. 46:32see today we're having like a 03% chance
  1364. 46:35or 03%
  1365. 46:38of the the time um our search docs is
  1366. 46:40hitting an error and that's an issue
  1367. 46:41with uh you know we use Mintifi's doc
  1368. 46:43server. So uh there might just be an
  1369. 46:45issue on the Mintify side that's causing
  1370. 46:46that. Um, we can see run types and then
  1371. 46:49we can also see these feedback scores.
  1372. 46:51So, you can see here like our
  1373. 46:52helpfulness score. We can see it over
  1374. 46:53this past seven days it's been, you
  1375. 46:55know, hovering around six or 7%. I know
  1376. 46:57if this like drops or spikes down,
  1377. 46:59there's something there's some kind of
  1378. 47:00issue with our agent. Um, same thing
  1379. 47:03with like task completion. We can see
  1380. 47:04that it's doing a good job of
  1381. 47:05accomplishing user tasks. If there's
  1382. 47:07like a big dip or a big drop, there
  1383. 47:08might be something wrong. So, yeah, it
  1384. 47:10can be really helpful to just like
  1385. 47:11monitor over time.
  1386. 47:15Um, cool. Um, how are annotation cues
  1387. 47:18surfaced to SMMES inside of LinkSmith or
  1388. 47:20can we surface them in another UI and
  1389. 47:22integrate? Um, yeah. So, uh, you can,
  1390. 47:24um, but typically you can go ahead and
  1391. 47:27start create a rule-based access um
  1392. 47:29through or rather through our rule-based
  1393. 47:31access control, you can create a role
  1394. 47:33that is specifically for the annotation
  1395. 47:35Q. So, you can have data reviewers come
  1396. 47:37in. Um, there's no like seat charges in
  1397. 47:40Langmith. It's all usage based ch like
  1398. 47:42billing. So, you don't have to worry
  1399. 47:43about like having too many seats
  1400. 47:44allocated or something. Um, but you can
  1401. 47:46have users that are just specifically
  1402. 47:48um, able to access like this annotation
  1403. 47:50queue in this particular workspace and
  1404. 47:52they're able to come in and access it.
  1405. 47:54Um, the other thing that you can do
  1406. 47:56which, um, I wish I actually had set up
  1407. 47:58um, that's actually a good idea to get
  1408. 48:00this set up on this demo workspace is
  1409. 48:01you can enable a custom output rendering
  1410. 48:03and that'll allow you to basically
  1411. 48:05iframe in your own front end. So if you
  1412. 48:07have like very unique traces where you
  1413. 48:09want to allow uh reviewers to like see
  1414. 48:11them in a particular format, you can
  1415. 48:13enable this like custom output rendering
  1416. 48:15which will allow you to see that in a
  1417. 48:17very unique way. So um I unfortunately
  1418. 48:19don't have a demo of that right now. But
  1419. 48:20yeah,
  1420. 48:25cool. Um so it looks like I'm being told
  1421. 48:28that is it. Um thank you for joining. Uh
  1422. 48:30I really hope this was helpful. Feel
  1423. 48:32free to reach out to me um on LinkedIn
  1424. 48:34or or you know contact afterwards. Um, I
  1425. 48:37think our team is going to kind of send
  1426. 48:38you to a different screen to to do those
  1427. 48:40things. But, um, I enjoyed this time
  1428. 48:42today. Thank you for all the great
  1429. 48:43questions and, uh, yeah, feel free to
  1430. 48:44reach out anytime. Thanks.

About this transcript

This page contains the full transcript of How to Debug, Evaluate, and Ship Reliable AI Agents with LangSmith by LangChain, generated from the public captions YouTube serves with the video. The transcript has 10,462 words across 1,430 segments, with the original timestamps preserved so you can click any line to jump to that moment in the embedded player.

What you can do with it

Use the transcript to take notes, quote the speaker, build a study guide, generate a summary with ChatGPT or Claude via the YouTube Summary tool, or export it as a timed subtitle file with YouTube to SRT. You can also re-open it in the transcriber to choose a caption track available on the video.

Free YouTube transcript tool

YouTube2Text is a free YouTube transcript generator — no signup, no daily limit. Paste any YouTube link and get the full transcript instantly, with timestamps, click-to-jump, caption language selection, AI prompts for ChatGPT, Claude, and Gemini, and exports to TXT, SRT, VTT, or Markdown.