YouTube2Text

How to Know If Your AI Agent Is Any Good: Evals With Phoenix & Claude — Laurie Voss, Arize AI — Transcript

by AI Engineer · 20,194 words · 2,896 segments · language en · Watch on YouTube

Full transcript

  1. 0:01[music]
  2. 0:12My name is Lauri Voss. I'm head of
  3. 0:14developer relations at Arise AI. Uh I
  4. 0:16used to do JavaScript at npm, Inc. way
  5. 0:18back in the day, so you may remember me
  6. 0:20from then. Uh but these days I think
  7. 0:22about AI applications and how to make
  8. 0:25them run and how to make them actually
  9. 0:26work. Um, I had this slide up for the 15
  10. 0:30minutes before. I hope you've seen it
  11. 0:32already. If not, now is the time to get
  12. 0:34started.
  13. 0:36Um, this is a moderately hands-on
  14. 0:40workshop. There's I've already built an
  15. 0:42agent for you. It's sitting there in
  16. 0:44that repo. Uh, you will get to play with
  17. 0:46the prompts and run actual evals. Um,
  18. 0:49but it's got checkpoints all the way
  19. 0:51through. So if you get lost, you can
  20. 0:53just switch to the right checkpoint and
  21. 0:55uh uh jump to the part where it's
  22. 0:58already working. Um you're going to need
  23. 1:01node 22 or later. All of this all of
  24. 1:03these examples are going to be in
  25. 1:04Typescript. Um because you know it's me,
  26. 1:08I'm going to use JavaScript if I can. Uh
  27. 1:11and uh you're going to be installing and
  28. 1:14running Phoenix on your own laptop. uh
  29. 1:17on conference Wi-Fi that can be a
  30. 1:19challenge, but I tried it this morning
  31. 1:20and it came through pretty quickly. So,
  32. 1:22uh UVX is magic. Um you're not going to
  33. 1:26need to run any Python in this thing.
  34. 1:27All of the Python is going to be run for
  35. 1:29you on your behalf by JavaScript, which
  36. 1:31is nice.
  37. 1:33Um I think that's it for the setup. Um
  38. 1:36so, what we're going to do today is um
  39. 1:42uh oh yeah, sorry, one more bit of
  40. 1:43setup. Once Phoenix is installed, uh you
  41. 1:46should open up your browser on localhost
  42. 1:48606 so that you can see what it looks
  43. 1:50like. Um it's going to be empty right
  44. 1:54now, but we are going to run the
  45. 1:56commands that will fill it with data.
  46. 1:58Um
  47. 2:01you will also need an anthropic key. All
  48. 2:03of my examples are using Claude. Uh you
  49. 2:07can do all of this stuff using any LLM
  50. 2:09provider in the world, but I had to pick
  51. 2:11an example, so I picked the one that I
  52. 2:12use every day. So, this one is using
  53. 2:14Claude. Um,
  54. 2:18who needs help with the setup? Show of
  55. 2:20hands. Just shout at me. It's fine.
  56. 2:25All right. So, the first 10. What's up?
  57. 2:31>> Just getting started.
  58. 2:33>> Okay, great.
  59. 2:35>> Yeah. So, the first 10 minutes are
  60. 2:37theory, which will give you some time to
  61. 2:38catch up on the setup uh while I'm
  62. 2:42talking.
  63. 2:47So, let's get started with the theory.
  64. 2:49Um, here's the situation I'm assuming
  65. 2:52most of you are in. You have already
  66. 2:53built an application that has an LLM in
  67. 2:55it. Uh, maybe a chatbot, maybe an agent.
  68. 2:58You tried it a bunch of times and it
  69. 2:59looks pretty good. Uh, then you shipped
  70. 3:02it and somebody used it in a way that
  71. 3:03you weren't expecting and it broke. Um,
  72. 3:07or you changed the prompt to fix one
  73. 3:09thing. uh and you have this nagging
  74. 3:11feeling that you broke something else.
  75. 3:13Uh and there's no way of knowing. That
  76. 3:15is the problem that today is about. That
  77. 3:17is the problem that evals are here to
  78. 3:19solve. How do you know if your agent is
  79. 3:22any good? How do you know if your change
  80. 3:24made things better or worse? Uh and how
  81. 3:27do you stop it getting worse when you
  82. 3:29make changes uh without having to read
  83. 3:31every output yourself?
  84. 3:36My promise by the end of today is that
  85. 3:38you're going to have a working agent
  86. 3:40traced end to end with code evals with
  87. 3:42LLM judge evals and with a custom eval
  88. 3:45that you wrote yourself. Uh
  89. 3:48and you'll have checked whether your
  90. 3:49judge can be trusted. You'll have run an
  91. 3:51experiment to prove that your changes
  92. 3:53worked. Uh and you'll have have all of
  93. 3:56it running as a test suite with npm
  94. 3:58tests so you can put it into npmci.
  95. 4:01Um, that is the bit that I'm most
  96. 4:04excited about. So, it's going to be the
  97. 4:05last thing that we do. I see some people
  98. 4:07have walked in late. So, let me just go
  99. 4:09back to the setup slide very quickly so
  100. 4:11that they're not completely lost.
  101. 4:17Right. Remember this repo because you're
  102. 4:20going to want this repo.
  103. 4:32How is the Wi-Fi working for people? Is
  104. 4:34it Are you getting places?
  105. 4:36>> Excellent. Okay. I did this at World's
  106. 4:40Fair and uh every and I accidentally had
  107. 4:42a repo that was full of product images
  108. 4:44that looked really great in the demo,
  109. 4:46but it was 400 megabytes of product
  110. 4:47images and it just complete failure.
  111. 4:50Nobody was able to get even the repo
  112. 4:51down.
  113. 4:54So, I've learned my lesson and today has
  114. 4:55no images. Uh,
  115. 4:59so let's cover the basics. What is an
  116. 5:01eval? The shortest version, the one that
  117. 5:04I use whenever I'm talking to somebody
  118. 5:05who's been an engineer for a while is
  119. 5:08that uh there are these things called
  120. 5:10traces and they are basically logs and
  121. 5:13there's these things called evals and
  122. 5:15they're basically tests and evals are
  123. 5:17using are running tests on your traces.
  124. 5:20Um
  125. 5:22the difference between an eval and a
  126. 5:23unit test is that uh evals are for
  127. 5:26outputs that are never exactly the same
  128. 5:28twice, which is to say the
  129. 5:29non-deterministic outputs that you get
  130. 5:31from LLMs.
  131. 5:32Um traces record what your AI did at an
  132. 5:36incredible level of detail. So every
  133. 5:37agent step, every tool call, every LLM
  134. 5:40call, the inputs and outputs at every
  135. 5:41single step.
  136. 5:43A trace is made up of what we call
  137. 5:45spans. Each span is one step in the
  138. 5:47execution. You can think of it as just a
  139. 5:49line in the log. Um, and a so a whole
  140. 5:52agent turn is a span that has other
  141. 5:55spans nested inside of it. Uh, and each
  142. 5:57one records its input, its output, how
  143. 5:59long it took, how many tokens it used,
  144. 6:01uh, and sometimes how much it cost. So
  145. 6:04traces tell you what happened and evals
  146. 6:06tell you whether it was any good and
  147. 6:08that is the whole mental model for
  148. 6:09today. This is very far from being
  149. 6:12rocket science.
  150. 6:15Looks good to me is not a test suite.
  151. 6:17Um, but it's how most AI features get
  152. 6:20shipped. You build it, you try it a few
  153. 6:22times, does it look right? Yeah, that
  154. 6:24looks good. You ship it. Uh, and it
  155. 6:27probably does look good on the three
  156. 6:29things that you tried. Um, but three
  157. 6:31tries is not a test suite. And the usual
  158. 6:33fix is unit tests. Um, but unit tests
  159. 6:37don't work here because the same prompt
  160. 6:38is going to give a different answer text
  161. 6:40every single time you run your
  162. 6:42application. Uh, so two completely
  163. 6:45different answers can both be right. a
  164. 6:46thousand different answers can both can
  165. 6:48all be right. Uh just differently right.
  166. 6:51So there's no expected string to assert
  167. 6:53against. Uh so humans tend to fall back
  168. 6:57on human judgment. They look at the
  169. 6:58strings being output and they're like
  170. 6:59well this looks fine. [snorts] Um but
  171. 7:02that doesn't scale. It doesn't catch
  172. 7:04regressions and it certainly doesn't run
  173. 7:05in CI where there are no humans to watch
  174. 7:07things.
  175. 7:09Uh what that looks like in practice is
  176. 7:12you change your system prompts to fix
  177. 7:14the tone and the tone gets better. Uh
  178. 7:16but now the bot is making up product
  179. 7:18features. Uh and you don't find out
  180. 7:20until a customer does. Every prompt
  181. 7:22change can affect every kind of input
  182. 7:23your users send. Uh and you can't test
  183. 7:26all of those by hand. So you end up
  184. 7:27playing a game of whack-a-ole where you
  185. 7:29fix one thing and something else breaks
  186. 7:31and you fix that and something else
  187. 7:32breaks. uh evals fix that by giving you
  188. 7:36a number that you can track and can
  189. 7:38compare and act on.
  190. 7:42This matters more every month because uh
  191. 7:45every couple of weeks somebody releases
  192. 7:47a new model and you're like, "Oh, I want
  193. 7:49to switch to the new model." Uh but you
  194. 7:51have no way of knowing which things the
  195. 7:53new model is going to be better at uh
  196. 7:55and which things the new model is going
  197. 7:56to be worse at unless you have a set of
  198. 7:58evals that you can run things through.
  199. 8:00Uh, and that's exactly what we're going
  200. 8:02to do today. We're going to start with
  201. 8:04uh Claude 4.5 and then we are going to
  202. 8:06upgrade it to Claude uh Haiku 5.5
  203. 8:10um uh which was conveniently released
  204. 8:14like a week ago making this demo
  205. 8:16extremely easy to put together. I was
  206. 8:17like I want to upgrade the model for
  207. 8:19this demo. So I'm going to make that the
  208. 8:21demo. Uh so with eval you run the suite
  209. 8:25you can compare the numbers and by the
  210. 8:26end of the afternoon you know uh whether
  211. 8:28you can upgrade your model.
  212. 8:31Um and there are a few kinds of evals.
  213. 8:33The first kind is code evals. Code evals
  214. 8:35are fast and free and a little bit
  215. 8:37brittle. They are very very similar to
  216. 8:40unit tests. They are just ordinary
  217. 8:42functions where you basically assert a
  218. 8:46string. There are a bunch of techniques
  219. 8:48you can use to make them more flexible
  220. 8:51than a straight unit test that asserts a
  221. 8:53basic string. Uh but fundamentally
  222. 8:55that's what they're doing. So the things
  223. 8:57that you can test with a Kodi valal are
  224. 8:59stuff like did the output parse as JSON?
  225. 9:01Is it under 500 words? Did it mention
  226. 9:04the thing that I asked about? The
  227. 9:05advantage of them is that they run in
  228. 9:07milliseconds and they cost nothing to
  229. 9:08run. Um,
  230. 9:11but there are lots of valid answers that
  231. 9:14a string match can't tell you about. Um,
  232. 9:17and for that you need the second kind of
  233. 9:19eval which is the LLM is a judge eval.
  234. 9:22Uh, which is what most people think
  235. 9:24about when they're thinking about evals.
  236. 9:26In this one you use a second LLM to
  237. 9:28grade the output of the first LLM.
  238. 9:31[snorts] Um, you grade it against what
  239. 9:33is called a rubric. There are a bunch of
  240. 9:35terms in uh eval land that are borrowed
  241. 9:38from ML uh that I find obscure the
  242. 9:42meaning of what's going on. One of them
  243. 9:43is traces and one of them is evals and
  244. 9:45the other one is rubric. I'm like rubric
  245. 9:47just means rules. Why do we have a
  246. 9:49special word for it? Anyway, uh
  247. 9:53L&M judges understand meaning not just
  248. 9:56strings. So stuff like is this accurate?
  249. 9:58Does it stick to the source documents?
  250. 10:00Is the tone right for a customer? Um,
  251. 10:03the catch is that because the LLM judge
  252. 10:06isn't itself an LLM, it has all of the
  253. 10:08flaws that LLMs have. So, it can be
  254. 10:10unpredictable. It is never the same
  255. 10:12twice. Uh, and it can make mistakes. Uh,
  256. 10:16they also cost money because you're
  257. 10:18using an LLM. Uh, and they can be
  258. 10:21confidently wrong. So, you have to check
  259. 10:23them. And that is one of the things that
  260. 10:24we're going to do today. Then there's a
  261. 10:27third kind of eval uh, which is the
  262. 10:29human eval. somebody who knows the
  263. 10:31domain, who can read the output and
  264. 10:34grade it as an expert. Uh, humans are
  265. 10:36the gold standard for quality. Um,
  266. 10:39they're also slow and expensive. Uh, and
  267. 10:42they get bored and start skimming. So,
  268. 10:45uh, you want to use all three at the
  269. 10:47same time. These are not competing
  270. 10:49approaches. They are complimentary
  271. 10:51approaches. And we're going to talk
  272. 10:52about a little bit about how you use
  273. 10:53them in a complimentary way later.
  274. 10:56So which eval do you use when? Use code
  275. 11:00when the answer is deterministic. So
  276. 11:03things like formats and lengths and
  277. 11:04required fields and band phrases. Uh but
  278. 11:07use an LLM judge when you need
  279. 11:09understanding. Is it accurate? Is it
  280. 11:11grounded? Is it useful? Uh and use
  281. 11:14humans for the kinds of failures you
  282. 11:16haven't seen before. Stuff that you
  283. 11:18haven't anticipated. And to check that
  284. 11:20your LLM judges are judging correctly.
  285. 11:24Um, all of that applies to any LLM app,
  286. 11:26but agents in particular make all of
  287. 11:28this stuff harder because agents are
  288. 11:30more complicated. A single simp a single
  289. 11:33LLM call is relatively simple. You give
  290. 11:35it an input, you get an output. Uh, but
  291. 11:38an agent tends to chain a whole bunch of
  292. 11:40steps together. So, one of the things
  293. 11:42that can go wrong is very early on in
  294. 11:45the chain, the agent makes a mistake and
  295. 11:46it cascades through all of the rest of
  296. 11:48the steps in your agent and each one
  297. 11:51gets progressively more off the rails.
  298. 11:53Um,
  299. 11:56and one of the biggest problems is being
  300. 11:58confidently wrong. Confidently wrong is
  301. 12:00worse than obviously wrong. Uh, so I
  302. 12:02talked about the cascading failure. Um,
  303. 12:06one example of that is say you've
  304. 12:08written a financial analysis agent,
  305. 12:09which is the kind of agent that I'm
  306. 12:11going to show you today. Um, and you ask
  307. 12:14it for a report on Tesla. It searches
  308. 12:16for Tesla and instead of getting results
  309. 12:18about the car company, it gets results
  310. 12:19about the 18th century inventor. It
  311. 12:22writes an beautiful, perfectly formatted
  312. 12:24report about an 18th century inventor.
  313. 12:26Uh, and none of your checks fail because
  314. 12:30you're like, it's well formatted. It's
  315. 12:32in a great tone. Everything is
  316. 12:34grammatical. Uh, it's just about
  317. 12:36completely the wrong subject. Uh, and
  318. 12:40that is the kind of failure that is uh
  319. 12:44um insidious with uh agents.
  320. 12:48Agents can also fail in the opposite
  321. 12:49direction. Um, Anthropic uh, who make
  322. 12:53Claude ran a benchmark called Ta2 bench
  323. 12:55which simulates customer service
  324. 12:57conversations and they uh, gave it this
  325. 13:01task where the user asked to change
  326. 13:04their flight. Uh, and the test according
  327. 13:07to the test the user was supposed to
  328. 13:09fail the test uh, or rather the agent
  329. 13:12was supposed to fail because uh, the
  330. 13:14person was in economy and you're not
  331. 13:16allowed to switch seats in economy. Uh
  332. 13:18but what cloud found is that they can
  333. 13:21upgrade the person to first class.
  334. 13:23You're allowed to change your seat in
  335. 13:24first class and then they downgraded
  336. 13:25them back after changing their seat back
  337. 13:27down to economy. Uh and pass and like
  338. 13:31did the thing that the user asked for
  339. 13:33and the test said no you failed because
  340. 13:34you weren't supposed to be able to do
  341. 13:36that. Um but the agent had been smarter
  342. 13:40than the rules that it was in. Um so you
  343. 13:42have to expect that uh when you are
  344. 13:45building eval that sometimes the agent
  345. 13:47is going to come up with a solution to
  346. 13:48the problem that you did not expect. So
  347. 13:50your tests have to be very flexible.
  348. 13:53Um here's what an eval result generally
  349. 13:57looks like. Uh it comes with a score, it
  350. 13:59comes with a label and it comes with an
  351. 14:00explanation. The score is a number
  352. 14:02usually just zero or one. Uh and the
  353. 14:05label is just a word that the human can
  354. 14:07read that matches what the score means.
  355. 14:09Uh so stuff like pass and fail,
  356. 14:11actionable and not actionable. Uh and
  357. 14:13LLM judges add a third thing which is an
  358. 14:16explanation of why you got the score you
  359. 14:18did, why you got the label you did. Um
  360. 14:22and it is the most valuable part of an
  361. 14:24LLM judge. Uh because the explanation is
  362. 14:27where the value is. It tells you what
  363. 14:29was wrong and what was missing and it
  364. 14:30tells you a a lot of the time what to
  365. 14:33fix in your prompt to get this right. Uh
  366. 14:37this is especially useful when you're
  367. 14:38running your evals at scale because you
  368. 14:40can get, you know, 50, 100, a thousand
  369. 14:43explanations from your LLM and you can
  370. 14:45get another LLM to read all of those
  371. 14:47explanations and be like, it looks like
  372. 14:48there is a pattern in these
  373. 14:49explanations. It looks like we have a
  374. 14:51systematic problem. And you can just
  375. 14:52feed them to your agent and your agent
  376. 14:54goes, okay, I see 50 traces all doing
  377. 14:56the same all with the same explanation
  378. 14:58of what went wrong. I can fix it.
  379. 15:01Um,
  380. 15:04so this is the loop that we're going to
  381. 15:05be building today. We're going to trace
  382. 15:07your agent. We're going to read what it
  383. 15:08did. We're going to write evals for what
  384. 15:10matters. Uh, we're going to check that
  385. 15:11those eval can be trusted. Uh, then
  386. 15:14we're going to change the agent and
  387. 15:15we're going to prove that the change
  388. 15:17worked. Then we're going to lock that in
  389. 15:19so that it stays fixed by putting it
  390. 15:21into CI.
  391. 15:22So, uh,
  392. 15:25who still needs help getting set up? Who
  393. 15:28walked in late and needs set up? Show of
  394. 15:30hands. Okay, let me
  395. 15:32head back to the setup screen and see if
  396. 15:35you can get it.
  397. 15:46Right, this is the magic URL.
  398. 15:50If you haven't got this one, uh, all you
  399. 15:52have to do is read the readme and, uh,
  400. 15:55run the instructions or just, you know,
  401. 15:56paste the readme into your agent and
  402. 15:58your agent will read the instructions
  403. 15:59and get it all done for you. One of the
  404. 16:02weird things about doing tutorials in
  405. 16:042026 is that we're just like, well, I
  406. 16:06could show you how to do all of this
  407. 16:08stuff, or I could just tell you how to
  408. 16:09tell your agent to do all of this stuff.
  409. 16:11Uh, and that's what we do a lot of the
  410. 16:14time.
  411. 16:16All right, I'm now going to assume that
  412. 16:17everybody has that URL. Cool.
  413. 16:31So let's start with step one. Step one
  414. 16:33is tracing. Before you can evaluate
  415. 16:35anything, you need to get the data to
  416. 16:37run the to run the evaluations on. And
  417. 16:39that is what that is traces. Today we
  418. 16:42are going to be using Phoenix. I hope
  419. 16:44that's not a surprise to anybody by now.
  420. 16:46Uh, Phoenix is ARIS's open-source AI
  421. 16:48observability platform. Uh, it collects
  422. 16:51traces from your AI AI app with in
  423. 16:54whatever framework you use to build it.
  424. 16:55It stores your evals next to those
  425. 16:57traces. Uh, and it gives you a UI to dig
  426. 16:59through all of it. It also does data
  427. 17:01sets and experiments, which we're going
  428. 17:02to be talking about today. Uh, and you
  429. 17:05run it on your laptop. So, uh, you can
  430. 17:09keep it entirely private to yourself, or
  431. 17:11you can run it on a server and share it
  432. 17:12with your team.
  433. 17:16So now I'm going to dangerously see if I
  434. 17:19can actually Oh, that's so that is so
  435. 17:22small.
  436. 17:24Let's make that bigger.
  437. 17:27Okay,
  438. 17:29so what we're working in today is
  439. 17:30Typescript. Uh you'll see a ton of
  440. 17:33examples in Python and Fenix has great
  441. 17:35Python SDKs as well. Uh but I like
  442. 17:37JavaScript so we're going to use
  443. 17:38TypeScript. Um the repo is a small set
  444. 17:42of uh scripts. Instrumentation.ts
  445. 17:45sets up tracing. Agent.ts is the agent
  446. 17:48itself. Prompts.ts has the prompts. Uh
  447. 17:55where are all of these things? There we
  448. 17:56go. Um
  449. 18:00and you'll be editing the prompts in
  450. 18:01this folder. Uh sorry, in this file. Um
  451. 18:04and the evals folder is where our evals
  452. 18:06go. Queries.json is our test data. Uh,
  453. 18:09and hopefully every step today is just
  454. 18:11going to be one npm command. Uh, and
  455. 18:13each one stands on its own. So if you
  456. 18:15fall behind, you can skip straight to
  457. 18:16the next one. Uh, and use the seed data
  458. 18:19that I put in the repo uh, so that you
  459. 18:21don't get left behind.
  460. 18:26So what we're building today, or indeed
  461. 18:28what I've already built for you, is a
  462. 18:30financial analyst. How it works is you
  463. 18:32give it a stock ticker and something to
  464. 18:34focus on like Tesla vehicle deliveries.
  465. 18:37uh and it will go and it will search the
  466. 18:38web for live data uh and write you a
  467. 18:41report about that. Uh there are whole
  468. 18:44startups built on this idea of giving
  469. 18:46you you know financial analysis of
  470. 18:48whether or not you should buy a stock.
  471. 18:50Uh but ours is deliberately simple
  472. 18:52because I needed something that would
  473. 18:54make mistakes so that we could fix the
  474. 18:56mistakes. Um
  475. 19:00today is not about how to build an
  476. 19:01agent. I've just built the agent for
  477. 19:03you. I assume you've already got an
  478. 19:04agent running somewhere and your what
  479. 19:06you want is help on making it reliable.
  480. 19:09Um, our agent works in two turns. It has
  481. 19:12a research turn where it searches the
  482. 19:14web and then it has a writing a report
  483. 19:16writing turn where it takes the research
  484. 19:18and it writes the report about it. Um,
  485. 19:22I'm I've built it using the claude agent
  486. 19:24SDK. If you haven't used it, that is
  487. 19:26anthropics framework for agents. Uh it
  488. 19:28is the same engine that runs underneath
  489. 19:30cla code which is going to become
  490. 19:32relevant later especially if you're
  491. 19:33using claude code to work with it uh
  492. 19:36because the two versions of cloud code
  493. 19:37tend to try to cooperate with each other
  494. 19:39and that makes them cheat the eval which
  495. 19:41is not very helpful. Um
  496. 19:45uh it gives you tool use web search uh
  497. 19:47and conversations that carry on across
  498. 19:49turns. There are also lots of other
  499. 19:50options that we are compatible with. The
  500. 19:52Versel AI SDK, Mastra, Langchain,
  501. 19:55OpenAI's agent SDK. Uh, Phoenix has
  502. 19:59adapters and instrumentation for every
  503. 20:01possible framework that you can think of
  504. 20:03and every LLM provider that you can
  505. 20:05possibly think of. Wherever you have
  506. 20:06built your agent in, Phoenix will work
  507. 20:08with it and the instrumentation will
  508. 20:10happen automatically. Uh, but I had to
  509. 20:12pick one for a demo, so I picked this
  510. 20:13one. Um, [snorts] tracing takes about
  511. 20:17five lines. Um, first we're going to
  512. 20:19call register uh from the Phoenix hotel
  513. 20:22package that sets up tracing and points
  514. 20:24it at Phoenix. One of the good things uh
  515. 20:27about the industry is that everybody has
  516. 20:30pretty much picked uh the same uh
  517. 20:33instrumentation standard. uh everything
  518. 20:36is built on open telemetry in the
  519. 20:37industry and on top of open telemetry
  520. 20:39there is a standard called open
  521. 20:40inference uh which arise takes care of
  522. 20:44um and everybody has already built the
  523. 20:46instrumentation into their frameworks
  524. 20:48that is why we are compatible with all
  525. 20:49of those frameworks all you have to do
  526. 20:51is use this registered command to say
  527. 20:53hey that instrumentation that you've
  528. 20:56already built into your framework turn
  529. 20:58it on and point it over here in this
  530. 21:00case you're just going to point it at
  531. 21:01your laptop
  532. 21:03uh and That's all you have to do. Every
  533. 21:06agent call that our agent makes is now
  534. 21:07going to be traced. Um,
  535. 21:11oh, I said that already. Uh, so the good
  536. 21:14thing about this is that we don't have
  537. 21:15to write a log line for every single
  538. 21:17call. We don't have to write a trace for
  539. 21:18every single thing our agent does. It's
  540. 21:20just going to do it automatically.
  541. 21:22Sometimes we will want to add additional
  542. 21:23information and the framework absolutely
  543. 21:25supports that. Um, uh, but we don't have
  544. 21:28to do it for every single thing. Um
  545. 21:31there's one gotcha in the TypeScript
  546. 21:34version that you should know about uh
  547. 21:36which is that manually you should use
  548. 21:38manually instrument which will hand you
  549. 21:40back a copy of the instrument uh and you
  550. 21:42should use the copy of the instrument uh
  551. 21:45because the cloud agent SDK is an ES
  552. 21:48module uh and ES module exports are
  553. 21:51readon. So the instrumentation can't do
  554. 21:53the thing like it can do in Python where
  555. 21:55it swaps out your instrument and just
  556. 21:57changes everything. you have to use the
  557. 21:58copy that it gives you which has that
  558. 22:00instrument swapped out. Um
  559. 22:05it won't break it just won't log
  560. 22:06anything if you don't use the copy that
  561. 22:08it gives you. Uh so everywhere in this
  562. 22:10repo we import claude agent SDK from our
  563. 22:13instrumentation file never straight from
  564. 22:15the package.
  565. 22:17Uh now if you open agent.ts you'll see
  566. 22:20our agents options. Uh we're going to
  567. 22:22start using Claude Haiku F 4.5 uh
  568. 22:25because it is fast, it is cheap, and it
  569. 22:27is sort of usefully dumb. Um it makes uh
  570. 22:31mistakes that are nice and predictable
  571. 22:33even with a relatively simple agent. Um
  572. 22:37unlike the frontier models which will
  573. 22:39still definitely make mistakes, but you
  574. 22:40have to have quite a complicated agent
  575. 22:42and quite a complicated set of tasks. Uh
  576. 22:44and it makes it harder for the demo. Um
  577. 22:48if you've not used it before then uh
  578. 22:51allowed tools is giving it web search so
  579. 22:53it can find the current financial data.
  580. 22:56Uh and the permission mode don't ask
  581. 22:58means that it's [snorts] uh going to not
  582. 23:00be interactive. It's not going to pause
  583. 23:01and ask you questions uh because there's
  584. 23:04nobody there to say yes. Um that option
  585. 23:08is going to become relevant uh to a
  586. 23:10failure mode later. [snorts] Um, and the
  587. 23:12other three options, like I mentioned,
  588. 23:14they keep the your laptop out of the
  589. 23:16agent. The cloud agent SDK, uh, runs the
  590. 23:18same engine as cloud code. Uh, so if
  591. 23:21you're doing this in cloud code, it
  592. 23:23tends to pick up the options that you
  593. 23:24and the tools and the skills that you've
  594. 23:26given to your copy of Claude code
  595. 23:28instead of its copy of Cloud Code. Uh,
  596. 23:30which tends to make things extremely
  597. 23:32non-deterministic in an unhelpful way.
  598. 23:35Uh so I've uh thrown in a couple lines
  599. 23:38of code there that make sure that the
  600. 23:40cloud uh the cloud SDK is running in its
  601. 23:42own isolated version of uh the cloud SDK
  602. 23:46and not uh stealing your copies of of
  603. 23:49you know keys and things from your data.
  604. 23:52Um
  605. 23:55[sighs]
  606. 23:57right uh none of that is Phoenix
  607. 23:59specific by the way. Uh that is just a
  608. 24:02danger of using the cloud SDK at the
  609. 24:04same time as you're using cloud code. Um
  610. 24:08in this SDK one turn is one query call.
  611. 24:11So you give it a prompt. Uh it streams
  612. 24:13back messages as the agent works. It
  613. 24:16thinks it calls a tool. It reads the
  614. 24:17result. Uh it maybe calls another tool
  615. 24:20and when it's finished you get a result
  616. 24:22message with the final text and a
  617. 24:23session ID. The session ID is how we
  618. 24:26carry on the conversation. If we pass it
  619. 24:28back in as resume, the next turn
  620. 24:30remembers everything that the last turn
  621. 24:32saw. Uh so that's how we can do the
  622. 24:34research and then say, hey, write a
  623. 24:37report on this research because it knows
  624. 24:39that it's in the same session. Uh and it
  625. 24:41can find the research that the previous
  626. 24:42turn just created.
  627. 24:45Then we put the two turns together. Uh
  628. 24:47so we get the two turns in one trace. Um
  629. 24:50first the research turn, then the
  630. 24:51writing turn, resuming the research turn
  631. 24:53session so the writer can see everything
  632. 24:55the researcher found. Um, and then we
  633. 24:57wrap the whole thing in trace agent. Um,
  634. 25:00the reason we do that, uh, is because it
  635. 25:03gives us one parent span that
  636. 25:05encompasses all of the data. If we
  637. 25:07didn't do that, we would get two, uh,
  638. 25:10two, uh, sibling spans in our Phoenix.
  639. 25:13Um, which would be fine, but slightly
  640. 25:16harder to read. Uh, so I'm just, uh,
  641. 25:19shaping the data now to make our lives
  642. 25:21easier later.
  643. 25:24Now, if you open up prompts.ts, ts.
  644. 25:26You'll see that uh there are a bunch of
  645. 25:27prompts in there. They are deliberately
  646. 25:29bad. Um there's one line of research
  647. 25:32instructions, one line of writing
  648. 25:33instructions. Uh and I did that on
  649. 25:36purpose because it gives us lots to
  650. 25:37improve later. Um if you're coding
  651. 25:40along, now is the time to start playing
  652. 25:42with things. Feel free to change them.
  653. 25:43Add stuff like make no mistakes or I
  654. 25:45will tip you $100.
  655. 25:47Um allegedly those help. Uh
  656. 25:52what I want is everyone in the room to
  657. 25:53end up with a slightly different agent
  658. 25:55uh so that we get different experiences
  659. 25:58uh which will make comparing notes more
  660. 26:00interesting.
  661. 26:02So now if you've followed along and
  662. 26:05you've installed everything and
  663. 26:07everything is going fine uh you should
  664. 26:09be able to run it. You should run npm
  665. 26:11run agent dash uh Tesla and then growth
  666. 26:15outlook in quotes. Um,
  667. 26:20you can do it on Tesla, you can do it on
  668. 26:21some other company if you like. Uh, it
  669. 26:24will take a minute or two because it
  670. 26:25really does have to actually search the
  671. 26:26web and you're on conference Wi-Fi. Um,
  672. 26:29and the model will do a few rounds of
  673. 26:31reasoning. Um,
  674. 26:34what's happening here while that's
  675. 26:36running for you uh is the agent gets the
  676. 26:39research prompt. It decides that it
  677. 26:41needs to search uh which is a tool call.
  678. 26:43It reads the results uh decides whether
  679. 26:45it has enough results or whether it
  680. 26:47needs to search again. And that is the
  681. 26:50thing that makes it an agent. We haven't
  682. 26:51specified how many times it needs to
  683. 26:53search the web. We haven't specified
  684. 26:54what it needs to search the web for. The
  685. 26:56agent is making those decisions by
  686. 26:58itself. Uh so all of our agents are
  687. 27:01going to make slightly different
  688. 27:02decisions about those things. They're
  689. 27:04going to use slightly different search
  690. 27:05terms. Uh they're probably going to
  691. 27:07search a different number of times. Um,
  692. 27:10and then once it's done, the writing
  693. 27:13turn starts and it turns all of that
  694. 27:14into a report. So the path the agent
  695. 27:17takes is nondeterministic by by design.
  696. 27:20Um, both reports might be fine if you
  697. 27:24run it a if you run it twice. Um, or one
  698. 27:28might be great and one might be wrong
  699. 27:29and you can't but you can't predict that
  700. 27:32uh output from the input. Uh, which is
  701. 27:34why you need evals. Um,
  702. 27:39who's got an actual report yet? Anybody?
  703. 27:43>> Still running. [snorts]
  704. 27:45>> Okay,
  705. 27:48we've got time. Let me be brave.
  706. 27:53And actually try running it myself.
  707. 27:56One of the problems that we're going to
  708. 27:58see that the agent runs into is that we
  709. 27:59told it to write a report, but we didn't
  710. 28:01tell it where to write a report. And so
  711. 28:03it assumes that it should be uh writing
  712. 28:06the report to a file. There we go. So
  713. 28:09you can see mine. I need permission to
  714. 28:10write the financial report file. Would
  715. 28:12you like me to display the report here?
  716. 28:14This is completely unhelpful. The agent
  717. 28:16does not understand that it is running
  718. 28:18in a no permissions environment and that
  719. 28:20I wanted the report actually output to
  720. 28:23the command line. Uh and that is because
  721. 28:25my prompt is ambiguous. Um but sometimes
  722. 28:28it doesn't do that. Sometimes it does
  723. 28:30just figure it out and give you the
  724. 28:31report. Uh, so that is the
  725. 28:33nondeterminism that we're talking about.
  726. 28:35So let's see what Phoenix captured from
  727. 28:38all of this.
  728. 28:41Here is my Phoenix 101. There is my
  729. 28:44financial report. This is what a trace
  730. 28:47looks like. So you can see the financial
  731. 28:50report agent running and you can see the
  732. 28:53two invocations of the claude agent. One
  733. 28:55is the this is the research report. You
  734. 28:58can see tool searches inside of it to
  735. 29:01find out whether what it's got available
  736. 29:03to it. You can then see it finds that
  737. 29:04it's got a web search tool. So it
  738. 29:07conducts three different web searches.
  739. 29:08You can see the inputs and the outputs.
  740. 29:11Uh what the exact query is, what output
  741. 29:13it got from each tool call. Uh and then
  742. 29:16you can see uh that it messed up in this
  743. 29:19case. uh it tried to write it it wrote a
  744. 29:22report and then it tried to write it to
  745. 29:24a file path on my computer and said that
  746. 29:26it couldn't work. Um
  747. 29:31so
  748. 29:33uh
  749. 29:34the important thing here is that we
  750. 29:36didn't have to add any logging to our
  751. 29:37agent. The important thing here is that
  752. 29:38all of this showed up all of this very
  753. 29:40useful information about what's going on
  754. 29:42without us doing anything. We didn't say
  755. 29:44hey your tools need to be instrumented.
  756. 29:46We didn't say hey your web searches need
  757. 29:47to be instrumented. All of that just
  758. 29:49happens as part of the cloud agent SDK
  759. 29:50because it's already instrumented for
  760. 29:52us. Uh and you can click into any span
  761. 29:55in Phoenix and you can see an enormous
  762. 29:57amount of data about what's going on. Um
  763. 30:04uh
  764. 30:05and the reason that all of this
  765. 30:06happened, the reason that it's trying to
  766. 30:08write to disk and then failing is
  767. 30:09because we gave it that don't ask
  768. 30:11setting. We told it you're going to be
  769. 30:12running unattended. Uh don't ask me any
  770. 30:15questions. it ran without asking any
  771. 30:17questions and then it messed up. Um,
  772. 30:21but you wouldn't know that if you hadn't
  773. 30:22been able to look at the trace, right?
  774. 30:24You just would have got a mysterious
  775. 30:25output where it says something was
  776. 30:27wrong. The traces are where you can see
  777. 30:30that the tool call is failing. The
  778. 30:32traces are where you can see it's trying
  779. 30:33to do something that it's not been given
  780. 30:35permission to do. Um, and that is the
  781. 30:39kind of stuff that lives in a span. Uh,
  782. 30:41so the span kind tells you what type of
  783. 30:44step it is. So it's an agent tool, an
  784. 30:46agent, a tool call, an LLM and so on.
  785. 30:48Um,
  786. 30:50and in a tool call and a web search and
  787. 30:53things like that, you can see that our
  788. 30:54input is in fact JSON. Um,
  789. 30:58and that's going to make our first eval
  790. 31:02uh because it gives us some structured
  791. 31:03data. Um, you also get things like
  792. 31:06timing and token counts. Um, and uh,
  793. 31:11often your agent will record what it
  794. 31:13costs.
  795. 31:14Um,
  796. 31:16when we write eval in a bit, these are
  797. 31:18the fields that we're going to pull out
  798. 31:19and grade.
  799. 31:26So, uh, you've run one, you've won one,
  800. 31:30you've run one test so far. Uh, that is
  801. 31:34not enough data to draw any conclusions
  802. 31:35from. So what I want you to do now is
  803. 31:37run npm run batch uh which will run 15
  804. 31:40queries in a row. Uh that will take a
  805. 31:43little while. So I'm going to talk while
  806. 31:45you're doing that. Um it runs five at a
  807. 31:48time. It takes three or four minutes
  808. 31:50optimistically on Wi-Fi. Um so start it
  809. 31:53now. [snorts] Um if it fails for
  810. 31:56whatever reason, don't worry about it.
  811. 31:57The seed project that you loaded earlier
  812. 31:59uh contains is called Phoenix 101
  813. 32:02golden. Uh, and it has my 16 runs that I
  814. 32:05did earlier on reliable Wi-Fi on it. So,
  815. 32:08you can use those instead if you can't
  816. 32:10get your batch to run.
  817. 32:13Um, here are some examples of the
  818. 32:15queries.
  819. 32:18Uh, there are obvious ones like Apple,
  820. 32:20Nvidia, and Amazon. And then there are
  821. 32:22some edge cases that I put in there to
  822. 32:23make things fall over. Uh, so one asks
  823. 32:26it to compare Apple and Microsoft, which
  824. 32:28is harder than just company covering one
  825. 32:30company. Uh, one is about Rivian. uh
  826. 32:33which is not a public company. So
  827. 32:34there's much less data out there than it
  828. 32:36does about uh public companies. Um
  829. 32:39Coca-Cola is a very different type of
  830. 32:41company from a tech company. Uh and ZZQ
  831. 32:43isn't a real ticker at all. I just made
  832. 32:45it up. Um and that is to see what the
  833. 32:48agent does when it sees a ticker symbol
  834. 32:50that it doesn't recognize. Does it, you
  835. 32:51know, invent a company? Does it guess
  836. 32:53what company you mean or does it say
  837. 32:56what I'm hoping it says, which is that
  838. 32:57ticker doesn't exist? Um, one of them is
  839. 33:00uh about Tesla, but the focus is yo is
  840. 33:03it a buy right now? Uh, because that is
  841. 33:06how real people send queries to agents.
  842. 33:08They do it in slang. Uh, and they don't
  843. 33:11often specify exactly what it is that
  844. 33:13they wanted. Um,
  845. 33:15so these are all, you know, realish
  846. 33:19looking queries. Um,
  847. 33:23and what you have to do is, like I said,
  848. 33:25you have to write down what good means
  849. 33:28before you measure it. You can't say
  850. 33:29that your agent doesn't work if you
  851. 33:31haven't specified what working means.
  852. 33:34So, for our analyst, uh, what does a
  853. 33:37good report look like? Um, it should use
  854. 33:40real current data. It should probably be
  855. 33:42about the right company. It should stick
  856. 33:44to what it actually found. Uh, and for
  857. 33:47my purposes, I want it to tell us what
  858. 33:49we should do. I want it to say buy or
  859. 33:53hold or sell this stock. I don't just
  860. 33:55want it to give me analysis.
  861. 33:57Um,
  862. 33:59those sorts of requirements sound
  863. 34:00obvious once you've written them down,
  864. 34:02but before that, they could just be
  865. 34:04vague or different people on your team
  866. 34:06could have different ideas about what a
  867. 34:08good financial an analyst agent would
  868. 34:10do.
  869. 34:10>> [snorts]
  870. 34:11>> Uh so writing them down turns vague
  871. 34:13disappointment into specific things that
  872. 34:15you can test and we are going to turn
  873. 34:17every single one of those requirements
  874. 34:18into an eval today.
  875. 34:21Defining good is not solely uh an
  876. 34:25engineering job. If you are defining
  877. 34:27good for your product, you have to talk
  878. 34:29to the non-technical stakeholders in
  879. 34:32your organization because they are the
  880. 34:33domain experts who are going to know
  881. 34:36what good looks like. You as an engineer
  882. 34:38are going to have specific guesses about
  883. 34:41what uh guesses and biases uh about what
  884. 34:44makes uh a good agent and what makes
  885. 34:46good output and you are not always going
  886. 34:49to agree with the domain experts. So uh
  887. 34:52the customerf facing people need to be
  888. 34:54in the room when you define what your
  889. 34:56agent looks like.
  890. 34:59Uh it's also great uh if you don't have
  891. 35:02users that you can make some up. uh you
  892. 35:05can get an LLM to generate lots of test
  893. 35:07queries and vary them on purpose. So
  894. 35:10research Tesla's financial performance
  895. 35:12is one way to ask what's going on with
  896. 35:14Tesla stock is another and yo is Tesla
  897. 35:17by right now is a third. Um then you can
  898. 35:20get a human to look at the list because
  899. 35:22LLM generated queries they are a useful
  900. 35:24way of seeding your initial data. They
  901. 35:26are not perfect u mostly because they
  902. 35:30are relatively conservative. They don't
  903. 35:32go as far a field as human users tend to
  904. 35:35actually go. Human users are like, you
  905. 35:37know, tell me what's wrong with, you
  906. 35:39know, my child's health instead of
  907. 35:42asking you for a financial analyst and
  908. 35:43you your agent has to have something to
  909. 35:45do with that. Um, but synthetic data is
  910. 35:48a great way to get started once you've
  911. 35:50got started and you have real users with
  912. 35:52real traffic. Real traffic is uh the
  913. 35:55gold standard for testing an agent. you
  914. 35:57want to get it incorporated into your
  915. 35:59data set as fast as you possibly can.
  916. 36:02Um,
  917. 36:04one aside before we look at the data
  918. 36:05that I'm hope hoping is arriving in your
  919. 36:07laptops right now. Um, I walked through
  920. 36:10tracing by hand because you should
  921. 36:11understand what it's doing, but you can,
  922. 36:13like I said, you can also get your
  923. 36:14coding agent to do all of this. Um,
  924. 36:17Phoenix has a really good CLI. Uh, and
  925. 36:19if you run it setup command in your
  926. 36:21project, it will give your coding agent
  927. 36:23um, it will get your coding agent to add
  928. 36:25tracing to your app. uh and it will work
  929. 36:28until your your app uh has tracing
  930. 36:31installed and you don't have to figure
  931. 36:33out how to add the register command and
  932. 36:34all of that stuff. It will work in every
  933. 36:36language. Uh it's really neat.
  934. 36:40So step two is reading your data. Who
  935. 36:43has any data at this point? Show hands.
  936. 36:46One person. Anybody else? Oh yeah. Cool.
  937. 36:49All right. Several people. Fantastic.
  938. 36:53Uh
  939. 36:55you have to read your traces before you
  940. 36:57write a single eval. Um reading a dozen
  941. 36:59or more of them end to end. Uh what was
  942. 37:02the input? What was the output? Um what
  943. 37:04specifically is wrong? This sounds
  944. 37:07manual and old-fashioned, but it's an
  945. 37:09incredibly high value high value thing
  946. 37:11that you can do. Um, when you're
  947. 37:14building an agent, uh, you have to
  948. 37:17manually inspect what is going on so
  949. 37:20that you can find things that you the
  950. 37:22unknown unknowns that you weren't
  951. 37:23expecting. Uh, Anthropics team regularly
  952. 37:27sits down and reads eval transcripts by
  953. 37:29hand uh, and have built a bunch of
  954. 37:32tooling internally to make that easy to
  955. 37:34do. [snorts] Um, if you automate before
  956. 37:37you understand how your agent fails,
  957. 37:38you're going to end up measuring what's
  958. 37:40easy to measure instead of what actually
  959. 37:42matters.
  960. 37:44Um, so you should read traces and we're
  961. 37:46about to do that. But reading traces
  962. 37:48doesn't scale. Reading 16 traces
  963. 37:51yourself is absolutely fine. Uh, but
  964. 37:531600 traces uh is going to give you a
  965. 37:56bunch of really great data and it's also
  966. 37:58going to take a week out of your life.
  967. 38:00Um,
  968. 38:02but it turns out that coding agents are
  969. 38:04aces at reading traces. Uh, so you can
  970. 38:06point your coding agent at your traces
  971. 38:08and get them to look for things that are
  972. 38:10weird in your traces. Get them to code
  973. 38:12stuff up. [snorts] Uh,
  974. 38:15but they're not always going to find
  975. 38:16what you expected. So manual inspection
  976. 38:18as a sampling technique always a really
  977. 38:20great idea.
  978. 38:24So, um,
  979. 38:27if you are using if you're getting the,
  980. 38:31uh, agent to do stuff for you, you want
  981. 38:33to install the Phoenix plugin or the
  982. 38:35Phoenix skill depending on which coding
  983. 38:36agent you're use you use. It was the
  984. 38:38last step in the setup readme if you've
  985. 38:40still got that. Uh, so you may have it
  986. 38:43already. Um, for cloud code, we have a
  987. 38:45plugin which is two commands. Uh, there
  988. 38:47are also plugins for cursor and codeex.
  989. 38:50Uh, and for any other coding agent,
  990. 38:51there is a skill file. Um, the plug-in
  991. 38:54connects your coding agent to your
  992. 38:56Phoenix. Uh, and it already points at
  993. 38:58localhost 606, so there's nothing to
  994. 39:00configure. Um, and Phoenix itself will
  995. 39:03hand your agent a skill called the
  996. 39:04Phoenix error analysis skill with
  997. 39:06instructions on how to do error analysis
  998. 39:08properly. Um,
  999. 39:11it should take about 10 seconds to
  1000. 39:13install.
  1001. 39:14Uh, and I'm not going to hang around
  1002. 39:17waiting for you to install it. Um,
  1003. 39:22now open your coding agent and ask it to
  1004. 39:24do the error analysis.
  1005. 39:26Uh,
  1006. 39:29if you've got it. Who's got who's got
  1007. 39:31the skill installed from previously?
  1008. 39:33Fantastic. I'm going to pick on you
  1009. 39:35again. Can you have you asked your
  1010. 39:37coding agent to do things?
  1011. 39:39>> Okay, great. Um, the prompt is on the
  1012. 39:42slide. Tell it where Phoenix is. Tell it
  1013. 39:44to read the traces. Come up with
  1014. 39:45categories of failures. uh count them up
  1015. 39:48and write each category back onto its
  1016. 39:50trace in Phoenix as an annotation. An
  1017. 39:52annotation is just a human readable
  1018. 39:56string of text attached to a trace. Uh
  1019. 39:59they are a way of adding additional
  1020. 40:01information to traces so that either
  1021. 40:04yourself or your agent can figure out
  1022. 40:06what was going on. Um your your plug-in
  1023. 40:09is going to ask permission to use
  1024. 40:10Phoenix's tools. So you should say yes.
  1025. 40:12Uh when I ran it, it took about 9
  1026. 40:15minutes. Uh, so I'm not going to pick on
  1027. 40:17you quite yet. Um,
  1028. 40:22uh, also if it asks to write notes into
  1029. 40:24the repo, uh, that's fine. Just let it
  1030. 40:27write stuff to disk.
  1031. 40:30Now, let's look at Phoenix again.
  1032. 40:35Um,
  1033. 40:37I'm going to very dangerously
  1034. 40:43try and remember my syntax for search.
  1035. 41:00Ha. Okay, so these are all of my runs uh
  1036. 41:04that are the financial reports. Uh we
  1037. 41:07can click into individual ones of them.
  1038. 41:08Let's see if we can find the interesting
  1039. 41:11ones. Uh ZZQ,
  1040. 41:14what was my output for ZZQ?
  1041. 41:18ZZZQ does not appear to be a valid or
  1042. 41:20active financial ticker symbol. Hooray.
  1043. 41:21The agent did the thing that we were
  1044. 41:23expecting it to do. Um
  1045. 41:26how about uh Coca-Cola?
  1046. 41:31First, it starts with the apology. It's
  1047. 41:33running in restricted mode and it cannot
  1048. 41:34write files directly. We're going to
  1049. 41:36have to fix that definitely. Uh then it
  1050. 41:38comes to a conclusion. Coca-Cola
  1051. 41:40represents a high quality, lowrisk
  1052. 41:42dividend investment. Um KO is an
  1053. 41:45excellent long-term income vehicle for
  1054. 41:47riskaverse investors. This one's going
  1055. 41:49to be fun. Show of hands. Who thinks
  1056. 41:52that this is an actionable report?
  1057. 41:57[laughter]
  1058. 41:57Okay, I primed you already. Uh it does
  1059. 42:00not say buy, sell, or hold. So it just
  1060. 42:03says that it's a good investment. That
  1061. 42:04doesn't say what you should do. Uh I'm
  1062. 42:07going to make my standard of
  1063. 42:09actionability for these reports that it
  1064. 42:10should tell me whether I should buy,
  1065. 42:12sell, or hold the stock. I'm not going
  1066. 42:13to leave it to be ambiguous. Um
  1067. 42:19a whole bunch of them do different
  1068. 42:20things in this set. Uh
  1069. 42:23you can see this one had the same
  1070. 42:25problem. It tried to write to disk and
  1071. 42:26it was and it was and it failed. Um,
  1072. 42:31uh, the Rivian trace, I made a note that
  1073. 42:34Rivian was interesting.
  1074. 42:39There it is.
  1075. 42:44Uh, it's full of emojis for some reason.
  1076. 42:46Um, it opens by asking, "Would you like
  1077. 42:50to
  1078. 42:51Yes. Would you like to create the report
  1079. 42:53file?" We saw that earlier when I ran it
  1080. 42:55live. Uh, it's asking me to do things
  1081. 42:57and it can't ask. I told it I told it
  1082. 43:00it's not allowed to and it's asking to
  1083. 43:01do things anyway. Um,
  1084. 43:07all of these things are uh different
  1085. 43:10ways of failing. Lots of these are
  1086. 43:11failures. Lots of these are sort of
  1087. 43:13okay. Um,
  1088. 43:17but then uh there's Tesla.
  1089. 43:23Tesla is particularly fascinating. Uh
  1090. 43:27specifically the yo is Tesla a buy right
  1091. 43:29now one.
  1092. 43:36So in this one uh
  1093. 43:40it says that the analyst consensus is a
  1094. 43:42buy. Uh it says 50% say buy, 52.6% 6%
  1095. 43:48say hold and 13.1% say sell, which adds
  1096. 43:51up to 116% of analysts saying things.
  1097. 43:55And it did not catch that its math was
  1098. 43:57completely wrong. What it did was it did
  1099. 43:59two different web searches. One where it
  1100. 44:01found 50% of people saying something,
  1101. 44:03another one where it found 13% of people
  1102. 44:05saying something. It took those two web
  1103. 44:07searches and it munched them together
  1104. 44:09even though they were not from the same
  1105. 44:10data set and it came up with 116%. But
  1106. 44:14it confidently wrote down that 116% of
  1107. 44:17analysts say something. This is exactly
  1108. 44:20the kind of agentic failure that you
  1109. 44:21see. Uh it is confidently wrong having
  1110. 44:25done uh bad math. Um
  1111. 44:29if you go into these web searches, you
  1112. 44:31can see the specific places where it got
  1113. 44:34the data and how it uh put those things
  1114. 44:36together. Um
  1115. 44:40so when you find a failure, you have to
  1116. 44:42ask why it failed. the answer was wrong
  1117. 44:44is a symptom. It's not a cause. Um
  1118. 44:48with the traces you can see what the
  1119. 44:49actual answer was. Did it get bad search
  1120. 44:51results? That would be a retrieval
  1121. 44:53failure. That is not what happened here.
  1122. 44:54This each search result was fine. Uh did
  1123. 44:57it have the right data but the wrong
  1124. 44:59conclusion? Then that is a reasoning
  1125. 45:00error. That is uh definitely what
  1126. 45:03happened here. Right? It saw two
  1127. 45:05different bits of data and it did not
  1128. 45:07reason correctly about them. Um
  1129. 45:10sometimes it will make numbers up
  1130. 45:11completely. that is a hallucination. Uh
  1131. 45:13and sometimes it will answer a question
  1132. 45:15that isn't the question you asked. So a
  1133. 45:17scope problem. Each cause has a
  1134. 45:19different fix. Uh but if you don't know
  1135. 45:21the cause, you don't know the fix. Which
  1136. 45:23is why reading traces is useful.
  1137. 45:26Um
  1138. 45:28there's a really great way to do this
  1139. 45:30which is
  1140. 45:33let's switch back to slides. Uh you
  1141. 45:36should write notes first and categories
  1142. 45:38second. So look through all of your
  1143. 45:39traces and just write down in human
  1144. 45:41language what you see happening. So this
  1145. 45:43is bad because it does this. This is
  1146. 45:45good because it does that. Uh that is
  1147. 45:48called open coding. Uh another term
  1148. 45:51borrowed from ML. You're just saying uh
  1149. 45:54what you saw. Once you've done that uh
  1150. 45:57you can then do what is called axial
  1151. 45:59coding where you look through all of the
  1152. 46:00notes you've written to yourself and you
  1153. 46:02group them into categories. It is very
  1154. 46:04very tempting as an engineer to g try
  1155. 46:07and guess in advance what the categories
  1156. 46:09are going to be and come up with
  1157. 46:11categories and just put things in
  1158. 46:12categories from the get-go uh because
  1159. 46:14that is less work but you will do worse
  1160. 46:17at it because you will not know in
  1161. 46:19advance what your failure nodes are
  1162. 46:20going to be. Uh so the categories you're
  1163. 46:23going to pick are going to be either too
  1164. 46:24narrow or too broad or just not what not
  1165. 46:26the kind of stuff that actually went
  1166. 46:28wrong. [snorts]
  1167. 46:29Um,
  1168. 46:33while we're talking about this, I talked
  1169. 46:35about how you stack up uh
  1170. 46:39um
  1171. 46:41Kod valves and LLM judgy valves and
  1172. 46:43human evals. Uh this is uh a model
  1173. 46:47barred from the security world called
  1174. 46:49the Swiss cheese model. Um
  1175. 46:53every layer of defense that you have is
  1176. 46:55going to have holes in it. your your
  1177. 46:57every eval you have is going to have a
  1178. 46:59blind spot. What you want to do is uh
  1179. 47:02stack as many eval as you can on top of
  1180. 47:05each other such that it is very hard for
  1181. 47:07an error to get all the way through all
  1182. 47:09of them. Um
  1183. 47:12because they've all got holes but the
  1184. 47:14holes are not in the same place. So if
  1185. 47:16you can uh if you have enough evals, if
  1186. 47:20you have enough different types of check
  1187. 47:22going on, they will stack up on top of
  1188. 47:24each other and be much more reliable.
  1189. 47:27Um so code evals can catch formatting
  1190. 47:30problems, but they will miss problems
  1191. 47:31with meaning. LM judges will catch
  1192. 47:33reasoning gaps, but they will miss some
  1193. 47:34subtle hallucinations. Humans will often
  1194. 47:37catch the subtle stuff, but they can't
  1195. 47:38look at every single trace. So no single
  1196. 47:41method uh is going to catch everything.
  1197. 47:44Um, so today we're building several
  1198. 47:46small evals, not one giant super eval,
  1199. 47:49which is also another failure mode. When
  1200. 47:51people first get into evals, they're
  1201. 47:52like, I'm going to think of every
  1202. 47:54possible thing that can go wrong and I'm
  1203. 47:56going to cram it into one big LLM as a
  1204. 47:57judge, and it's going to find
  1205. 47:59everything. And that is uh a very
  1206. 48:02unreliable and very complicated way of
  1207. 48:04not solving the problem.
  1208. 48:08So, whoops.
  1209. 48:14Uh
  1210. 48:21so the agent may call uh
  1211. 48:25the agent is going to do a whole bunch
  1212. 48:26of stuff. This is what the agent output
  1213. 48:28looks like. I showed you already in
  1214. 48:29Phoenix. Um
  1215. 48:32we've I've already showed you uh the
  1216. 48:34various things that uh it came up with.
  1217. 48:39Um,
  1218. 48:41in this case, uh, my coding agent looked
  1219. 48:45through all of my traces for me. It came
  1220. 48:47up with, uh, both, uh, open coding and
  1221. 48:51aial coding, uh, and it came up with a
  1222. 48:54category, uh, called harness leakage.
  1223. 48:57Uh, harness leakage is what it decided
  1224. 49:00to call that thing where it's constantly
  1225. 49:02asking us to give it permission to do
  1226. 49:04things that it doesn't have permission
  1227. 49:05to do. Um,
  1228. 49:09so, uh,
  1229. 49:12that's a ton of that's a ton of times
  1230. 49:14for that specific thing to happen.
  1231. 49:16[snorts] Um, there are also a bunch it
  1232. 49:18also found a bunch of other things. It
  1233. 49:19found hallucination. It found uh,
  1234. 49:21reasoning errors like the Tesla one
  1235. 49:23where it had too many it added up
  1236. 49:25percentages. Um if you're doing if
  1237. 49:29you've run this data yourself and you've
  1238. 49:30come up with your coding agent has uh
  1239. 49:33produced its own analysis, you're going
  1240. 49:35to get a different analysis and a
  1241. 49:36different set of uh labels. Uh because
  1242. 49:40all of our agents are different. Who has
  1243. 49:42got their coding agent to complete an
  1244. 49:43analysis yet? Anybody still running?
  1245. 49:48>> All right. Well, we'll keep going.
  1246. 49:50Hopefully, you'll get some, but if not,
  1247. 49:52you can just use my seed data.
  1248. 49:56Uh once you've got data, you can count
  1249. 49:58the categories. The most common failure
  1250. 50:00is going to be where you look first, but
  1251. 50:03the most common failure is not
  1252. 50:04necessarily the first thing that you're
  1253. 50:05going to fix. What you want to do is
  1254. 50:07address uh frequency and severity. So if
  1255. 50:12uh you know 40% of the time it
  1256. 50:15hallucinates, that's a problem. If 1% of
  1257. 50:17the time it gives your user instructions
  1258. 50:20on how to build a bomb, you fix that
  1259. 50:22immediately even though it happens only
  1260. 50:231% of the time because that's absolutely
  1261. 50:25not what a financial analyst is supposed
  1262. 50:26to be doing. Uh so you multiply
  1263. 50:29frequency by severity to get your
  1264. 50:31priority.
  1265. 50:32All right, so hopefully your agents will
  1266. 50:35catch up to where we are, but I'm going
  1267. 50:37to keep going. Step three is Kodi
  1268. 50:39valves. Kodi valves are the simple ones.
  1269. 50:41There's no model, there's no API call,
  1270. 50:43there's just TypeScript.
  1271. 50:45Uh the simplest useful eval that I could
  1272. 50:48think of was does the report actually
  1273. 50:50mention the stock that we asked about.
  1274. 50:52Our agent is supposed to analyze a
  1275. 50:54specific company. If it's doing that, it
  1276. 50:56should mention the ticker symbol of the
  1277. 50:57company that it is analyzing. Uh if I
  1278. 51:00ask about Tesla and it writes about
  1279. 51:01Microsoft, which is a thing that it
  1280. 51:03really did on at least one occasion, um
  1281. 51:06that is a completely useless report. So
  1282. 51:08either the ticker report, the ticker is
  1283. 51:10in the report or it isn't. and using an
  1284. 51:12LLM to check that would be complete
  1285. 51:14overkill.
  1286. 51:15Uh
  1287. 51:17so to run that check, the first thing
  1288. 51:19that we need to do do is get our data
  1289. 51:22out of Phoenix so that we can run the
  1290. 51:23analysis. This is how that is done. Um
  1291. 51:26we ask for spans for our project and
  1292. 51:28parent ID null means that only spans
  1293. 51:30that have no parent. Um so those are the
  1294. 51:33top level spans. So the ones that I was
  1295. 51:35showing you in my traces. Um, the repo
  1296. 51:39runs this in a little helper called get
  1297. 51:40agent runs, which hands back each run
  1298. 51:42span ID, its input, and its output, plus
  1299. 51:44the research turns output, uh, which
  1300. 51:46we're going to need later.
  1301. 51:49Uh, and then this is the ticker check.
  1302. 51:52Um,
  1303. 51:53create evaluator comes from the Phoenix
  1304. 51:55evals package. You can just give it an
  1305. 51:57ordinary function. You don't have to
  1306. 51:58build an evaluator function yourself.
  1307. 52:00Uh, all you have to do is tell it that
  1308. 52:02this is a code eval so that no LLM is
  1309. 52:04involved. The function gets the input
  1310. 52:06and the output. It uh splits out the
  1311. 52:08tickers we asked about. Uh it checks
  1312. 52:11that each one appears in the report. Uh
  1313. 52:13and it returns a label and a score. And
  1314. 52:15if something's missing, it also it also
  1315. 52:17says which ticker. So the failure
  1316. 52:19explains itself.
  1317. 52:21Um the structured inputs that I talked
  1318. 52:24about earlier, how we the input being
  1319. 52:26sent uh to our tool was JSON, that is
  1320. 52:29helping us out here because it's making
  1321. 52:30it really easy to write this Kodi val
  1322. 52:32because it's already JSON. So we already
  1323. 52:34know uh which thing is the ticker and
  1324. 52:37which thing is the uh description of the
  1325. 52:40uh report that it should be writing.
  1326. 52:42[snorts] Um so if you can get uh your
  1327. 52:46inputs to be structured data that's
  1328. 52:48going to make your evals really easy to
  1329. 52:50work with. But if not you're going to
  1330. 52:51have to get another LLM involved to read
  1331. 52:53your input figure out what the input was
  1332. 52:55and then pass it to your eval.
  1333. 52:58Uh then we run it and we log the results
  1334. 53:01back to Phoenix. So the script runs the
  1335. 53:03evaluator on every agent run and then it
  1336. 53:05calls log span annotations which
  1337. 53:07attaches each result to its span. Um
  1338. 53:10that's going to be the same pattern for
  1339. 53:11every single eval we run today. You get
  1340. 53:13the runs uh you evaluate them and then
  1341. 53:15you log the results back to Phoenix. Uh
  1342. 53:19so
  1343. 53:21uh the command here is npm run eval
  1344. 53:24code. Let me see if I can get that to
  1345. 53:25work.
  1346. 53:39All right, it worked and it ran almost
  1347. 53:41instantly because it's Kod valves. They
  1348. 53:43don't have to wait for an LLM to do
  1349. 53:44anything. They just go [snorts]
  1350. 53:46uh and it has reported 15 fastes and two
  1351. 53:50failures. One is Tesla is missing Tesla
  1352. 53:52and one is Amazon is missing Amazon. Uh
  1353. 53:56so uh
  1354. 54:00this is the dumbest possible check that
  1355. 54:01we could have made. Did the LLM actually
  1356. 54:03write a report about the thing that we
  1357. 54:05asked it about? Write a report about and
  1358. 54:07it has already found some errors. It has
  1359. 54:09found cases uh where it wrote about the
  1360. 54:12wrong thing. I know for instance that
  1361. 54:14the am the problem with Amazon is uh
  1362. 54:17that it asked it about AWS profitability
  1363. 54:20and the agent got focused on AWS and
  1364. 54:23wrote a report that was only about AWS
  1365. 54:25and what AWS was doing uh and not about
  1366. 54:28what Amazon, you know, the shopping
  1367. 54:30company does. Um so this is a test worth
  1368. 54:35doing and it cost you absolutely nothing
  1369. 54:37to run. So Kod valves aren't toys. So,
  1370. 54:41did the output parses JSON? Is it under
  1371. 54:43the length limit? Does it avoid phrases
  1372. 54:45you never want to see like as an AI
  1373. 54:47language model? Um, and it doesn't have
  1374. 54:50to be a string check. Kodval just means
  1375. 54:52that the grading is deterministic. So,
  1376. 54:55uh, your Kodval can be querying your
  1377. 54:57database to make sure that the state is
  1378. 54:58correct. It can make sure that the tool
  1379. 55:00calls did what the tool calls were
  1380. 55:02supposed to do. uh it can call an API
  1381. 55:05and double check that the stock price uh
  1382. 55:07that the agent thinks is happening is
  1383. 55:09really the stock price. Um anything that
  1384. 55:12gives the same answer for the same input
  1385. 55:14every time can become a Kodi val. So
  1386. 55:16your Kodi valves can be quite advanced.
  1387. 55:19Um but one thing you should be wary of
  1388. 55:21is grading the outcome and not the path.
  1389. 55:24Uh there's a tempting mistake here um to
  1390. 55:27check that the agent took particular
  1391. 55:29steps. Did it call the search tool first
  1392. 55:31and then this other tool? Uh, Anthropic
  1393. 55:34advises that this is too rigid an
  1394. 55:36approach. Uh, like we saw earlier, the
  1395. 55:40agent can be creative. It can do things
  1396. 55:41in an unexpected way. You don't want to
  1397. 55:44assume that it's always going to do
  1398. 55:46exactly what you would have done. Uh, so
  1399. 55:48you don't want to grade the path that it
  1400. 55:50took. You want to grade whether or not
  1401. 55:52the outcome was good.
  1402. 55:55um our ticket check doesn't care how
  1403. 55:57care how the agent found its data right
  1404. 55:59it just cares that the right company is
  1405. 56:01in the report and that is the right
  1406. 56:03level for a lot of evals we will talk
  1407. 56:05later about trajectory level evals where
  1408. 56:07we do actually want to grade the path
  1409. 56:09but that is a very different uh kettle
  1410. 56:11of fish
  1411. 56:13so that brings us to step four the LLM
  1412. 56:16as a judge uh and we're going to start
  1413. 56:19with Phoenix's builtin evals
  1414. 56:22Um
  1415. 56:24code can't check whether code can check
  1416. 56:26whether the ticker is in the report but
  1417. 56:28it can't tell you if the analysis is any
  1418. 56:29good. Uh are the numbers accurate? Is
  1419. 56:31the report report complete? Is the
  1420. 56:33recommendation well reasoned? These are
  1421. 56:35questions about the meaning of the
  1422. 56:37report not the textual content of the
  1423. 56:39report. And for those you need uh
  1424. 56:41something that has judgment. Uh an LLM
  1425. 56:44judge has three parts. It has a judge
  1426. 56:46model which is the LM that is doing the
  1427. 56:47judging. Uh it has a rubric which is the
  1428. 56:50prompt that tells it what good looks
  1429. 56:51like. And then it has the data which is
  1430. 56:53the examples that it's grading. Phoenix
  1431. 56:55keeps those three separate so you can
  1432. 56:57mix and match. You can try the same
  1433. 56:58rules with different models. You can try
  1434. 57:00the same judge with different rules.
  1435. 57:03Uh the good news for you is that Phoenix
  1436. 57:06ships a bunch of built-in evals. So you
  1437. 57:08don't always have to write your own
  1438. 57:10evals, at least not right off the bat.
  1439. 57:12Uh there's correctness which checks if
  1440. 57:14the answer is accurate. Uh there's
  1441. 57:16faithfulness which checks if it sticks
  1442. 57:18to the source material. Uh we're going
  1443. 57:20to see the difference between those two
  1444. 57:21in a second. Uh there's completeness,
  1445. 57:24hallucination, refusal, PII, and
  1446. 57:26toxicity. Lots of things that lots of
  1447. 57:28agents need to check are built in. Uh
  1448. 57:32and for agents, there are evals for tool
  1449. 57:34use. Did it pick the right tool? Did it
  1450. 57:35pass the right arguments? Um did it do
  1451. 57:38something sensible with with the result?
  1452. 57:41Uh these eval are not magical. They are
  1453. 57:45just uh prompts that we've already
  1454. 57:48written and battle tested and made sure
  1455. 57:50work for you.
  1456. 57:52Uh
  1457. 57:55so let's find the judge model. Um
  1458. 58:00uh Phoenix evals in Typescript uh use
  1459. 58:03the Versel AI SDK to talk to models. So
  1460. 58:06any model that the AI SDK supports can
  1461. 58:08be a judge. Uh in this case I'm using
  1462. 58:12Claude Sonnet 5.5. Um, the agent runs on
  1463. 58:15Haiku. Like I said, it's cheap and fast.
  1464. 58:18Our judge is running on Sonnet because
  1465. 58:19you want your judge to be more capable
  1466. 58:21than the agent itself was. So, give it
  1467. 58:24Sonnet or give it Opus. Uh, or give it
  1468. 58:27uh even better um give it a model from
  1469. 58:31uh a different provider entirely. If
  1470. 58:33you've got an OpenAI key, get OpenAI to
  1471. 58:35judge the work of Claude. Uh because
  1472. 58:37Claude has what is known as uh same
  1473. 58:40model bias. So Claude tends to like the
  1474. 58:42output of other versions of Claude uh
  1475. 58:45more than it does the output of uh of
  1476. 58:47OpenAI or some other provider.
  1477. 58:50Um
  1478. 58:52the last line here uh in case you're
  1479. 58:55wondering is suppressing tracing on the
  1480. 58:57judge because we turned on tracing
  1481. 58:59across the board. The judge is itself a
  1482. 59:01copy of Claude. Uh so by default and in
  1483. 59:05fact in my test data you will see that I
  1484. 59:08forgot to turn on uh uh telemetry
  1485. 59:11suppression. So my traces are full of
  1486. 59:13the the judge running itself and and
  1487. 59:16seeing all of the traces from the judge
  1488. 59:18which you don't need. Um
  1489. 59:23so every evaluator in this repo gets it
  1490. 59:26gets this telemetry setting uh so that
  1491. 59:28the judge stays out of uh our agent. Um
  1492. 59:32let's start with correctness. Uh which
  1493. 59:35is the obvious first choice. Is the uh
  1494. 59:37is this report correct? Um that is one
  1495. 59:40import and one line of setup. You don't
  1496. 59:42have to do anything. You just say hey
  1497. 59:44I'm running the correctness evaluator.
  1498. 59:46Run it on my stuff and let's see how it
  1499. 59:48goes. Uh then you call evaluate and you
  1500. 59:51get back a label, a score, and an
  1501. 59:53explanation. And the script runs it on
  1502. 59:54every agent run and logs the results
  1503. 59:56back to Phoenix. Uh the same way we did
  1504. 59:58the ticker check. Uh,
  1505. 1:00:02I should be able to run that as well.
  1506. 1:00:12That's going to take a little while
  1507. 1:00:13because it has to actually do some LLM
  1508. 1:00:15stuff. Uh,
  1509. 1:00:18if it works, it works. If it doesn't, I
  1510. 1:00:20have stuff already built in.
  1511. 1:00:26So you can see uh in my annotations
  1512. 1:00:29column you can see the results of
  1513. 1:00:31various evaluations I've already run. In
  1514. 1:00:33this case it's showing you the uh
  1515. 1:00:35actionability one but you can see uh
  1516. 1:00:38correctness, faithfulness, human
  1517. 1:00:39actionable uh and mention sticker. We're
  1518. 1:00:42going to talk about what all of those
  1519. 1:00:43are. But first you're going to see
  1520. 1:00:44correctness. Uh correctness on all of
  1521. 1:00:48these is zero. Uh,
  1522. 1:00:54all 16 reports have been judged as
  1523. 1:00:56incorrect. And the reason that they've
  1524. 1:00:58been judged as incorrect is because
  1525. 1:01:00Claude judges correctness by what it
  1526. 1:01:03knows. That's the only thing that it has
  1527. 1:01:05available to it. And Claude's knowledge
  1528. 1:01:08cut off uh at the moment is in something
  1529. 1:01:10like January. So uh my agent is talking
  1530. 1:01:14about stock prices in October and Claude
  1531. 1:01:16is freaking out and going, "You're
  1532. 1:01:18talking about stuff that's in the
  1533. 1:01:19future. That's obviously a
  1534. 1:01:20hallucination. This report cannot
  1535. 1:01:22possibly possibly correct. So our
  1536. 1:01:24built-in check for correctness fails
  1537. 1:01:26every single report for that reason. Um
  1538. 1:01:30which is not terribly useful. Um
  1539. 1:01:35so the eval is half wrong and half
  1540. 1:01:37right. Seven of in my data, seven of the
  1541. 1:01:3916 explanations complain that the judge
  1542. 1:01:41can't verify fresh data. Uh which is the
  1543. 1:01:44eval definitely being wrong. Um, but
  1544. 1:01:46lots of them also point out something
  1545. 1:01:48real. Things like the numbers don't add
  1546. 1:01:50up or dates that contradict each other.
  1547. 1:01:52Um, so a score of zero is telling us
  1548. 1:01:55nothing here. It's telling us across the
  1549. 1:01:56board that this that this eval is
  1550. 1:01:58probably not the right choice of eval.
  1551. 1:02:01Um, what we want is a question that the
  1552. 1:02:04judge uh can actually answer.
  1553. 1:02:08So uh
  1554. 1:02:13oh, I told you that already. All right.
  1555. 1:02:15uh what we're going to use instead is
  1556. 1:02:16faithfulness. Faithfulness is asking a
  1557. 1:02:19much better question. It's saying given
  1558. 1:02:20the data that you had, did your did your
  1559. 1:02:23report make sense? Did is the answer
  1560. 1:02:26based in the data that we were given?
  1561. 1:02:28This works much better because it can
  1562. 1:02:29work with data this exactly the same
  1563. 1:02:31data that the agent was given and see if
  1564. 1:02:33it gets a report that makes sense. Uh so
  1565. 1:02:38that's a question the judge can actually
  1566. 1:02:39answer. Uh and the context is already in
  1567. 1:02:41the trace. Every web search is its own
  1568. 1:02:44span like we saw. Um, every research
  1569. 1:02:47turns output is the agent's own notes on
  1570. 1:02:49what it found. So my first version, my
  1571. 1:02:52first eval uh only gave the judge uh the
  1572. 1:02:55research notes and then I read the
  1573. 1:02:57explanations and the judge was flagging
  1574. 1:02:58numbers as made up uh because my version
  1575. 1:03:01of the eval hadn't told it that oh I I
  1576. 1:03:03searched the web and actually found this
  1577. 1:03:05data. Uh so uh in the version you see
  1578. 1:03:08we've given it the full context. um our
  1579. 1:03:12get agent runs helper is going to pull
  1580. 1:03:14both uh the raw search results and the
  1581. 1:03:18notes so that it can see uh what the
  1582. 1:03:22research agent found and how it found
  1583. 1:03:24that data.
  1584. 1:03:27Uh so like I said faithfulness takes
  1585. 1:03:28three things. It takes the input which
  1586. 1:03:30is what the user asked. It takes the
  1587. 1:03:32output which is the report and it takes
  1588. 1:03:33the context which is the search results
  1589. 1:03:35and the notes that I was just talking
  1590. 1:03:36about. [snorts]
  1591. 1:03:37Uh and you run it using the same pattern
  1592. 1:03:40as before. You create the evaluator, you
  1593. 1:03:41evaluate every run, you log the results.
  1594. 1:03:44Um,
  1595. 1:03:46like I said, it's slower than
  1596. 1:03:47correctness uh because the judge is
  1597. 1:03:50reading every search. Uh, who has got
  1598. 1:03:53any results out of their uh eval so far?
  1599. 1:03:58Again, you've got a faster Wi-Fi
  1600. 1:04:00connection than everybody else. Anybody
  1601. 1:04:01else?
  1602. 1:04:04Cool.
  1603. 1:04:06Um,
  1604. 1:04:08so let's look in Phoenix at my
  1605. 1:04:10faithfulness reports. Um,
  1606. 1:04:16I got a lot of zeros on faithfulness,
  1607. 1:04:17but not all of them.
  1608. 1:04:22Um,
  1609. 1:04:23let's read the Microsoft explanation.
  1610. 1:04:26That was the one that I read that was
  1611. 1:04:27most interesting.
  1612. 1:04:30Uh, as you can see, next to each one,
  1613. 1:04:32you get the explanation. Um, so in this
  1614. 1:04:35one, the response adds several claims
  1615. 1:04:37that the context does not support. Azure
  1616. 1:04:39is the number two cloud provider. The
  1617. 1:04:41backlog gives three years of visibility
  1618. 1:04:43and there are implied FY202 targets. Uh,
  1619. 1:04:50it is telling me what it doesn't like
  1620. 1:04:52about uh this thing. It does it's
  1621. 1:04:55telling me why it thinks this thing is
  1622. 1:04:56unfaithful. Um,
  1623. 1:05:00it's complaining that uh some of the
  1624. 1:05:042027 targets are fabricated because
  1625. 1:05:06they're not in any search results. Uh,
  1626. 1:05:09the Nvidia one is also interesting
  1627. 1:05:14if I can find that one.
  1628. 1:05:20Right. In this one, it says the response
  1629. 1:05:22conflates two different data points.
  1630. 1:05:23This is a reasoning error that the agent
  1631. 1:05:25that the judge has uh accurately found.
  1632. 1:05:28Um
  1633. 1:05:31it says the context information this is
  1634. 1:05:33fabricated. These are much more useful
  1635. 1:05:35results. We've got uh 14 out of 16 uh
  1636. 1:05:39reports marked as unfaithful here, but
  1637. 1:05:41the explanations are way more useful. Uh
  1638. 1:05:44and it's actually doing the thing that
  1639. 1:05:45we wanted it to do. Um
  1640. 1:05:50so for agents, you can also grade the
  1641. 1:05:51tool calls. Uh so we saw the web search
  1642. 1:05:54spans inside each trace. Phoenix has
  1643. 1:05:56built-in evals for all of those as well.
  1644. 1:05:59Tool selection asks did the agent pick
  1645. 1:06:01the right tool uh or search when it
  1646. 1:06:04didn't need to. Tool invocation asks did
  1647. 1:06:06it pass sensible arguments to those
  1648. 1:06:08tools like a search query that's
  1649. 1:06:10actually about the company. And tool
  1650. 1:06:12response handling asks did it do
  1651. 1:06:13something sensible uh with the result of
  1652. 1:06:16that call.
  1653. 1:06:17Uh these are the decisions that can make
  1654. 1:06:19a break make or break an agent. Um, and
  1655. 1:06:23they all happen before the report
  1656. 1:06:24actually gets read. Uh, and we already
  1657. 1:06:27know our agent makes strange tool
  1658. 1:06:28choices sometimes, like it tries to save
  1659. 1:06:30the report to a file. Uh, so we can see
  1660. 1:06:33if our built-in eval catches that. Uh,
  1661. 1:06:37I'm not going to run this one, but you
  1662. 1:06:38can run that one. Um, tool selection
  1663. 1:06:41takes three things. What the agent was
  1664. 1:06:43asked, which tools it could have used,
  1665. 1:06:44and which ones it picked. Uh and the
  1666. 1:06:46script goes through every agent turn and
  1667. 1:06:48every trace research and writing
  1668. 1:06:49separately and collects the tool spans
  1669. 1:06:51underneath each one. Um the trace
  1670. 1:06:54records which tools the agent called but
  1671. 1:06:57not which ones it could have called. So
  1672. 1:06:58we have to write that list ourselves uh
  1673. 1:07:01in tool selection.ts.
  1674. 1:07:03Uh then it is uh the same pattern as
  1675. 1:07:06every other run. Uh so npm run eval
  1676. 1:07:10tools uh and then you're done. Uh that
  1677. 1:07:12one should take about 15 seconds.
  1678. 1:07:17So, let's look in Phoenix at
  1679. 1:07:20tool selection.
  1680. 1:07:38Tool selection. It's helping me out.
  1681. 1:07:44All right. So, these are ones where it
  1682. 1:07:46has decided that my tool selection was
  1683. 1:07:48incorrect for whatever reason. Uh, the
  1684. 1:07:51user asked for a concise report based on
  1685. 1:07:53prior research. Writing it to a file
  1686. 1:07:55with write is plausible and appropriate
  1687. 1:07:57since write exists and is safe. Uh,
  1688. 1:07:59however, the LLM made a second redundant
  1689. 1:08:02bash call. Awesome. Uh, yeah, it sure
  1690. 1:08:06did. Um,
  1691. 1:08:09the judge failed six that tried twice.
  1692. 1:08:12It passed seven. Six of the seven that
  1693. 1:08:14tried once. Uh
  1694. 1:08:16uh overall 13 of my 16 writing turns
  1695. 1:08:19tried to save a file. Um
  1696. 1:08:25and only one of these explanations said
  1697. 1:08:27that the user never asked for a file to
  1698. 1:08:30be saved. So uh is this judge incorrect?
  1699. 1:08:34Is the judge uh accurately judging that
  1700. 1:08:37the tool call was correct? Um, our
  1701. 1:08:40writing prompt said, "Write a concise
  1702. 1:08:43financial report based on your research
  1703. 1:08:45above." Our prompt is genuinely
  1704. 1:08:47ambiguous here. We said, "Write, we
  1705. 1:08:49didn't say where to write it to. We
  1706. 1:08:51didn't say what to write it for. Uh, we
  1707. 1:08:53didn't say who the audience was going to
  1708. 1:08:54be." So, the tool selection knows that
  1709. 1:08:56and is looking at the input and is
  1710. 1:08:57going, "Well, it seems a reasonable
  1711. 1:08:59thing for the agent to try and write to
  1712. 1:09:01disk here." Uh so again what you're
  1713. 1:09:06telling the agent to do and what you're
  1714. 1:09:08telling the eval to do interact with
  1715. 1:09:10each other. Uh you can't necessarily
  1716. 1:09:13trust that the tool call invocation is
  1717. 1:09:15going to be right because in this case
  1718. 1:09:17the tool call is citing the tool call
  1719. 1:09:19eval is siding with the agent. It's like
  1720. 1:09:21no the the agent is right. The agent
  1721. 1:09:23gave us instructions uh the agent
  1722. 1:09:26received instructions and did its best
  1723. 1:09:27is basically the eval's position. Uh,
  1724. 1:09:34eval results live in the trace as well.
  1725. 1:09:37Um,
  1726. 1:09:39so if you're looking at the traces in
  1727. 1:09:41Phoenix, uh, you can see them here
  1728. 1:09:44attached to which trace they got, which
  1729. 1:09:47span in the trace they got attached to.
  1730. 1:09:48So you see actionability and correctness
  1731. 1:09:50got attached to the root. Uh, whereas
  1732. 1:09:52tool selection is getting attached to
  1733. 1:09:54the specific uh, turn that made that
  1734. 1:09:57tool call.
  1735. 1:09:58Um, you can filter your traces by any
  1736. 1:10:01eval. Uh, you can sort by score to find
  1737. 1:10:03your worst runs. You can click straight
  1738. 1:10:05from a failing score into the step that
  1739. 1:10:06caused it. Uh, from score to from score
  1740. 1:10:09to cause in one click. Uh, so all of
  1741. 1:10:12that is the built-in eval.
  1742. 1:10:15Um,
  1743. 1:10:17and the lesson here is that choosing the
  1744. 1:10:19right eval beats tuning it. Choosing
  1745. 1:10:21correctness was entirely the wrong eval.
  1746. 1:10:23It didn't tell us anything. It just told
  1747. 1:10:24us a bunch of stuff was wrong. tool
  1748. 1:10:26selection did tell us something uh and
  1749. 1:10:28faithfulness told us quite a lot. Um
  1750. 1:10:33so checking the right eval beats tuning
  1751. 1:10:35it uh and knowing which question you're
  1752. 1:10:37actually asking is really the core of
  1753. 1:10:40getting this right
  1754. 1:10:42which brings us to step five which is
  1755. 1:10:44writing your own judge. This is where
  1756. 1:10:45the eval get specific to your
  1757. 1:10:47application.
  1758. 1:10:49Uh, and again, this is when people are
  1759. 1:10:51thinking about evals, this is what most
  1760. 1:10:53people are thinking about, but I wanted
  1761. 1:10:55to make sure that you got the basics in
  1762. 1:10:56first. You don't have to jump straight
  1763. 1:10:58to writing a custom rubric. You can
  1764. 1:11:00write code evals to get a bunch of stuff
  1765. 1:11:02out of the way. You can write uh you can
  1766. 1:11:04use built-in eval to do a bunch of
  1767. 1:11:06obvious stuff without having to invent
  1768. 1:11:08your own tool calling correctness uh uh
  1769. 1:11:12evaluator.
  1770. 1:11:13Um,
  1771. 1:11:16what I wanted my report to do was give
  1772. 1:11:18me a buy, sell, or hold recommendation.
  1773. 1:11:20There is no built-in eval that checks
  1774. 1:11:22for that because that would be a very
  1775. 1:11:23specific thing indeed. So, we're going
  1776. 1:11:25to write our own. Uh, every eval prompt
  1777. 1:11:28I've seen that works well has five
  1778. 1:11:30different parts and we're going to go
  1779. 1:11:32through them one at a time. The first
  1780. 1:11:34part is you give the judge a role and
  1781. 1:11:37context. Uh, a thing you'll see all the
  1782. 1:11:40time is you are an expert blah blah blah
  1783. 1:11:42blah blah. That does actually work.
  1784. 1:11:45That's why everybody puts it in there.
  1785. 1:11:46Like it helps a little bit to tell the
  1786. 1:11:48to tell the agent what it is. Uh,
  1787. 1:11:51telling it it's an expert as opposed to
  1788. 1:11:53just telling it that it is running up
  1789. 1:11:55something else also seems to make a
  1790. 1:11:57difference when they do sideby-side
  1791. 1:11:59comparisons. Um, it's just one of the
  1792. 1:12:02weird things about LLMs. You need to
  1793. 1:12:03tell it it's really smart and it gets
  1794. 1:12:04like confident and tries. Um
  1795. 1:12:09uh but what really matters is the
  1796. 1:12:10context. Um this is a financial report.
  1797. 1:12:14Uh we are expecting a report that that
  1798. 1:12:17analyzes financial data and tells us
  1799. 1:12:19real things. Um
  1800. 1:12:21and specifically what we care about is
  1801. 1:12:23whether or not you could act on it. So
  1802. 1:12:26uh that gives us the explicit criteria
  1803. 1:12:28that we include in our rubric. Um so
  1804. 1:12:32this is where a lot of people don't put
  1805. 1:12:33in enough effort. So don't write a good
  1806. 1:12:36response is helpful and accurate because
  1807. 1:12:38uh a judge doesn't know what helpful and
  1808. 1:12:40it doesn't know what accurate means in
  1809. 1:12:42this context. Um a judge can't make a
  1810. 1:12:45yes or no decision from that. Write down
  1811. 1:12:48exactly what makes a report actionable.
  1812. 1:12:50Uh so it makes a specific
  1813. 1:12:52recommendation. It names concrete risks
  1814. 1:12:54and it looks forward not just back.
  1815. 1:12:56Those are things that a judge can look
  1816. 1:12:57at and actually check.
  1817. 1:13:00Uh, and note that we're not just making
  1818. 1:13:03up these things blind. Um, your criteria
  1819. 1:13:06come from your error analysis. Uh, only
  1820. 1:13:10summarizes data with no interpretation
  1821. 1:13:12is a problem that we saw when we were
  1822. 1:13:13reading our traces. We are putting that
  1823. 1:13:15in there because it's a problem that we
  1824. 1:13:16are trying to avoid. Um, that is the
  1825. 1:13:20whole point of reading the data first.
  1826. 1:13:21Specific criteria give you consistent
  1827. 1:13:24judgments and you get specific criteria
  1828. 1:13:26by knowing in advance what the data is
  1829. 1:13:28going to look like because you read it
  1830. 1:13:29yourself.
  1831. 1:13:31Part three of a good rubric is to mark
  1832. 1:13:34the data clearly. Wrap each piece of
  1833. 1:13:35data in its own XML tag. Claude was
  1834. 1:13:38trained on billions and billions of XML
  1835. 1:13:40tags and it's really good at working
  1836. 1:13:41with them. Um,
  1837. 1:13:44if you look into the code at our own
  1838. 1:13:46rubrics, that's what we're doing. uh our
  1839. 1:13:48own prompts [snorts] uh wrap everything
  1840. 1:13:50in XML tags. Um and the double curly
  1841. 1:13:54braces are template variables that
  1842. 1:13:55Phoenix fills in uh with each span's
  1843. 1:13:58input and outputs. Uh the reason you do
  1844. 1:14:01this is because you want clear
  1845. 1:14:02boundaries between what is the input,
  1846. 1:14:04what is the output, and what is your
  1847. 1:14:05instructions. Uh this helps against
  1848. 1:14:07prompt injection, but it also helps uh
  1849. 1:14:10the agent just getting confused. uh in
  1850. 1:14:12particular it helps you get con uh if
  1851. 1:14:15you include examples which we're going
  1852. 1:14:16to see mark the example as an example
  1853. 1:14:19and not the data otherwise it will get
  1854. 1:14:21very confused about that um I love to
  1855. 1:14:25include labeled examples but it is in
  1856. 1:14:26fact a controversial proc uh a
  1857. 1:14:28controversial practice uh in the eval
  1858. 1:14:32world um
  1859. 1:14:35criteria tell the judge what you mean in
  1860. 1:14:37the abstract but examples show it
  1861. 1:14:39exactly what you mean as a human, I find
  1862. 1:14:42it much easier to do something when
  1863. 1:14:43somebody has shown me an example of how
  1864. 1:14:45it's supposed to work than if they've
  1865. 1:14:47just given me a list of instructions of
  1866. 1:14:49how to work. Uh, and, uh, a lot of LLMs
  1867. 1:14:53feel that way as well, apparently. Um,
  1868. 1:14:57so when you test your rubric, uh, which
  1869. 1:15:00we're going to do in the next step, uh,
  1870. 1:15:02test it with examples and without
  1871. 1:15:03examples and see which one does better.
  1872. 1:15:07Uh, because sometimes, uh, examples are
  1873. 1:15:10going to help it do a better job. And
  1874. 1:15:11sometimes, uh, an example will make it
  1875. 1:15:14overfit. It will look at your examples
  1876. 1:15:17and say, well, it doesn't look exactly
  1877. 1:15:18like my example. Or it will try and make
  1878. 1:15:19every output look like your output
  1879. 1:15:21example. Uh, which is less helpful.
  1880. 1:15:24Um, I ran exactly that test on mine. Uh,
  1881. 1:15:28so in the rubric that I used, um, this
  1882. 1:15:32was fascinating in a really nerdy way,
  1883. 1:15:34which is why I included it. Uh, I threw
  1884. 1:15:36out my examples and with the examples,
  1885. 1:15:38the judge agreed with me, uh, 15, 15,
  1886. 1:15:41and 15 times out of 16 in three
  1887. 1:15:43different runs. Uh, and if I threw out
  1888. 1:15:46the examples, it agreed with me 16 times
  1889. 1:15:48twice, all 16 examples, and 15 times
  1890. 1:15:52once. Uh and so I was like I was very
  1891. 1:15:55curious as to how throwing out the
  1892. 1:15:56examples made it better. Uh and the
  1893. 1:15:59specific problem that it was having is
  1894. 1:16:01that in one of the reports it did not
  1895. 1:16:05include
  1896. 1:16:06um
  1897. 1:16:08uh it did not include a list of risks.
  1898. 1:16:10So as a human I read the report and it
  1899. 1:16:13was like Microsoft is a buy and it
  1900. 1:16:15didn't include any risks and I was like
  1901. 1:16:17that's fine. It's still actionable. It
  1902. 1:16:18included a buy. Uh so I marked it as uh
  1903. 1:16:21an actionable report. Uh but my examples
  1904. 1:16:25said you must include risks. And so the
  1905. 1:16:27agent uh the LLM judge was looking at
  1906. 1:16:31the rules and and looking at the
  1907. 1:16:32examples and saying there must be risks
  1908. 1:16:34in here. So this is not actionable
  1909. 1:16:36because there's no risks. So that's
  1910. 1:16:39genuinely an open question as to whether
  1911. 1:16:41or not my human judgment was better or
  1912. 1:16:43worse than the judges. The judge was
  1913. 1:16:45being very strict and I was being loosey
  1914. 1:16:48goosey when I as a human gave myself
  1915. 1:16:50golden data.
  1916. 1:16:51>> Sorry, can I ask a question?
  1917. 1:16:53>> Sure.
  1918. 1:16:53>> So what's your hypothesis then as to
  1919. 1:16:56without the examples
  1920. 1:16:58it agreed with you so it saw that
  1921. 1:17:01Microsoft as being actionable?
  1922. 1:17:03>> Yeah.
  1923. 1:17:03>> Is that is that your hypothesis then
  1924. 1:17:05that like simply because you didn't say
  1925. 1:17:07risk was a necessary element it felt
  1926. 1:17:10that that was a good actionable? I mean,
  1927. 1:17:13it's not a hypothesis like the LLM judge
  1928. 1:17:15comes with an explanation. So, it says
  1929. 1:17:17>> So, it said that that was actionable,
  1930. 1:17:19>> right?
  1931. 1:17:22>> Yeah. So, like I said, in this case,
  1932. 1:17:25it's genuinely unclear whether or not I
  1933. 1:17:28was doing the right thing or the judge
  1934. 1:17:29was doing the right thing. The judge
  1935. 1:17:30decided to interpret the the rubric very
  1936. 1:17:33strictly and I when I was marking these
  1937. 1:17:35things as human actionable or not, uh
  1938. 1:17:38was not being as strict.
  1939. 1:17:41Um,
  1940. 1:17:44here's an example of an actionable one.
  1941. 1:17:46Uh, it has specific numbers. It has
  1942. 1:17:48revenue growth. Uh, it has valuation
  1943. 1:17:50compared to its sector. It names a
  1944. 1:17:52concrete risk. And it ends with a
  1945. 1:17:53recommendation you could actually
  1946. 1:17:54follow, including when you'd change your
  1947. 1:17:56mind. Um, and this is what a not
  1948. 1:17:59actionable one looks like. It isn't
  1949. 1:18:00wrong. Everything in it is is true. It's
  1950. 1:18:03just not very useless. Investors should
  1951. 1:18:05consider various faction uh factors is
  1952. 1:18:08not a recommendation. Um, now that the
  1953. 1:18:11judge has seen both, the hope is that
  1954. 1:18:13it's more consistent on reports that
  1955. 1:18:14fall somewhere in between. Uh, and
  1956. 1:18:17whether it actually is, you find out by
  1957. 1:18:18testing.
  1958. 1:18:20Uh, part five of putting together a
  1959. 1:18:22rubric is you constrain the answer. You
  1960. 1:18:24ask it for things that are actionable or
  1961. 1:18:26not actionable. A thing you used to have
  1962. 1:18:29to do is you used to have to say output
  1963. 1:18:31a string and the string must be the word
  1964. 1:18:32actionable or not actionable. Uh, you
  1965. 1:18:35don't have to do that anymore. what uh
  1966. 1:18:38modern evaluators use tool calls uh to
  1967. 1:18:41put their output. So those uh the
  1968. 1:18:44choices available for that tool call are
  1969. 1:18:46defined in the tool call and not in your
  1970. 1:18:49rubric. Uh which makes them a lot more
  1971. 1:18:51reliable.
  1972. 1:18:54So now it is your turn to write the
  1973. 1:18:56rubric. Uh open evalactionability.ts.
  1974. 1:19:00Uh it has my rubric in it with all five
  1975. 1:19:02parts. Um and you can make it yours. You
  1976. 1:19:05can change the criteria. You can change
  1977. 1:19:06the examples. Uh
  1978. 1:19:09what would make you act on one of these
  1979. 1:19:11reports? What did you see in your own
  1980. 1:19:13traces? Write that down and that should
  1981. 1:19:15become your rubric. Um it will take
  1982. 1:19:18three or four minutes to run. Who has
  1983. 1:19:20managed to stay up with me so far? Like
  1984. 1:19:22who is at this point? Excellent. I have
  1985. 1:19:25multiple hands. Uh like I said, the last
  1986. 1:19:29time I did this workshop, everyone was
  1987. 1:19:31completely lost because the 200 megabyte
  1988. 1:19:34repo. So the fact that anyone's got it
  1989. 1:19:35this is just great for me. Um
  1990. 1:19:40this is how you wire it up. You create a
  1991. 1:19:41classification evaluator which does all
  1992. 1:19:43the plumbing. Uh you give it a name, you
  1993. 1:19:45give it the model. Uh you give it your
  1994. 1:19:49template. Uh and like I said uh out of
  1995. 1:19:52band you give it its out its options. So
  1996. 1:19:54you give it its choices which are
  1997. 1:19:56actionable with a score of one and not
  1998. 1:19:58actionable with a score of zero.
  1999. 1:20:00Um,
  2000. 1:20:03so let's look at actionability in
  2001. 1:20:05Phoenix. [snorts]
  2002. 1:20:22It's so cold in here that my fingers
  2003. 1:20:24have gone all numb and I can't type
  2004. 1:20:25properly.
  2005. 1:20:28Okay.
  2006. 1:20:36So, the report analyzes JPM's rate
  2007. 1:20:38exposure and loan growth uh and a
  2008. 1:20:40forward-looking output, but makes no
  2009. 1:20:42buy, hold, sell recommendations.
  2010. 1:20:44Fantastic. It's doing exactly what it's
  2011. 1:20:45supposed to do. Uh it is complaining
  2012. 1:20:48about uh the lack of recommendation of
  2013. 1:20:50concrete recommendations. Um
  2014. 1:21:00before we look at all of these
  2015. 1:21:01recommendations, we should look at the
  2016. 1:21:02split in the recommendations. Uh in my
  2017. 1:21:05data, five of 16 reports were actionable
  2018. 1:21:08and 11 were counted as not actionable.
  2019. 1:21:11Uh and that is one of the most useful
  2020. 1:21:14types of evals you can get. An eval
  2021. 1:21:16where everything is perfect is not
  2022. 1:21:18particularly helpful. An EVA where
  2023. 1:21:20everything is wrong is also equally
  2024. 1:21:22unhelpful. An EVA where you've got an
  2025. 1:21:24even split that is a hill that you can
  2026. 1:21:26climb. You've suddenly got uh some
  2027. 1:21:28you've got a def a set of examples where
  2028. 1:21:31things are actually working, a set of
  2029. 1:21:33things where uh stuff isn't working and
  2030. 1:21:35you can start figuring out the
  2031. 1:21:37differences between them. Um
  2032. 1:21:43so if you click through these traces,
  2033. 1:21:45I'm not going to bother clicking through
  2034. 1:21:46all these traces. In Rivian it says it
  2035. 1:21:48never makes a buy, hold, sell
  2036. 1:21:49recommendation or any equivalent next
  2037. 1:21:51step. For Nvidia, it said the closing
  2038. 1:21:54investment thesis risk level is
  2039. 1:21:56moderate, is vague rating, not guidance.
  2040. 1:21:58And uh for Meta, the verdict is the is
  2041. 1:22:02only that the position is solid. So this
  2042. 1:22:04is the same problem over and over. It is
  2043. 1:22:06refusing to give concrete buy, sell,
  2044. 1:22:08hold recommendations.
  2045. 1:22:10Um,
  2046. 1:22:14if we
  2047. 1:22:16uh we can open the Phoenix prompt
  2048. 1:22:18template. I'm not going to do it now.
  2049. 1:22:20Um, but uh there's one more rule for
  2050. 1:22:25rubrics, which is that you should treat
  2051. 1:22:26eval prompts as code. Your eval prompts
  2052. 1:22:29going into your into your custom eval
  2053. 1:22:32are extremely sensitive to small changes
  2054. 1:22:34in wording. Um,
  2055. 1:22:37so, uh, one example of that I ran into
  2056. 1:22:41while making this was, uh, I told you
  2057. 1:22:43that you should put XML tags around
  2058. 1:22:45stuff. I forgot to put XML tags around
  2059. 1:22:47my examples to begin with. Uh, and with
  2060. 1:22:51my examples as plain text, uh, I got a
  2061. 1:22:54string of not actionable stuff, uh,
  2062. 1:22:56because it was getting confused about
  2063. 1:22:58what the data was and what my examples
  2064. 1:23:00were. And when I wrapped them in XML
  2065. 1:23:02tags, everything suddenly became
  2066. 1:23:04actionable because it could tell what I
  2067. 1:23:05was talking about. Um,
  2068. 1:23:09this is there was no other change. I'd
  2069. 1:23:12given it the same data, the same
  2070. 1:23:13instructions, the same input and the
  2071. 1:23:15same output every time. Uh, it just got
  2072. 1:23:17less confused in the evaluator as to
  2073. 1:23:20what was happening. Uh, so you have to
  2074. 1:23:23treat your evals as code. You should
  2075. 1:23:25version them, you should check them, and
  2076. 1:23:26you should test them.
  2077. 1:23:29Um, as I mentioned earlier, uh, there is
  2078. 1:23:33a trap to fall into with evaluators,
  2079. 1:23:34which is to try and write write one
  2080. 1:23:36evaluator that does everything for you.
  2081. 1:23:38It is called the god evaluator because
  2082. 1:23:40it is such a a common pattern. Uh, you
  2083. 1:23:43try and get it to check accuracy, tone,
  2084. 1:23:45completeness, formatting, policy all in
  2085. 1:23:47a single prompt. Uh, and it is a
  2086. 1:23:49nightmare because if it fails, what
  2087. 1:23:52thing failed? Was it inaccurate? Was the
  2088. 1:23:53the tone wrong? Was the faithfulness
  2089. 1:23:55wrong? which of the many many many
  2090. 1:23:56things that you've told this god
  2091. 1:23:58evaluator to evaluate is it actually
  2092. 1:24:00wrong and you try and solve that by
  2093. 1:24:02giving it 15 labels that it can spit out
  2094. 1:24:05uh and the whole thing becomes very hard
  2095. 1:24:07to track. Uh the best practice is to
  2096. 1:24:10split this up split your evaluators into
  2097. 1:24:13as many dimensions as you are testing.
  2098. 1:24:15So one for faithfulness, one for
  2099. 1:24:16correctness, one for actionability.
  2100. 1:24:19Um,
  2101. 1:24:21and you should also know which one of
  2102. 1:24:22your evals is a guardrail and which one
  2103. 1:24:24is a north star. So, a guardrail is
  2104. 1:24:26something that should block the release.
  2105. 1:24:28So, if the agent is making up a stock
  2106. 1:24:30price, that should halt shipping. Uh,
  2107. 1:24:34but north stars are things that you're
  2108. 1:24:36aiming for. So, suggests other stocks
  2109. 1:24:38worth a look would be nice to have. That
  2110. 1:24:40would be a good thing to include. Your
  2111. 1:24:41eval can look for that, but it doesn't
  2112. 1:24:43have to gate shipping on that.
  2113. 1:24:47Which brings us to step six, which is
  2114. 1:24:49testing your tests. We've built a judge
  2115. 1:24:51and it says that some of our reports
  2116. 1:24:52aren't actionable. Uh but can we trust
  2117. 1:24:55the judge? How do we know that the judge
  2118. 1:24:57is right? Uh the trick to remember is
  2119. 1:25:00that your judge is a classifier in the
  2120. 1:25:02classic ML sense. Uh it is looking at a
  2121. 1:25:05report and it is predicting a label as
  2122. 1:25:07actionable or not actionable.
  2123. 1:25:08Predictions uh can be right or wrong. So
  2124. 1:25:12like any classifier, you measure it by
  2125. 1:25:14comparing its predictions with the
  2126. 1:25:15truth. Uh, and here the truth is what a
  2127. 1:25:17human expert would say. You get to judge
  2128. 1:25:20uh you get to mark the judge's homework.
  2129. 1:25:23Uh,
  2130. 1:25:24in this case, the human expert is going
  2131. 1:25:26to be me. I'm going to be deciding
  2132. 1:25:27whether or not stocks are buy, sell, or
  2133. 1:25:29hold. Uh, not necessarily the expert
  2134. 1:25:33that you want. Uh, but we're doing our
  2135. 1:25:36best. It's just a demo. Um, how you do
  2136. 1:25:39this is very simple. You open up a
  2137. 1:25:42trace.
  2138. 1:25:44uh you click the little pencil button
  2139. 1:25:46and you can add annotations. So I have
  2140. 1:25:50created an annotation in advance called
  2141. 1:25:52human actionable uh and I can set it to
  2142. 1:25:55actionable or not actionable and I can
  2143. 1:25:58very quickly
  2144. 1:26:00uh click through all of my traces and
  2145. 1:26:02set that on each one which I've done in
  2146. 1:26:04advance. Uh this is where you would get
  2147. 1:26:07uh a domain expert involved. You would
  2148. 1:26:09throw them at Phoenix. You'd say here
  2149. 1:26:11are 10 traces, here are 20 traces.
  2150. 1:26:13there's 50 traces. Go through and read
  2151. 1:26:15the output and give me give me your
  2152. 1:26:17golden data set about whether or not
  2153. 1:26:18these things are good. Um,
  2154. 1:26:24[snorts]
  2155. 1:26:25I sat down and labeled all 16 of my
  2156. 1:26:27reports properly against the same
  2157. 1:26:28criteria that I gave the judge. Uh, and
  2158. 1:26:30those are sitting in your seed project
  2159. 1:26:32so that you don't have to do that
  2160. 1:26:33because that would take you a long time.
  2161. 1:26:36Um, what you're building when you do
  2162. 1:26:37this, like I said, is called a golden
  2163. 1:26:39data set. Uh it's examples where to the
  2164. 1:26:42best of human knowledge you know that
  2165. 1:26:44the answers are right. Um it is a lot of
  2166. 1:26:47work so you should make that work count.
  2167. 1:26:50So you should give yourself the same
  2168. 1:26:52specific criteria that you gave the
  2169. 1:26:54judge. That was the error that we were
  2170. 1:26:56talking about earlier. Uh where I was
  2171. 1:26:59not exactly reading the rules that I had
  2172. 1:27:01put into my eval criteria. Right? I was
  2173. 1:27:04disobeying one of my own rules. my rule
  2174. 1:27:06said uh must include risks and I said
  2175. 1:27:10that this report is fine even though it
  2176. 1:27:11doesn't include risks. Uh and as a
  2177. 1:27:13result me and the judge disagreed and I
  2178. 1:27:15feel like the judge was actually more
  2179. 1:27:17correct than I was. It was being
  2180. 1:27:18stricter. Um so uh your enemy here is
  2181. 1:27:24fatigue. Uh if you give yourself a
  2182. 1:27:27hundred traces to judge by trace 50,
  2183. 1:27:30you're going to be really bored of
  2184. 1:27:31judging traces and you're going to get
  2185. 1:27:32lazier about it. Uh so it is better to
  2186. 1:27:36have 50 really well-labeled
  2187. 1:27:39uh examples than a hundred where you
  2188. 1:27:41were just clicking through and saying ah
  2189. 1:27:42this looks fine. Uh the the higher the
  2190. 1:27:46quality the data in your golden data set
  2191. 1:27:48uh the more reliable everything is going
  2192. 1:27:50to be.
  2193. 1:27:52Um
  2194. 1:27:53and one of the best things that you can
  2195. 1:27:55do is that uh is continuously add to
  2196. 1:27:57your golden data set. when you see a
  2197. 1:27:58tricky example, when you see something
  2198. 1:28:00strange happen in production, figure out
  2199. 1:28:02what the answer should have been and put
  2200. 1:28:03it into your golden data set.
  2201. 1:28:06Uh, a few good rules for human go for a
  2202. 1:28:08good golden data set is that you should
  2203. 1:28:10write test tasks a human could pass. Uh,
  2204. 1:28:13if your agent fails a task every single
  2205. 1:28:15time, that is almost always going to be
  2206. 1:28:17a broken task, not a broken agent. Um,
  2207. 1:28:20and for each task, you should have an
  2208. 1:28:22answer that you know is good, which
  2209. 1:28:24proves the task can be done. Uh, you
  2210. 1:28:26should also test in both directions. If
  2211. 1:28:28you only check, for instance, that the
  2212. 1:28:30agent searches the web when it's
  2213. 1:28:31supposed to search the web, you're going
  2214. 1:28:33to accidentally train your agent to
  2215. 1:28:34search the web every single time, all
  2216. 1:28:36the time, even when it doesn't need to.
  2217. 1:28:40Uh, and here's a rule from machine
  2218. 1:28:42learning that applies to judges as well.
  2219. 1:28:43Don't tune on your test set. Uh, split
  2220. 1:28:46your labels into two groups. One that
  2221. 1:28:48you use to tune your evals and one that
  2222. 1:28:51you use to test that they are working.
  2223. 1:28:54Uh when you only have 16 answers in your
  2224. 1:28:56golden data set, that makes it your test
  2225. 1:28:57set very small. Uh because the rule is
  2226. 1:29:00usually 75% in the tuning set, 25% in
  2227. 1:29:03the test set. So there's only four in
  2228. 1:29:05our test set. Uh but if you were up to
  2229. 1:29:08100, that would be fine. Um
  2230. 1:29:12Phoenix data sets have splits built in.
  2231. 1:29:13So this is very easy to do. Uh
  2232. 1:29:17see what that looks like.
  2233. 1:29:20uh
  2234. 1:29:22so first it builds the golden data set
  2235. 1:29:24with splits. It finds every report with
  2236. 1:29:26a human label. Uh
  2237. 1:29:30uh and each one becomes an example in a
  2238. 1:29:31Phoenix data set. The input is the
  2239. 1:29:33report. The expected output is the
  2240. 1:29:35human's label. We sort them by span ID.
  2241. 1:29:37Then every fourth example goes into the
  2242. 1:29:39test split and the rest go into dev. Uh
  2243. 1:29:42sorting first means that a report always
  2244. 1:29:44lands in the same split however many
  2245. 1:29:46times you run this. Uh, and span
  2246. 1:29:48[snorts] ID links each example back to
  2247. 1:29:50the trace it came from. Uh, so you can
  2248. 1:29:52always click through to the original
  2249. 1:29:54run.
  2250. 1:29:57Then we run the judge against the
  2251. 1:29:59humans. This is an experiment which is
  2252. 1:30:01something that we're going to dig into
  2253. 1:30:02in a little bit. Um, but for now uh an
  2254. 1:30:05experiment takes a data set. It takes a
  2255. 1:30:07task task to run on every example uh and
  2256. 1:30:10evaluators to score the results. The
  2257. 1:30:12task here is our judge and the evaluator
  2258. 1:30:14is a tiny Kodi val which checks whether
  2259. 1:30:16the judge's label matches the humans. Uh
  2260. 1:30:19notice that we only run it in the devs
  2261. 1:30:21split. Uh you can run this yourself by
  2262. 1:30:24running npm run meta.
  2263. 1:30:28[sighs]
  2264. 1:30:30Let's see if we can get it to go.
  2265. 1:30:44It's going to run an LM. So, uh, I'm
  2266. 1:30:47going to assume that it does the same
  2267. 1:30:48thing that it did last night. Um, the
  2268. 1:30:51script should print a little table at
  2269. 1:30:52the end. Uh, and on my 12 dev reports,
  2270. 1:30:56the judge and I made the same call every
  2271. 1:30:57time, which is great, but it's also only
  2272. 1:30:5912 reports. Uh, so read that as, you
  2273. 1:31:03know, no sign of a problem yet. you're
  2274. 1:31:05going to want a larger test set when
  2275. 1:31:06you're running this in production. Um,
  2276. 1:31:11cool. It actually completed it. Uh,
  2277. 1:31:14the more interesting part is the two
  2278. 1:31:16ports that I the two reports that I
  2279. 1:31:18found hardest to label. Um,
  2280. 1:31:24so in my Phoenix data,
  2281. 1:31:27uh, there's Coca-Cola and there's
  2282. 1:31:30Microsoft.
  2283. 1:31:38Um
  2284. 1:31:42the the first one is Coca-Cola. The
  2285. 1:31:43Coca-Cola is the one that flipped uh
  2286. 1:31:46when I changed from the XML tags to the
  2287. 1:31:48uh from not having XML tags to having
  2288. 1:31:50XML tags. Uh this is where when it got
  2289. 1:31:53the examples it got better. Um
  2290. 1:31:58borderline for me turns out to be uh
  2291. 1:32:00borderline as well. the it the report
  2292. 1:32:02calls KO ideal for conservative income
  2293. 1:32:04oriented pol uh portfolios uh which
  2294. 1:32:08sounds like a recommendation. So as a
  2295. 1:32:10human I went back and forth on whether
  2296. 1:32:12or not I should count that as a
  2297. 1:32:13recommendation. Ultimately I decided it
  2298. 1:32:15did not uh but the judge also goes back
  2299. 1:32:17and forth on whether or not that counts
  2300. 1:32:18as enough of a recommendation.
  2301. 1:32:21Um
  2302. 1:32:23and the second one was Microsoft uh
  2303. 1:32:25which I'm not going to bother to click
  2304. 1:32:26into which is the other way around. The
  2305. 1:32:27report says buy with reasons uh and a
  2306. 1:32:30time horizon. Uh and it never mentions a
  2307. 1:32:32single risk. This is the one that I was
  2308. 1:32:34talking about earlier. Uh my rubric
  2309. 1:32:37lists name concrete risks as a
  2310. 1:32:39criterion. Uh and I decided that was
  2311. 1:32:42fine and the judge decided that that was
  2312. 1:32:44not fine. It said it was weak on risks.
  2313. 1:32:46There is no risk section. It clears the
  2314. 1:32:48bar for actionability but though not by
  2315. 1:32:50much. So, the judge looking at this
  2316. 1:32:53stuff came up with exactly my human
  2317. 1:32:55judgment on whether or not this was an
  2318. 1:32:57actionable report, including the
  2319. 1:32:59ambiguity.
  2320. 1:33:02Um, and that ambiguity is still in our
  2321. 1:33:05rubric
  2322. 1:33:08because we haven't changed it yet. Uh,
  2323. 1:33:10so it's very tempting to fix it. So, I
  2324. 1:33:13tried I added one sentence uh which was
  2325. 1:33:16a report is actionable only if it meets
  2326. 1:33:18all four criteria because previously
  2327. 1:33:19that was ambiguous. I said a report
  2328. 1:33:21should include all of these things. I
  2329. 1:33:24didn't say that it must. Uh so you can
  2330. 1:33:27change the you can change the rubric and
  2331. 1:33:29be more specific and say yes this
  2332. 1:33:31absolutely must contain all these four
  2333. 1:33:33criteria. Uh and on dev uh that broke
  2334. 1:33:36Microsoft my 12 out of 12 agreement
  2335. 1:33:39became 11 out of 12 agreement. Um
  2336. 1:33:42and uh it also in the test split it
  2337. 1:33:46broke Apple uh because Apple didn't have
  2338. 1:33:48enough uh a big enough risk section as
  2339. 1:33:50far as the agent was the judge was
  2340. 1:33:52concerned. Um
  2341. 1:33:55what that tells you is that I could
  2342. 1:33:57change my rubric and make my eval worse.
  2343. 1:33:59Uh I can make my eval less helpful. I
  2344. 1:34:02can make my EVA less like what a human
  2345. 1:34:04would do. Uh even though I'm trying to
  2346. 1:34:06be specific.
  2347. 1:34:08Um the script also prints precision and
  2348. 1:34:11recall. Uh precision these are very
  2349. 1:34:14important things again borrowed from the
  2350. 1:34:16ML land or rather from stats land. Um
  2351. 1:34:20precision asks when the judge says not
  2352. 1:34:22actionable how often is it correct? And
  2353. 1:34:25recall asks of all the reports that
  2354. 1:34:28aren't actionable how many did the judge
  2355. 1:34:30catch? Those two sound very similar but
  2356. 1:34:33measure different things. Um,
  2357. 1:34:37in most cases, you're going to want to
  2358. 1:34:39prioritize recall because what recall
  2359. 1:34:41gives you is it catches everything, but
  2360. 1:34:44it gives you high recall catches
  2361. 1:34:46everything, but it will give you uh
  2362. 1:34:48false alarms. A false alarm costs you a
  2363. 1:34:51minute or two when you look at a report
  2364. 1:34:52that turns out to be fine. Uh, but a
  2365. 1:34:55missed failure uh would give you a bad
  2366. 1:34:57report that reaches a customer. Um, so
  2367. 1:35:01you have to trade one for the other. If
  2368. 1:35:03recall goes up uh um then uh precision
  2369. 1:35:08will go down and vice versa. So for your
  2370. 1:35:11application you have to decide whether
  2371. 1:35:14being accurate uh as in throwing away
  2372. 1:35:17some things that were actually correct
  2373. 1:35:19uh but but uh you decided they weren't
  2374. 1:35:23is better or worse than getting false
  2375. 1:35:25alarms where you say something is
  2376. 1:35:27important and it turns out not to be. Um
  2377. 1:35:32judges also have biases. Uh I mentioned
  2378. 1:35:35one of them already. Um one is position
  2379. 1:35:38bias. Given two options, they tend to
  2380. 1:35:40prefer depending on the model either
  2381. 1:35:42which one comes first or which one comes
  2382. 1:35:44last. It depends which way the model
  2383. 1:35:46around which way around the model was
  2384. 1:35:47changed. Uh but you should swap your
  2385. 1:35:50options so that it's not always looking
  2386. 1:35:52at those uh things in the same order. Um
  2387. 1:35:54they have length bias. Uh, judges prefer
  2388. 1:35:58long answers and they also have a
  2389. 1:35:59confidence bias. Judges prefer answers
  2390. 1:36:02that sound fluent and confident. Um, and
  2391. 1:36:06the one that I mentioned already is
  2392. 1:36:07self-preference. A model judging its own
  2393. 1:36:09output tends to rate it higher. Uh,
  2394. 1:36:13which is why we judged Haiku with
  2395. 1:36:14sonnet. Uh, and ideally you judge haiku
  2396. 1:36:17with something from open AAI.
  2397. 1:36:21Um, but before you get too worried about
  2398. 1:36:24how much you can trust a judge, it's
  2399. 1:36:25worth noting that human judges also
  2400. 1:36:28disagree with each other a lot of the
  2401. 1:36:29time. Um, if you give two experts the
  2402. 1:36:32same outputs in the same rubric and
  2403. 1:36:33measured how often they agree, uh, there
  2404. 1:36:35is a standard score for that called
  2405. 1:36:37Cohen's Kappa, uh, and for this kind of
  2406. 1:36:39task, it's often as low as 02 or.3. Uh,
  2407. 1:36:43which is to say they agree with each
  2408. 1:36:45other not very much more often than just
  2409. 1:36:47random chance. Um [snorts] so the bar
  2410. 1:36:50for your human judgment is h for the bar
  2411. 1:36:53for your judge is human performance and
  2412. 1:36:55h human performance uh is not actually
  2413. 1:36:57that good when you compare humans to
  2414. 1:36:59each other. So having a judge that
  2415. 1:37:01disagree you don't do not need a judge
  2416. 1:37:04that agrees with you 100% of the time.
  2417. 1:37:07Uh your judge is never going to agree
  2418. 1:37:09with you 100% of the time. What you want
  2419. 1:37:10is a judge that does better than another
  2420. 1:37:12human doing the judge would be. uh
  2421. 1:37:15because your judge can run across
  2422. 1:37:17thousands of examples and help itself
  2423. 1:37:19out that way. Um
  2424. 1:37:22one last principle on judges uh is that
  2425. 1:37:24failures should seem fair. When
  2426. 1:37:26something fails, it should be obvious
  2427. 1:37:27what the agent did wrong. If you look at
  2428. 1:37:29the failure and go, "Well, actually that
  2429. 1:37:31looks fine to me," then the problem is
  2430. 1:37:33probably your eval. Um
  2431. 1:37:36there's a famous example of this uh when
  2432. 1:37:38Claude Opus 4.5 first scored 42% on a
  2433. 1:37:42benchmark called Corebench uh which
  2434. 1:37:44tests whether agents can reproduce
  2435. 1:37:46scientific papers. Uh anthropic were
  2436. 1:37:49upset about that low score. Uh so a
  2437. 1:37:51researcher ran the actual transcripts
  2438. 1:37:53and found uh that uh Claude was just
  2439. 1:37:57being uh right in a different way. Uh it
  2440. 1:38:01the test expected uh six digits of
  2441. 1:38:04precision and Claude gave the right
  2442. 1:38:06answer to two digits of four digits of
  2443. 1:38:07precision rather. Um and the test said
  2444. 1:38:10that was wrong. There were ambiguous
  2445. 1:38:12task descriptions. Some of the tasks
  2446. 1:38:14couldn't be reproduced at all. Uh so
  2447. 1:38:16Anthropic went through and they fixed
  2448. 1:38:18all of the tests and they said these
  2449. 1:38:19tests could be better. Uh and magically
  2450. 1:38:22they got 95% on the eval.
  2451. 1:38:24Um this happens all the time. SWEBench
  2452. 1:38:28and all of the other uh benchmarks that
  2453. 1:38:31you see are constantly being
  2454. 1:38:33re-evaluated and manually tweaked and uh
  2455. 1:38:37that is why you see version two, version
  2456. 1:38:38three, version four of of uh the famous
  2457. 1:38:40benchmarks uh because people are
  2458. 1:38:42constantly finding that the benchmarks
  2459. 1:38:44are not actually as good as they could
  2460. 1:38:45be and your evals are going to end up
  2461. 1:38:47with the same problem. Uh so you need to
  2462. 1:38:51be constantly re-evaluating your test
  2463. 1:38:53set.
  2464. 1:38:55Uh which brings us to step seven which
  2465. 1:38:57is uh experiments. We've got evals that
  2466. 1:39:00we trust. Now we are going to use them
  2467. 1:39:02to actually improve that the agent and
  2468. 1:39:04prove that the fixed worked. Uh
  2469. 1:39:09I'm going to go a little faster now as
  2470. 1:39:11I've been going on a very leisurely
  2471. 1:39:12pace. I'm getting beginning to run out
  2472. 1:39:14of time. Um so the here's the problem.
  2473. 1:39:17We know that some reports aren't
  2474. 1:39:19actionable and we know why. So we change
  2475. 1:39:21the prompt and then what? How do you
  2476. 1:39:22know that it worked? Uh, how do you know
  2477. 1:39:25that you didn't break something that was
  2478. 1:39:27working before? If you run it on a
  2479. 1:39:28couple of examples and eyeball it, then
  2480. 1:39:30you're back to vibes. A prompt change
  2481. 1:39:32that you haven't measured is just a
  2482. 1:39:34vibe. What you want is a controlled
  2483. 1:39:36comparison. You want the same inputs,
  2484. 1:39:38the same eval before and after. That is
  2485. 1:39:41an experiment.
  2486. 1:39:42Um
  2487. 1:39:46so uh what you can do in Phoenix is you
  2488. 1:39:49can take a bunch of your evals that you
  2489. 1:39:51have filtered down to not actionable say
  2490. 1:39:54uh and you can select them and you can
  2491. 1:39:56add them to a data set. Um
  2492. 1:39:59that gives you a set to test against uh
  2493. 1:40:02against specific things. Um I'm not
  2494. 1:40:05going to do that since I've already done
  2495. 1:40:06it over here. Um
  2496. 1:40:14Um once you have a data set you can
  2497. 1:40:16create turn that into an experiment and
  2498. 1:40:18run uh your experiment against only the
  2499. 1:40:22data set only against the evals that
  2500. 1:40:24were failing as opposed to against your
  2501. 1:40:25entire set every single time which you
  2502. 1:40:28know if you've got a decent sized split
  2503. 1:40:30and a decent sized test set is saving
  2504. 1:40:31you thousands and thousands of tests
  2505. 1:40:33every time. Uh
  2506. 1:40:36now we're going to fix what the eval
  2507. 1:40:38found. So, uh, if you're still coding
  2508. 1:40:42along, congratulations. Open prompts.ts.
  2509. 1:40:44There is an improved version of each
  2510. 1:40:46prompt. Uh, or you can write your own.
  2511. 1:40:49Um,
  2512. 1:40:51and every change maps to a finding. So,
  2513. 1:40:54the judge said, uh, makes no
  2514. 1:40:56recommendation, so we asked for an
  2515. 1:40:57explicit recommendation. It said
  2516. 1:40:59mentions risks with no evidence. So, we
  2517. 1:41:00asked for risks with supporting data.
  2518. 1:41:03Faithfulness found invented numbers, so
  2519. 1:41:04we said use only numbers that appear in
  2520. 1:41:07your research. uh and reading traces
  2521. 1:41:09found that the agent uh was trying to
  2522. 1:41:11save files all the time. Uh so we tell
  2523. 1:41:14it to reply with the report instead.
  2524. 1:41:17We're not guessing here. We are coming
  2525. 1:41:18up with specific things for the agent to
  2526. 1:41:20do as a result of the previous results
  2527. 1:41:22of our evals. Uh
  2528. 1:41:27this is what the experiment script looks
  2529. 1:41:29like. An experiment is a data set, a
  2530. 1:41:30task and evaluators. The data set is the
  2531. 1:41:33one that we just created. Uh the task is
  2532. 1:41:35a function that just runs the agent on
  2533. 1:41:37each example. Uh
  2534. 1:41:40in this case, we're running the entire
  2535. 1:41:42agent, but we could be running it on a
  2536. 1:41:43specific subset of the agents behavior
  2537. 1:41:45or a specific subtask uh if we wanted
  2538. 1:41:48to. Uh our task hands back the report
  2539. 1:41:51and the research. So each eval gets a
  2540. 1:41:53small wrapper that picks out the fields
  2541. 1:41:55that it needs. Uh and then faithfulness
  2542. 1:41:57gets the research as its context. The
  2543. 1:41:59same as before, uh Phoenix runs the task
  2544. 1:42:02on every example. It scores every result
  2545. 1:42:04and it stores everything so you can
  2546. 1:42:06compare. If you want to run this, you
  2547. 1:42:08can run npm run experiment and it will
  2548. 1:42:10take about four minutes to run. Um,
  2549. 1:42:14but I'm running out of time so I'm not
  2550. 1:42:15going to wait for four minutes. Uh, I
  2551. 1:42:19ran mine ahead of time. How many
  2552. 1:42:21examples do you need? Uh, is a really
  2553. 1:42:23good question. Uh, 10 to 20 examples
  2554. 1:42:26gives you a rough direction of where
  2555. 1:42:27things are going. Is very useful in dev.
  2556. 1:42:30Um, if you're getting into production,
  2557. 1:42:32uh, you're going to want hundreds of
  2558. 1:42:33examples. Um, that is going to take a
  2559. 1:42:37long time, but is, uh, very worth it for
  2560. 1:42:41accuracy. Um, for every, uh, to have
  2561. 1:42:46your error bars on your accuracy, you
  2562. 1:42:48need to quadruple the number of
  2563. 1:42:51examples. So, uh, going from 25 examples
  2564. 1:42:55to 100 examples is really, really
  2565. 1:42:57helpful. uh and is not that much effort
  2566. 1:43:00going to get that big a jump again you'd
  2567. 1:43:03have to go to 400 examples which begins
  2568. 1:43:05to get into the territory of you're
  2569. 1:43:06never going to bother to do this uh but
  2570. 1:43:09the bigger the better uh and the more
  2571. 1:43:12production failures you throw into your
  2572. 1:43:13data set the better
  2573. 1:43:16um so I ran mine three times and the
  2574. 1:43:18reason I did that uh is because the
  2575. 1:43:20agent is non-deterministic each run of
  2576. 1:43:22each example uh can mislead you in
  2577. 1:43:25either direction um And there are two
  2578. 1:43:28useful ways of thinking about how an
  2579. 1:43:30agent runs uh when it runs multiple
  2580. 1:43:33times. The first is called pass at K
  2581. 1:43:36which is uh does it succeed at least
  2582. 1:43:38once in K tries and then there is pass
  2583. 1:43:41to the K which does it increase every
  2584. 1:43:45single time uh does it pass every single
  2585. 1:43:47time I run uh K times. Um
  2586. 1:43:52so as K goes up those two numbers
  2587. 1:43:55diverge. Uh the more tries you give it,
  2588. 1:43:58the more likely pass at K is to succeed
  2589. 1:44:00because it succeeds at least once. The
  2590. 1:44:02more tries you give it, the more likely
  2591. 1:44:03it is to fail at least once and then
  2592. 1:44:05pass it K pass to the K will go down. Um
  2593. 1:44:09a coding assistant gets that gets it
  2594. 1:44:11right on the second try is fine. So pass
  2595. 1:44:13it K is fine. Um a support bot that's
  2596. 1:44:16wrong runtime in every five is a huge
  2597. 1:44:19problem. And a financial anal analyst uh
  2598. 1:44:22that gives inaccurate recommendations is
  2599. 1:44:24also a huge problem. Uh so you want pass
  2600. 1:44:27to the K. You want it to pass every
  2601. 1:44:29single time for those.
  2602. 1:44:31Um
  2603. 1:44:33when you're improving an agent, there's
  2604. 1:44:35an order of operations based on how
  2605. 1:44:39useful making a change is going to be.
  2606. 1:44:41The first one is data quality. If your
  2607. 1:44:44underlying data is bad, if it's hard to
  2608. 1:44:46read, if it's difficult to interpret for
  2609. 1:44:48the agent or for the judge, uh then
  2610. 1:44:51nothing else you do, nothing else you
  2611. 1:44:52tweak is going to be useful. Once you've
  2612. 1:44:55got good quality data, then you move to
  2613. 1:44:57the prompts. Uh that is what we've been
  2614. 1:44:59messing with mostly today. Uh is to make
  2615. 1:45:02things better at the prompt level by
  2616. 1:45:04changing our rubric, by changing our
  2617. 1:45:06agent.
  2618. 1:45:07Then there's model choice. Uh model
  2619. 1:45:10choice has a lot of leverage, but it
  2620. 1:45:15also changes a whole bunch of stuff at
  2621. 1:45:17the same time.
  2622. 1:45:18uh and also the usual way that you're
  2623. 1:45:21going to change your model is you're
  2624. 1:45:22going to change it to a bigger model and
  2625. 1:45:24that makes things more expensive. So
  2626. 1:45:25that is uh creates a tradeoff uh that
  2627. 1:45:29you don't always want to make. Uh and
  2628. 1:45:31finally there's hyperparameters.
  2629. 1:45:32Hyperparameters are things like
  2630. 1:45:34temperature and stuff like that. Uh
  2631. 1:45:36they're so useless that uh people have
  2632. 1:45:38that modern models have stopped allowing
  2633. 1:45:40you to tune them. You can't pass
  2634. 1:45:42temperature to model to modern claw
  2635. 1:45:44models. Um so if you're tempted to it is
  2636. 1:45:48the least useful thing that you can
  2637. 1:45:49pass.
  2638. 1:45:53Um so if we're looking at my experiments
  2639. 1:45:55you can look in your seed data and get
  2640. 1:45:57see see the same experiments. Um
  2641. 1:46:00you'll see that uh
  2642. 1:46:03as I improved as I improved my runs I
  2643. 1:46:06went from uh
  2644. 1:46:1016 out 15 out of 16 to 48 out of 48. and
  2645. 1:46:13went from 5 out of 16 to 48 out of 48.
  2646. 1:46:15And faithfulness went from 2 out of 16
  2647. 1:46:17to 3 out of 48. Uh, which is not that
  2648. 1:46:20good, right? Like we really should have
  2649. 1:46:22done better on faithfulness with my
  2650. 1:46:24improved prompt. Um,
  2651. 1:46:28the
  2652. 1:46:30uh
  2653. 1:46:31important thing is did anything that
  2654. 1:46:33used to pass break? We can filter down
  2655. 1:46:36to the passes split. I'm not going to do
  2656. 1:46:37it in the UI right now. Uh, but all of
  2657. 1:46:40the five reports that passed previously
  2658. 1:46:42as I improved my prompt still passed.
  2659. 1:46:45Uh, so actionability went straight to
  2660. 1:46:47perfect. Um, but faithfulness was bad.
  2661. 1:46:50Faithfulness uh went from 2 out of 16 to
  2662. 1:46:533 out of 48. Uh, even though the prompt
  2663. 1:46:56literally says only use numbers that
  2664. 1:46:57appear in your research. Um,
  2665. 1:47:01so we fixed what we measured in a single
  2666. 1:47:04line of the prompt. Uh, didn't fix the
  2667. 1:47:06agent making things up. That is the next
  2668. 1:47:08thing that we have to fix for this
  2669. 1:47:09agent. Uh we have fixed whether or not
  2670. 1:47:12it is making a good judgment call. Uh
  2671. 1:47:15but we have not fixed uh that it is uh
  2672. 1:47:18inventing the data some of the time.
  2673. 1:47:22Um
  2674. 1:47:25if we want to we can look into uh each
  2675. 1:47:27of the runs and you'll see that each of
  2676. 1:47:29the because it's nondeterministic each
  2677. 1:47:31of the runs are coming up with different
  2678. 1:47:32advice. Um, but I'm not going to do that
  2679. 1:47:35because I'm running out of time and I
  2680. 1:47:36want to get to some other stuff. Uh,
  2681. 1:47:44let's get to Okay, cool. Um,
  2682. 1:47:48a good eval like the 56 the 511 split
  2683. 1:47:52that I was talking about on my 16 data
  2684. 1:47:54sets. That is what is called a
  2685. 1:47:55capability eval. A capability eval is a
  2686. 1:47:58thing that our agent can't do yet. And
  2687. 1:47:59it gives us a hill that we can measure
  2688. 1:48:01ourselves climbing. Uh when it passes
  2689. 1:48:04reliably, when you get a test that
  2690. 1:48:07passes 100% of the time, you don't throw
  2691. 1:48:09it away. You turn it into what is called
  2692. 1:48:10a regression eval. That is the kind that
  2693. 1:48:13you can put into your CI and say this
  2694. 1:48:14used to pass 100% of the time. If it
  2695. 1:48:16suddenly stops passing 100% of the time,
  2696. 1:48:19then we can call that a failure and we
  2697. 1:48:20should stop release. Um how do we climb
  2698. 1:48:24this hill is the question. uh
  2699. 1:48:28we could work on the prompt again or uh
  2700. 1:48:30we could do the thing that I said that
  2701. 1:48:32we would do which is we can upgrade the
  2702. 1:48:34model. Uh so you can run the experiment
  2703. 1:48:37again by passing in a new model haiku
  2704. 1:48:395.5 and then run npm experiment. Um,
  2705. 1:48:44I said at the start of today that you
  2706. 1:48:46can't switch models without eval. And
  2707. 1:48:47this is what it looks like when you can
  2708. 1:48:48switch a model with an eval because we
  2709. 1:48:51know now that we are measuring all of
  2710. 1:48:52these things. Um, with three
  2711. 1:48:55repetitions, it takes 13 minutes, which
  2712. 1:48:57is more time than we've got left. So,
  2713. 1:48:58I'm just going to skip to the results.
  2714. 1:49:00Uh, here is Haiku 4.5 versus 5.5. Uh,
  2715. 1:49:05faithfulness improved. It got more than
  2716. 1:49:07three times better. It is still
  2717. 1:49:08terrible. This agent is still making
  2718. 1:49:10things up all the time.
  2719. 1:49:12Uh, but consistent calls got better. So,
  2720. 1:49:14it is at least making the same call over
  2721. 1:49:16and over. Is that good? Uh, it's also
  2722. 1:49:19costing four times as much money. Is
  2723. 1:49:21that worth it? Uh, is a question that
  2724. 1:49:24you need to make for yourself in
  2725. 1:49:25production when you're doing this kind
  2726. 1:49:27of thing. Um,
  2727. 1:49:31one of the ways that it got more
  2728. 1:49:32consistent, one of the ways it stopped
  2729. 1:49:34varying between buy and sell between
  2730. 1:49:36calls, uh, is it just got more
  2731. 1:49:38conservative. Haiku 5.5 uh it turns out
  2732. 1:49:41just says hold all the time. Uh so uh is
  2733. 1:49:46that better or worse? Probably worse. Uh
  2734. 1:49:49probably we need to iterate on Haiku 5.5
  2735. 1:49:52being too conservative uh about things.
  2736. 1:49:55But at least we know now that something
  2737. 1:49:57has changed and that the conserviveness
  2738. 1:49:59is a problem with Haiku 5.5.
  2739. 1:50:02Um that is the problem that I found. It
  2740. 1:50:05went it went to 41 of out of uh 45 calls
  2741. 1:50:09it said uh hold 41% of the on 41 of the
  2742. 1:50:13times. Um which is perfectly consistent
  2743. 1:50:16between runs. Uh so it it got better at
  2744. 1:50:19the uh consistency check that I was
  2745. 1:50:21talking about over here the consistent
  2746. 1:50:23call. Uh but it got there by just
  2747. 1:50:26picking the same answer every single
  2748. 1:50:27time.
  2749. 1:50:28>> [snorts]
  2750. 1:50:28>> Um
  2751. 1:50:32but that is the eval iterate cycle. Uh
  2752. 1:50:34and the cycle is where the value is not
  2753. 1:50:36anyone's score. You run your evals, you
  2754. 1:50:38read the failures and the explanations,
  2755. 1:50:40you spot the pattern, you change the
  2756. 1:50:41prompt or the tools or the data and you
  2757. 1:50:43run the experiment again. Did it get
  2758. 1:50:45better? Uh your evals can now answer
  2759. 1:50:48that question for you. You can go from I
  2760. 1:50:50think it works to I can show you it
  2761. 1:50:52works. Uh
  2762. 1:50:55I have just enough time to talk about
  2763. 1:50:57how to do the last step which is eval in
  2764. 1:50:59CI.
  2765. 1:51:00Uh more and more teams that ship AI
  2766. 1:51:03quickly write the eval before the
  2767. 1:51:05feature. That's called eval driven
  2768. 1:51:06development. Um say you want your
  2769. 1:51:09support agent to always check who the
  2770. 1:51:11customer is before giving a refund. Uh
  2771. 1:51:14you can write the eval that checks for
  2772. 1:51:16that first and now done has a definition
  2773. 1:51:18that you can measure a hill that you can
  2774. 1:51:20climb from the start. Um,
  2775. 1:51:24we talked already about capability
  2776. 1:51:26capability evals and regression evals.
  2777. 1:51:29Um,
  2778. 1:51:31here's how uh to create a eval that runs
  2779. 1:51:34in CI. Um,
  2780. 1:51:37if you've never used VEST, VEST is a
  2781. 1:51:40JavaScript testr runner and Fenix can
  2782. 1:51:41plug straight into it. Uh, if you open
  2783. 1:51:44agent.eval.ts, you'll see that it looks
  2784. 1:51:46like an ordinary test file because it is
  2785. 1:51:47one. There is a describe block and a
  2786. 1:51:49test for each query in our regression
  2787. 1:51:51set. So Coca-Cola, Apple versus
  2788. 1:51:53Microsoft, Rivian, uh, and the fake
  2789. 1:51:55ZZZQ.
  2790. 1:51:57Um, each test runs the agent, logs the
  2791. 1:52:00report as the output, uh, and then runs
  2792. 1:52:02our evals on it. And the same ticker
  2793. 1:52:04check and actionability judge that we
  2794. 1:52:05wrote earlier. We don't have to add new
  2795. 1:52:07evals for CI.
  2796. 1:52:09Uh, then at the bottom, we gate the
  2797. 1:52:12build on acceptance criteria. This is
  2798. 1:52:14where I talked about guardrails and
  2799. 1:52:15northstars. Mention sticker is a
  2800. 1:52:17guardrail. It has to be talking about
  2801. 1:52:19the right company. Um actionability is a
  2802. 1:52:22target. The average has to stay 08 or
  2803. 1:52:25better. Uh because an LLM judge can be a
  2804. 1:52:27bit noisy on a single report. So we gate
  2805. 1:52:29on the average uh not on just one. Uh
  2806. 1:52:33and then you can run npm test uh and it
  2807. 1:52:36runs like any test suite. Um and at the
  2808. 1:52:39end the reporter prints out a scorecard.
  2809. 1:52:42Um, and that'll take about four minutes,
  2810. 1:52:44which is more time than I've got left.
  2811. 1:52:46Um,
  2812. 1:52:48a red build. If a failed build, if your
  2813. 1:52:51build fails, this is what you'd get. All
  2814. 1:52:52four tests ran and every report
  2815. 1:52:54mentioned its ticker, but Rivian's
  2816. 1:52:55report wasn't actionable. So, the
  2817. 1:52:57actionability average came out at 75.
  2818. 1:53:00Uh, it doesn't say you failed. It just
  2819. 1:53:01says that you missed. Um,
  2820. 1:53:06but, uh, a green run, uh, is where all
  2821. 1:53:10of those pass. Um,
  2822. 1:53:13I'm not going to show the experiment
  2823. 1:53:15view because again, I'm running out of
  2824. 1:53:16time. Uh, but when a build fails, you
  2825. 1:53:19don't just get a red cross. You get an
  2826. 1:53:21explanation that says whether things are
  2827. 1:53:23good or bad and why they went wrong. And
  2828. 1:53:25that is the important thing. Uh, this
  2829. 1:53:27same test suite can be run in GitHub
  2830. 1:53:29actions. Uh, it starts Phoenix as a
  2831. 1:53:32service container. Uh,
  2832. 1:53:36but now we've done everything that I've
  2833. 1:53:38said that you can do. uh you can run
  2834. 1:53:41your evals, you can test things, you can
  2835. 1:53:43make sure uh that it matches your human
  2836. 1:53:45judgment, you can put it into CI and you
  2837. 1:53:47can make sure that your builds are gated
  2838. 1:53:49on whether or not uh the LLM's judgment
  2839. 1:53:52of what you've encoded as the definition
  2840. 1:53:55of good uh really works.
  2841. 1:53:58Um
  2842. 1:54:00and there's something I love about this
  2843. 1:54:02which is that anyone who knows what good
  2844. 1:54:04looks like can write evals now. uh your
  2845. 1:54:07product managers, your support team,
  2846. 1:54:09your person in sales who keeps hearing
  2847. 1:54:10the same complaint. They don't need to
  2848. 1:54:12write TypeScript. Uh they just need to
  2849. 1:54:14describe what a good answer looks like
  2850. 1:54:17uh and give it to you or even better
  2851. 1:54:19just give it to a coding agent which
  2852. 1:54:21will then write all of the evals for
  2853. 1:54:22them.
  2854. 1:54:24Uh you shouldn't run your whole agent on
  2855. 1:54:27every single commit because uh it's
  2856. 1:54:30going to take a really long time and
  2857. 1:54:31cost you a whole bunch of money. Um, but
  2858. 1:54:35now you've got the repo I promised you.
  2859. 1:54:37You've got all of the code. You've got
  2860. 1:54:38all of the examples. You can see how
  2861. 1:54:39everything is done. Uh, you can point
  2862. 1:54:41your agent at it and say, "Do this, but
  2863. 1:54:43for my codebase," uh, and your agent
  2864. 1:54:45will figure it out. Um,
  2865. 1:54:49there is one thing that we didn't get
  2866. 1:54:50time to build today, uh, which is, uh,
  2867. 1:54:53once you're live, you should keep
  2868. 1:54:55evaluating. You should run your evals on
  2869. 1:54:57a sample of real traffic, uh, and alert
  2870. 1:55:00when scores drop and stay down. um not
  2871. 1:55:03on every single failure because one
  2872. 1:55:04failure would be noise. Um but if you
  2873. 1:55:07get a trend in failures, uh production
  2874. 1:55:10monitoring is incredibly useful and eval
  2875. 1:55:12can get you that as well.
  2876. 1:55:15So this is the full cycle that we built.
  2877. 1:55:18We traced, we read, we evaluated, we
  2878. 1:55:20checked, we improved, uh and we locked
  2879. 1:55:23it in with CI. Uh but you don't have to
  2880. 1:55:26do all of the stuff that you've learned
  2881. 1:55:27today on Monday. You can start small.
  2882. 1:55:30You can just instrument your agent. you
  2883. 1:55:31can just read some traces. You will get
  2884. 1:55:34information reading 12 traces that you
  2885. 1:55:36wouldn't have got uh by just looking at
  2886. 1:55:39the output. Um so run them. Look at the
  2887. 1:55:42results and build from there.
  2888. 1:55:45Uh
  2889. 1:55:47so go try it on a app of your own. This
  2890. 1:55:49is the repo that I said that everything
  2891. 1:55:50was in. Uh the Phoenix docs are there.
  2892. 1:55:53Uh Phoenix itself is open source. So you
  2893. 1:55:56can mess with the code and tell us that
  2894. 1:55:58we got stuff wrong in there. Uh and that
  2895. 1:56:01just on time is it. Thank you very much
  2896. 1:56:04everybody. [applause]

About this transcript

This page contains the full transcript of How to Know If Your AI Agent Is Any Good: Evals With Phoenix & Claude — Laurie Voss, Arize AI by AI Engineer, generated from the public captions YouTube serves with the video. The transcript has 20,194 words across 2,896 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.