Video: Under the Hood: Debugging AI Agents with Precision | Duration: 3608s | Summary: Under the Hood: Debugging AI Agents with Precision | Chapters: Welcome to Dataiku (2.1599998s), Global Audience Introduction (65.090004s), AI Agent Adoption (172.24501s), Debugging AI Agents (317.08002s), Debugging AI Agents (474.505s), Agent Design Principles (695.595s), Debugging AI Agents (818.96s), Agent Demonstration Overview (1020.85s), Improving LLM Queries (1195.275s), Debugging AI Pipelines (2132s), Multiple Tools Integration (2632s), Controlling LLM Behavior (3287.105s), Real Estate AI Applications (3348.0999s), Ensuring Consistency Over Time (3442.625s), Conclusion and Thanks (3517.34s)
Transcript for "Under the Hood: Debugging AI Agents with Precision": Hello. Dataiku live. We are very happy for you all to join us whether you're here live or watching the recording. This is gonna be a fantastic webinar where you are hopefully gonna learn a lot about debugging AI agents, and really understand how to do it with precision as well as learn how you can do it within Dataiku because, of course, that is the reason why we're all here. So I know there are some people still joining. The first thing that I love to do in every single webinar, if you've been with me in the past for one, is please put in the chat where are you from, where are you watching from, where are you streaming from? I know people on the replay, you you probably can't put where you're watching from, but that's okay. So everyone that is joining us live, please go ahead and type in the chat where exactly you are watching from. We'll give a couple shout outs while we wait for the room to continue to fill up, and then we will hop into the content. So I'm seeing New York. I'm seeing Paris, France. I am seeing Golden, Colorado, Washington, DC, London, Fairfax, Virginia, all very fantastic places, Chicago, Iowa, Atlanta. So it's it's nice that we have we have many different places in in England, Luxembourg. Wow. We have we have the whole globe covered. So this is awesome. You will actually get to hear from me in New Jersey and Martin, who is, I think, currently in Spain. So, yeah, we are all over the globe for this one. I see a lot of people still joining. We will go ahead and get into the content. We're about to after. So, today is gonna be really looking at diving under the hood, debugging AI agents with precision, and, how exactly are we gonna get there to the point where we feel confident to debug our AI agents? Well, here is exactly how we're gonna get there. We are going to understand the AI agent landscape. We're going to understand some of the unique debugging challenges that comes with, just debugging AI agents. We're gonna understand, some troubleshooting as well as the design for, debugging and the impact that it has on the actual business, as well as debugging in Dataiku. Of course, we'll get to see it in the platform. So before we hop into, our introductions, I would like to say if you have any questions at all during this session, please go to the q and a section. You should see it next to messages, within your chat window. Go to the q and a section and leave a message there. I recommend you leave it during the session. We will have time at the end of this, maybe about ten minutes, to answer any lingering questions that you may have. So don't be afraid, to ask your questions. Go ahead and just post it in there. So now let's get well acquainted before we start into the actual information. My name is Chad Covin Kovan. I'm a senior technical specialist here at Dataiku, part of product marketing, and I am joined by Martin, who I'll allow him to introduce himself. Yeah. My name is Martin. I'm a GenAI software engineer, like lots of people nowadays. I worked on Dataiku Answers, agents connect, Traces Explorer, and some upcoming new features. And I'll be presenting some of the demos in Dataiku today. Awesome. Thank you so much, Martin. And let's go ahead and hop into it. Right? So let's talk about really what's happening with AI agents right now. So they've exploded from these cool tech experiments to really must have business tools. And to understand this, you could just look at the numbers. More than half of mid sized companies already have AI agents up and running, and nearly 80% are getting ready to jump into that AI agent pool. So what's really interesting is Gartner forecast that by 2028, these systems will be making about 15% of everyday work decisions completely on their own. And that's huge when you consider they're they're basically making none of those decisions today. And we're not just talking about simple chat bots anymore, we're really talking about these sophisticated systems that can plan complex tasks, they can use specialized tools, and they can really make real business decisions. But here's the challenge that we're all facing. Everyone is excited about AI agents, but only about 30% of pilot projects actually make it to production. And the number one roadblock is really getting them to perform in a reliable way. And that's exactly why debugging has become such a critical skill and why we're here today. So let's really hop in and understand how we can solve this sort of issue. So here's the reality check that we're facing for AI agents. It's incredibly easy to get an agent prototype working in some sort of control design development environment, but then scaling to production is a whole different ballgame. So when you ask teams why their project stalled, the answer usually isn't about, you know, cost or even safety concerns. It's about performance, quality, and reliability. And there's a fascinating psychological event that happens there too. So when you come from more of a traditional software perspective, if there's a bug, users typically can blame the software. But when an AI agent makes a mistake, users often lose trust in the entire system, and that trust is incredibly hard to rebuild. So what makes debugging AI agents so important, but also so uniquely challenging, are really three big obstacles that even the best data teams struggle to understand, when building agents and making sure their behavior is reproducible and effective. So the first of these challenges is, AI agents that hallucinate and give incorrect inputs. So unlike traditional bugs that crash your program or throw errors, these issues can be incredibly subtle and damaging. And here's what makes this so tricky, is when an AI agent hallucinates, there is no stack trace to follow. Right? The model might confidently make up an answer that sounds completely plausible, but is factually wrong. And because it's delivered with the same confidence as accurate information, users can't easily tell the difference. So in traditional software, a bug is usually deterministic. The same input produces the same output. But with L. L. M. Based agents, each run could produce different text making traditional unit tests pretty ineffective. And you can't just step through the code line by line to see where things went wrong. So, you know, instead of debugging code, we're essentially debugging, the behavior of a complex system. And this requires a completely different approach in tools than what we're used to. And it's really the major the the first major hurdle that teams need to overcome when deploying agents. The second major challenge is something that really drives, I would say, data teams, dev engineers, data scientists. It just drives them crazy. It's non determinism and reproducibility problems. So we all know that classic situation where you try to run it on your machine and it doesn't work and then you go to your colleague and it works on their machine. But really, AI agents kind of take that to a whole new level. So by design, LLMs and their outputs have kind of a tinge of randomness. Even with identical inputs, right, the same exact prompt, you might get completely different responses on each run. And a bug that appears once in every, let's say, 10 runs is especially frustrating because you can't reliably reproduce it to eventually fix it. So think about how frustrating that is in practice. Right? Your agent works fine in testing, but in production, it occasionally goes off the rails. And when you try to recreate the issue in your dev environment, everything looks perfect. So this makes traditional debugging approaches almost useless. So what we're really dealing with is a probabilistic behavior and not a deterministic execution. And without some sort of specialized tooling to capture these inconsistent failures, you're basically left guessing, you know, what went wrong and hoping that the fix that you put in place addresses the problem that you can't consistently reproduce. So the the third major challenge, and in my opinion, it's the most frustrating, is the lack of transparency and interpretability in your AI agents. So traditional software gives you visibility into exactly what's happening. Right? You can step through code, you can inspect variables, you can follow logic, But traditionally, with AI agents, and you'll understand why I say traditionally in just a moment, we're often dealing with black boxes. So without proper observability, you can't see why an agent made a particular decision. Was it the prompt? Was it the context window? Was it the tool selection? When things go wrong, debugging can become kind of like guesswork if it's not done correctly. So this visibility really gets worse with complex agents that combine multiple tools and reasoning steps. If your agent retrieves information, then plans actions, and then executes them, which step failed. Right? Without going into or I'm sorry. Without the visibility into the agent's thinking process, you're left tweaking random parts of your system, really hoping that something improves. And the most telling symptom is when you or your team revert reverts to making random changes to prompts without knowing what will fix the issue. And this sort of trial and error approach is just really inefficient, and it's pretty frustrating for everyone. So now that we understand the three unique challenges of debugging AI agents, let's consider a new design for our AI agents for both what's needed in building and debugging production level agents. So the right systematic choices can make the difference between a maintenance nightmare and a trustworthy high performing system. The first principle is simplicity first. And as counterintuitive as that sounds, the most effective agents are often the least complex. So each additional tool or layer of abstraction exponentially increases the the difficulty in debugging. And the research from Anthropic actually confirms this. The simplest solution that works. Right? Find the most simple solution that works, and then only add complexity to it step by step and when it's absolutely necessary. The second principle is build tracing in from day one. So your agent shouldn't just log what it did, but why it made each decision. So imagine using every function in your agent's execution loop to have, you know, structured logs with time stamps and context. And this isn't just about catching bugs, it's about understanding why your agent did the things that it did and how exactly your agent thinks about your problem or task. And the third principle is standardize your interfaces. So when agents interact with tools or pass information between components, using consistent and well defined formats prevent countless headaches. And this makes it easier to validate inputs and outputs at every single step. And these principles might sound straightforward, but, really, they are powerful when it comes to creating repeatable, systematic agents, and you'll see them in action during this demo. So, also, let's move not just, you know, let's not just think about agents in the technical aspect, but also why they matter, to the bottom line and project success. So when teams implement structured debugging approaches, they can see dramatic improvements in efficiency. For example, one company slashed their debugging time from 75% or they they slashed it by 75% with proper tooling, and engineers, can find the root causes in just a few clicks instead of hours of investigation. And this efficiency translates to faster development cycles and higher adoption rates. For example, OpenAI explained that Morgan Stanley achieved an impressive 98% adoption rate on their AI assistance system among their financial advisors after rigorous testing and debugging to ensure reliability. So contrast that to the industry average where only 30% of those AI pilots make it to production and that's that's amazing. Right? There's also risk factors. So Gartner predicts that by 2025, a quarter of enterprise data breaches will be linked to AI agent misuse or misbehavior with an average cost of nearly $5,000,000 per incident. So having that proper debugging and making sure that the performance of these agents are reliable, trustworthy, and reproducible is really essential, when it comes to protecting against these sort of disasters. So that's really why it's important for data teams to think about how to make their agents systematic and do debugging that's also systematic and repeatable. So now let's understand it from the Dataiku perspective. Right? And we'll see all of this in just a moment, but, Dataiku's agent framework records every step of your agent's execution. So with the Dataiku L. L. M. Mesh, you can really choose any L. L. M. Connection or provider that you want, even the latest state of the art model that maybe came out yesterday or last week. So agents can be created entirely with code or they can be created visually with Dataiku's visual code, visual agents. And this really just allows for faster implementation, deployment, and a more standardized creation. And each call, tool use, and decision is captured in structured JSONs with time stamps and the context. But the real game changer is also the way that you can navigate these traces visually. So the trace explorer lets you see your agent's reasoning in multiple different views. There's a tree view allowing you to understand the nested calls. There's a timeline view with allowing you to understand timing and duration of each of these calls and a more detailed information, view for each step. And this gives really full visibility into what your agents are actually doing and how they're thinking. And by combining all of these different debugging capabilities with the built in guardrails from the Dataiku LLM mesh and the standardized in in, interface of Dataiku, you can really dramatically reduce the time that you spend troubleshooting while also improving the agent reliability. So now I will hand it over to Martin and he will go ahead and demonstrate all of these capabilities and show you exactly how they work in the platform. Thank you very much. If you could stop sharing, and I'll share my screen. Thank you. Yeah. So in this demo, I'm gonna be walking us through an example project. So the original project here, came from a Dataiku, business solution, from the health and life sciences. This is the original project. It's the clinical trial intelligence. What we want to do is build an an agent on top of this. That means that we can interact and do all the typical tasks that, a user would do, but in an agentic way. Just to give a quick overview of this solution, this studies, publicly available, trial data. So there's obviously lots and lots of, drugs are tested, and majority of those don't go into production. But there's a lot of data around this about where these test, where this, testing is happening, the people involved, and we want to put an agent on top of this, to work with this data and to be able to query and understand it. This is the agent, so it doesn't look quite complex, when we look at it, from here. So this is the head of this is the agents connect. So this is, the tool within Dataiku that allows you to connect to all the different, agents, the code agents, official agents who, Chad was just talking about. But you can see this looks very, very complex. And, obviously, as Chad has, explained really well, we do not start from this. We start from the most, the basic elements of these, and so this is what we're gonna do today. We're gonna break this project down into the each individual element and understand how we start, make sure something's working correctly, debug those things, and then build upon it. So we'll start first with this section. So this is a summary agent. So you can see here this is just retrieving data using data retrieval tools. We'll be looking at a single individual retrieval with the summary and expanding that to have multiple retrievals. Then we'll look at a knowledge bank, so knowledge bank retrieval, which is quite popular and probably one of the most popular features of, the element mesh. Then we'll look at code agents so I can do more advanced tasks using, Python. And then after that, we look at a slightly more complex, use case where we've got a mixture of tools and agents, and we'll be using agents connect here just to be able to manipulate and understand what's going on, but then digging deeper with Traces Explorer. And then the final part, hopefully, if we have enough time, we'll be setting up Traces Explorer and Agents Connect together so we can have an ongoing cycle of monitoring a solution or a project in production. So to get started, we'll look at this first section now. So this is the summary section. So there's lots of different ways we can interact with, database data in Dataiku for, with tools. The two examples I'm showing here, the first one is just a basic parameterized, lookup, so just a column and a value. The second one is actually based on the code I wrote for, answers. So it is extracted as a tool, and this tool can, create SQL queries that are more complex. And this is done quite easily in Dataiku because we're taking advantage of the back end of Dataiku that already supports all of these different, data storage locations. And so this tool is the one that we'll be using for, some of these examples. And the first one that we'll look at here is looking at how we can summarize. So rather than starting with this agent with three complex datasets, we wanna make we're gonna break this down into a simple, the first one. So it's a simple dataset retrieval. So it's just a single row. Can we summarize that single row, in, an effective way? And if we can't, will then can we use that, prompt to then work in the agent? So to do that, we will jump into the first project. And so this is a single retrieval. The aim here is to create a prompt which summarizes well. It it's in the format that we want. We're also gonna add a guard against prompt injection, which is, one of the natively available Dataiku tools. And we'll also, see how we can quite quickly add examples. The thing we wanna look out for here as well is does it make sense to use caching? So the caching is available in Dataiku, so we can cache answers to avoid having to pay for the same query multiple times. Wanna see does it make sense, and we can examine that using Trace Explorer. So I'll just jump over to the video now. The data we're looking at here, obviously, this could be done with a prompt recipe, but I prefer to generally start with everything in the prompt studio. If you haven't seen it before, the prompt studio just allows you to build your prompt from scratch and interact with data in a more dynamic way. So we'll just be using a subset of that data here. So what I think tends to be overlooked a lot is the data the element does not have access to your data. It can't see it. So what we do to make it more effective, we're just adding some descriptions here to make, to, like, give an insight to the element to make it understand what's inside those columns. So this can be adding things like, information on categorical variables or information about ranges of values or even unique values that are in there. Something else I just I think it's quite nice to point out here. If you do have, image is in your input and you've got a multimodal model available, you can have images there as well. So it's a just a nice little extra. I'm gonna add a prompt here. So if you remember, just to go back, we're looking to create a summary prompt here, so it's from a single retrieval that can then probably generalize to the agent as well. To do it first, we're just gonna work on one dataset with one row at a time to to see how that works. Let's have a look at the prompt that we're using. You can see here, it's generally a good idea to have a role. Like, LLMs like to be given a role. They don't want to know who they are, and the task itself. This breaking down in, like, the specifics of this and a format. Now this could also be done in rules. Sometimes people like to have do this, don't do this, and this is something you can do here. And as I mentioned before, we have our guardrails and all these nice little, but very valuable features of, Dataiku's LLM mesh. The one I'll be working with today is the prompt injection detector. So this is actually using another LLM call to make sure that there's no prompt injection here. Maybe there's been some, like, security issues, and we wanna be add the extra added level of security. So I have a check here, and it's just a few clicks in Dataiku to set that up. Now I'm running that prompt. I'm getting back the answers, and you can see that prompt's working pretty well. It's getting the markdown format as expected. And now we can also check the system prompt, the user prompt. So So we're digging into what's actually being sent to the other line here, which is really, really helpful rather than having the chatters explaining those black boxes. We wanna be able to see step by step what is happening in all of these steps, and then investigating it further. And another, like, nice little feature, just with a single click here, I've added to that prompt an example. So we've got if we see an example of where this is working really, really well, we can just inject that into the prompt, and that's gonna be used in the future, to make those examples more robust. And so now I am happy with that prompt. I'm just gonna convert that into a recipe. The reason I'm doing this because I'm invest want to investigate a little bit further those traces. So as we mentioned earlier, we could use Traces Explorer to do that. So just with a single click there, I've converted all of that, nice prompt even with these examples and the injection detection all into a recipe that's now gonna be, in our flow, and we can use that to have a look at the traces. One thing to keep in mind here, we wanna see we wanna be able to collect the raw outputs with the traces, which is not the default value here just because, those traces can get quite big and some people don't always necessarily want them. So it's just a couple of clicks to enable that, and then we can jump in and look at the, raw query and then the query response. So what you're gonna see here is a massive JSON, which is great because there's lots of information, but, not necessarily that easy to understand. We can see, obviously, that, yeah, the caching is turned on, but what's that effect? It's kind of really difficult to see. I mean, if we have a look at that, Jason, a bit closer, yeah, we can kind of expand everything. We can see what's being called. Yeah. A little bit of the estimated cost, but this gets very complex very quickly, and this is a very basic use case. As these things start to grow, it gets bigger and bigger. Things are nested more and more within each other and, yeah, then it becomes impossible to read. So that's why we decided, to create Traces Explorer to make a visual way of understanding this. So I can just grab that JSON. And something to bear in mind here, all we're looking for that JSON can have other values in there, other key value pairs. It will just detect if there is a trace in there, and if it won't if it's there, it will, display it. And it but there can be other values in that, JSON object as well. And so this is, what Trace Explorer looks like. So immediately, you can see that it's created our total tokens, the completion tokens, and the prompt tokens. You can also see the estimated costs for queries like this if we were to, extrapolate out to larger values of tokens. This right now, we're just gonna look at a specific of, query, which is the one we were just run before, and we can see here the text that was sent. And, also, more importantly, we can dig into those guardrails that we mentioned earlier. So this is the one where we're detecting any prompt injections. You can see the cost involved specifically on that, injection, and we can see the message that is sent. So this is the system message here, and this is the one that's default created by default in, Dataiku for you. And then, the user prompt here. So this is showing all of the input that was given to the second element. You can hear see here that it's detected as safe. And then the second element called, this is the one that's actually gonna be used for summarizing. And, again, we can see all of the inputs here, the system prompts, the user prompts, and the outputs as well. So this just gives us a nice overview of everything that's been involved, which I don't think would really be that that easy with those big nested JSON objects. And this is only a simple call. Yeah, we can see the text of the summary here in the correct format. Another nice feature of, Traces Explora is we get to see this timeline. So you can see of all the processes and subprocesses that are running here, how long each of those is taking, which maybe are taking a little bit longer than others, which are running in parallel, which I think is very interesting to see. We'll see some nice examples of that later on. And then finally, we can look at the explorer view. This is, again, a nice way of looking at these, sub, sub exercises subtasks within each of, the runs. So now, as we mentioned, we're interested in looking at caching. So I'm gonna rerun that task. We're gonna grab the JSON again, and we're gonna see we can see here that caching is on, but what does that change to the trace? Like, what does that actually mean? So if you look here, you can see we've hit the cache. So we do not have a second, LLM call here. We do have the check. So this check is still happening. We can see there's a cost involved there. So the check the check for prompt injection, is it still there? But the cached value for the query is, coming in. So we can actually compare as well the time. So this one's taking seventeen seconds, whereas this one's taking three. There's a definite, marked difference there. We can also look at the, layouts of those calls themselves in a tree. So this one, we can see the size is proportionate to the, to the tokens involved. And see that there are a lot fewer tokens involved here and a lot shorter time. So we can easily jump back and forth between the two and see the difference. Finally, I'm just gonna simulate. I've got a broken I've simulated a broken LLM connection here. We're gonna see what that will look like when we have that there. So we we can see here we've already got the error message, but it's saying there's an API key that's not right. We don't know if there's two LLM calls. We're not too sure what that is. So I can quick quickly just jump in here. And I can see, actually, only one of those LLM calls has been made, and it looks like the one to check for prompt injection. So it's probably in the prompt injection that we have an issue. So it's probably this is the best place to start when we run a debug. So I'm just gonna jump into the messages, and see what's happening. I can see here the error is coming in this one, and it's, an incorrect API key. So if I want to fix that, I'll just have to, update the API key. The next step now so we've already done a single retrieval. The next step now would be to look at multiple retrievals. So if we look back, for a second here, that would mean we now take the summary, prompt that we've used here, put it onto here, and then, again, we're just gonna retrieve rows of the data and then see how, how effective this is, summarizing when we have multiple data sources. Wanna make sure it's still in that correct format and that the prompt is still working effectively. And, again, we'll just keep an eye out for that caching to see how helpful that is for us. So here, you'll notice that, in the datasets that I'm gonna be working with, before we have descriptions, I'm just gonna simulate a bad setup. So everything you've seen from now on, it's bad. We don't have any date dataset descriptions. We don't have any column descriptions. The dataset name is very vague. So it makes it really, really hard for that element to know what it should be doing with that data, which columns it should be using. Standard, there will be, the schema sent to the LLM, so it has to usually infer from that. But that can be a really, really difficult task if you don't know the in-depth business knowledge that's associated with those columns and with that data and how to handle that data. So we're just gonna simulate that now. I'm gonna set up three tools to interact with data, but I'm not gonna give them any descriptions of, what's in the data themselves. I'm not gonna describe any of the columns, and I'm not gonna describe the datasets. So this makes this task really, really hard. I'm also not even giving a prompt to the LM. So it makes it even harder still. I can see, obviously yeah. The LLM I've chosen here as well is something is, GPT 3.5, which is it's yeah. When it released, it obviously stated the art. But now with tasks like this, SQL generation, which is probably the hardest task that answers our agents connect or any of these tools tend to have to do, it's a very, very complex task. And, yeah, generally, GPT 3.5 and similar models do tend to struggle with it. And so this is what we can see here. It looks like it's not being able to complete that task. Which is really difficult. Like, I don't know why. There's lots of logs of luxury. We wanna be able to see in a really intuitive way. So I'm just gonna grab the traces again. You can see a very, very big trace. Let's see first what has worked well. So I can just look at the sources that have been retrieved for the main LLM. It looks like it's tried to run some of those. So it's decided to use some of the columns, and I had a look at this earlier. It's not really decided the correct columns to use. It has created a SQL query, which does seem to have, a column that it's filtering on, but it's not actually the, like, it's not necessarily running in the right way. And if we look at a bit further on, when we look at the tool output specifically, what we can see is actually it's a malformed, query. It's the from statement is incorrect because it's not using the correct, dataset name, and it's not using the correct syntax. This is probably in indicative of either, like, badly described data or poorly, like, the poor choice of LLM for the task. So what we're gonna do is we're gonna fix that now. So we've taken our tool, and we've, yeah, the three tools that we created, we've improved the prompts. We've also like, in between here, I'd I've skipped ahead a little bit, but I've shown some, examples to the LLM of what it can do, like, using I like, with to be able to to be able to filter in a more effective way, because we saw a few errors of this. And I've also improved the, model that we're using. We're using a more advanced, model using the anthropic cloud, 3.5, and this is gonna work a lot more effective at the task like this. So what we can do now is put them side by side. So this is the poor one with poor descriptions, and we can put this side by side against a more detailed LLM. And, immediately, you can see that the poorer setup one has failed. And, actually, what I don't show here, but their query fails for a couple of reasons. One is that it just did a select star from table because it didn't know what any of the data was. So what happened then is that it just had huge, huge amounts of data that filled the context. And because it's quite a small, context window on 3.5, it instantly filled up the context window. So there's a couple of things that clearly can be improved there. And if we jump now to the nicely set up one, you can see that it's not only has it got the data, it's in the correct format. So we can do the same for all three of those now. So add similar examples. So for the study official, so the PI that's involved, the facilities for the location that's involved. And it it notice as well here is I'm, updating the LLM to make sure it's, the best one to use. And so we've got all three of those. We've also added the column descriptions, the dataset descriptions to make it as easy as possible for the model to infer, what to use. And, yeah, just showing here a quick way of doing this. If we just go into the schema view in Dataiku, it's an easier way to edit all of those, quickly. So now we have those three tools set up. I can run that query again, and, hopefully, this show have a much nicer output as you can see. Yeah. So it's broken it down. You can see this it's, calling all of those different tools and summarizing all of that data quite nicely. But, of course, we wanna remove that black box element from this. So why why not use our traces explorer again, see what it looks like when it is correct? Obviously, if you can see, it's much like, there's a lot more calls there, so it's obviously digging in a lot deeper. There's quite a few agent calls there. What's interesting to notice here is when things have run-in parallel, when they're running series. So that's, again, that's a choice of the LLM. But you can see here you can see the steps that are involved. So it's trying the attempts that it's making on each of those, datasets, the query that's created. Again, here it's choosing specific columns, so it's, definitely working well. But what's nice as well that we can see is the data that's been retrieved, and that's, I think, a really, really nice, useful way of understanding what data is being passed to the LN for it to be able to make those decisions. And as I mentioned earlier, this is a really nice way of interacting and seeing what is happening in parallel, what's happening sequentially, which of those have been called before one another. Now I'm not gonna go in through all of these because they'll take quite a long time, but, I can definitely reassure you that it's made the correct decisions and in the correct order because it's got much more relevant information. K. And the next step now, we're gonna have a look at a knowledge bank retrieval tool. This is using, the knowledge bank features in Dataiku. So we're gonna look at creating knowledge bank, investigating what parameters are used in it, having a look at the code and click options we have in dataiku, and then quickly show showing quickly how we can set up a web app, to be able to prototype what we're doing with this knowledge bank. And this doesn't necessarily need to be ready for production, but it's just a quick way of, setting something up. So the thing we're looking out for here is how we remove that black box element from the rack. Well, how do we know what's actually happening in the background when we're running the rack queries? So the data itself has been, summarized into these JSON objects. This is what we've embedded, using our, embedding recipe and data code. So, again, all of this is just through, clicks, so no code involved, to set this up. I'm gonna just simulate, what will happen if we, set some parameters. So in here, the number of documents to retrieve, we're setting it quite low to one, which is obviously not a great idea, but it's just to show, what happens if you get those parameters wrong. I'm gonna set up a quick, augmented LOM and jump back into, prompt studio to run this query. You can see yes. Like, of course, it didn't do too well, and it's unfortunately, I can't answer this question. And a lot of times what happens in these situations is people blame the LLM. They don't actually see the sources that have been given and understand that, actually, it's just not provided with the correct sources. So this is incorrect. It could be an incorrect, vector query that's happening that's causing this, but the LOM tends to get the blame similar to Chad was mentioning earlier. So we've just updated, that parameter. We could we should found more sources this time, and we've passed those, and it's able to now, complete the task. So we wanna see that a little bit further. Maybe if you are more interested in the code side of things, we've shown quite a few click options. Now let's have a look at a code option. This is a template notebook that we can just create with a single click in Dataiku. Choose my from a very big list of LLMs, I'll choose the one that I prefer here, and we'll see, how we can interact with that knowledge bank object from Dataiku using the Python API. So it looks like we've got back four sources, I think, if I remember rightly. Yeah. Four sources. Kenny's attempted to answer the question, but he says there are only two active studies. So probably, again, we're not retrieving all the ones, active, for colon cancer. So I'm just gonna look at what arguments are available through the API, and you can see that there's case. So this is the number of, documents that we can, retrieve. I'm just gonna put that back up to 10 and see how this changes the answer. So this again is improved, on the original answer, and we've got much more complete response. And, again, this is not the fault of the LLM. This is, the fault of, the setup, the fault of the vector query. Just gonna skip ahead with this tool so we can, see, another tool. So this is using data occurrences. So in a single click, we can now make a web app. So this is made a chatbot web app just by setting that up with a couple of clicks and now choose our LLM, choose, the datasets where we wanna, create the history, and all of the parameters that we've, taken from the knowledge bank will be copied over here into, this web app. This is another great way of debugging because what we can do is just quite quickly break down a single element of this bigger agent into a smaller part and then understand how this is working. So I'm adding here the knowledge bank description and the knowledge bank, context, prompt. Now this is a big question we get asked a lot, like, where are they being used? How why is one different from the other? And so I'm gonna show how we can use Traces Explorer to understand what is actually happening here. So I'll set this up. Obviously, I'm using putting zero here because we want multi multi threading and we'll set up debug mode. And if we now run this query, this, will create a query in the knowledge bank that we can then, go ahead and have a look at the context that's created from here and have a look at the logs. We can if we want, obviously, we can see the sources here. We can make sure that we have our 10 that we've selected and that they're the ones that we expect. Obviously, we can, if we wanted, look at the, logs of Dataiku answers, but then it's not that easy to read. So what we're gonna do instead is, I'll just skip ahead and we'll grab yeah. From the, conversation history, we're gonna grab the saw the LLM context. Here, we can actually see here the sources. We're gonna grab the LLM context. And, again, as I mentioned, you can have multiple other key value pairs in here. As long as they've got traces somewhere, we'll be able to find it, and we're gonna see what's happening. So you can see there are actually three LLM calls, three separate LLM calls, and this allows us to dig in a little bit deeper and understand what's actually happening here. So if we have a look, this is the one this, call is to decide should we use a knowledge bank, and if we should, what query should we be using against that knowledge bank? So we can see here, this should be the knowledge bank description. Yeah. There you can see see knowledge bank's description, and the knowledge bank contains data from clinicaltrial.gov. If you have a look back at the settings here, this is, the description here. So we know that this prompt is used to decide if we should use the knowledge bank, and if we should, what we should run against it. The next LLM call now is using the second prompt. So this is where we give in, like, the task, the role, the context, all the understanding of what the LLM should be doing once the retrieval has happened. So the retrieval has happened, we get that information, and then how do we interpret those results? So you can see that these calls are slightly different. But then there's a final call, this third call, which, yeah, what's this one? If if you look in deeper, you can actually see. So this is when we are creating the title. So if you notice in the top left, all the conversations have a title. This is where we decide what that title is gonna be. We just look at the history, look at the questions that are asked, and decide on what the title should be. We can see which of these running in parallel and the time taken for each of these and, all of the different steps that are involved. K. The next one is a code agent. And, see, we don't have much time, so I'm probably just gonna jump ahead, from the code agent, and we'll jump to this one. Yeah. We'll jump ahead to the multiple tools and agents. This section will be looking at taking what we already have. So a few tools, agents, and also agents using agents, which is, something we haven't seen up to up until now. What we'll do, I'm just gonna take make a temporary version of agents connect, which is their web app front end connecting the agents in Dataiku. I'm gonna set this up with all of these, code agents and tools, and we're gonna simulate an error. And we're gonna dig into why that's happened and what we can do about it. So if I just jump ahead now and yep. There we go. We can see yeah. I can see this is the first call. So just as a, an explanation, this particular section is about creating, draft reports and then emailing them. So it's getting information about particular investigator that's in charge of, a clinical trial, understanding information on those trials, and understanding information about that the trials that we're involved in. So just a look up of the individual trials. So the idea here is we'd probably look up an investigator to find all of the trials they're involved in. Once we find that, we create a report of all the information, and then we wanna email them. So I've already gone ahead and asked a question. We can see that the LLM has responded and given, like, quite a nice summary, which should be expected because we've already fixed our summary to prompt from before, and that's asking us to do on to email that. So I'm saying, Charlotte's email that, to our to me, but it looks like there's been an error here. So it says it's been able to draft the report, but it hasn't been able to email it. So, again, we wanna dig in deep into what's happening here. So I'm just gonna find the specific query. This is using the, chat history logs from Dataiku and, Dataiku agents connect, and I'll look in the LLM context, grab that, to clipboard, and I'll just paste it in here. Can see here there's quite a few calls, so it's quite a lot of stuff to dig into. But you can see the individual, calls that are happening and, how they're all connected. I'm gonna go to the final step here. We're just gonna go step by step See it's getting the history. So it's seen the previous steps in that, conversation. It's been able to, it sees the system prompt from previously. It sees the user question. This is the one I asked originally. It then sees the, like, what the assistant has responded with as it's been building, as it's been running those different tools. So you can actually see some of the, queries that it's been making, and the response that it's done. And then it asks again, like, this is me asking for it to email, and this is the agent deciding to create that email, deciding to draft the report, and now you can see it calling the function. This function is to send the email. This is one of the built in tools in Dataiku. You can see it's used the tool correctly. It's using all the correct arguments, so that looks good. So it's the call has been made, but it looks like the response is not as expected. So let's have a look at that tool output. It looks like oh, yeah. There you go. You can see the error there. It looks like it's not been able to send the email. Ah, look. My email address is wrong. So that's what it is. I think it would have been impossible to find if you're digging through all the other logs, but just by using Traces Explorer, you can just go step by step through all of those messages and quite easily to find the error. So now I fixed that. I don't even need to reset start that back end. Just come back into the same chat and ask that, to send it try and send it again. It does, and it's able to create the report with all the information. So you can see how even a complex, agent can be set up, in agents connect quite quickly, to be able to send the email. Just have a look in Gmail now, and you can see yeah. And it's even doing done the correct formatting with the correct colors. So it did a perfect job, even if, I hadn't set it up right in the first place. And we can now see just to make sure that that's working as expected. Grab the traces again and look at that final call, the email tool call, and make sure that that's as expected. Yeah. The status is okay, so we know that that's working as expected. And the final step now, this is looking at, setting up, agents connect and traces explorer. So if you imagine we've got this, agent in production now, it's great. Everyone's using it, but we wanna be able to monitor it. We wanna we don't want the situation where for one particular user, we're getting unexpected answers. And we at the same time, we wanna be able to understand, you know, maybe some calls are taking a lot longer than others. Maybe some are using more tokens than others. So we wanna be able to dig in a bit deeper into that to understand what's happening. So what I'm gonna do is I'll set up, agents connect, which we've already done, ahead of time, and I'll just show how we can attach that to Traces Explorer, to go to have continuous ongoing monitoring, to make sure that there are no resources that have been overused, and to understand how we can monitor something at scale in production. So to do that, I'll jump back over to the demo here. Again, this is using the chat history from, agents connect. And now I wanna make a Traces Explorer instance. So I'll just look for the Traces Explorer web app and set up a nice web app called Traces. And I just need to find the dataset where that's, the history it is and the column in there. And you can do this with any column, of course. It doesn't have to be agents connect or answers. It can be any of your data as long as it's logging in the format that's expected. Traces Explorer will be able to read this. So you can see those three, different calls. There's gonna be quite a large one here. This is probably one of the biggest ones. But if you think about the task that that's replacing, it makes perfect sense. That's probably an hour's worth of work that is done within, you know, a few seconds. So we wanna understand now, yeah, maybe we've got lots of different traces here. So I can just quickly filter through, look at the ones that are not taking that much time, you know, just, a few hundred seconds, whereas we can increase this to, yeah, probably a few minutes. So it's a hundred and, yeah, hundred and fifty one seconds. We can see within that what's the thing that's taking the longest. Is it an LLM call? So I'm just gonna, sort these. And, actually, if you look at it, it's not the LLM calls. It's the tools themselves. It's actually one of the tools. So this could suggest that maybe the SQL database that we're choosing for this is slowing us down. Maybe there's a the query itself that's being run is maybe not the most efficient. So I'll have a look deeper at this and see what's actually going on. So if you have a look at the messages in this particular call, you can see here, actually, it's querying quite a few sources. And so probably this is what's, taking, it's taking a long time. So it might be a case that we might wanna consider another data source, or we might wanna consider, like, is there a more efficient way of maybe preparing this data so it's easier to use in the first place? And it it reduces the latency for the end user. So there's lots of things to explore. So, hopefully, yeah, we've had a nice overview of all of those different elements. There were some things I didn't get to show, which I would have, liked it, but I think, hopefully, yeah, if you're curious, I think there's lots of things to explore in data cube. And, yeah, hopefully, you'll be able to create a traces that are this large and doing this many things and still be able to understand what's going on. But, yeah, thank you very much. I think we can move over to the q and a. I'll stop sharing my screen now. Yep. Hey. Thank you so much, Martin, for the the amazing demo. I will for now, I will share my screen one more time just to put questions up on the screen so that everybody knows it is the question section of the day. So go ahead and ask any questions that you guys still may have lingering. You could put it either in the chat or in the q and a section. But I did want to address, one question from the chat that we just got from Wayne, which is, do these logs persist over time? Are there options of how I can save these logs perhaps in an s three repository or something like a Postgres, instance that supports JSON data types. I have to think having a single repository would be advantageous instead of having logs all over the place. And I can actually take this. Wayne, I did answer your question within the chat, but, just to speak to it further, what's really great about, answers, or, I'm sorry, Agent Connect, which Martin showed off, which is, as a user goes in and starts to talk to the agent, their conversation is being logged on the back end. Right? And you get to choose where you would like to save those logs. So if you want a Postgres, go ahead. If you want Snowflake, if you want Databricks, if you want, let's say, Redshift, s three, anything. Right? You can save it to any of those data sources, and you can always have those logged conversations saved and they persist over time. And you can also point your traces explorer directly to that data set so that you can investigate those traces as they're made. So, it it really is a benefit of using Traces Explorer. You can understand how your agent is working, but, also, you don't have to do the work of logging, the chats and the traces of those chats yourself, they they are done essentially hands off automatically. Alright. Moving forward, some other questions. How how do you enforce the agent to strictly follow the steps defined in the prompt? Martin, I don't know if that's something that you would like to give your hand at. Yeah. Yeah. Sure. I can do. So, yeah. This is part of the reason why we have Traces Explorers. There is an element of, randomness and freedom like Chad was explaining in the beginning. We've noticed that the more instructions you give like, when we've tested this, the more instructions you give about how to proceed, the better. But, obviously, like, choosing the correct element for the task, is the best thing. But as always, like, evaluation. So make sure, like, we we've shown here, if you're collecting those logs in production, then we evaluate afterwards. And so we have expected answers, and then we can evaluate, each of those expected steps against the actual steps to make sure that it's, doing as expected. And we can use an LLM as a judge to do this. So, yeah, the the the short answer is that there is it's quite difficult to control. The long answer is there are things you can do at the prompt level, but also the monitoring level. Mhmm. We have another question. How would you use this in real estate? So I think the interesting example that we actually covered at, Everyday AI, which if you guys are new to Dataiku, is our flagship conference. And we recently had that, I believe, about two weeks ago or maybe three weeks ago, in New York. And that was the focus of our keynote demo. It was creating a, real estate AI helper agent that would help real estate agents, you know, with their administrative tasks, like setting up inspection tickets through ServiceNow or, easily sending out, Google Calendar invites to, you know, all aspiring renters, creating, listing descriptions. There's many different things that I can't remember off the top of my head that we had to do. I think, also analyze, like, legal documents to make sure that listings were up to snuff in terms of, legal inspection. So there's many different things that we can use agents for for those type of tasks. So I recommend, if you wanna see a rewatch of that demo, go check out, Everyday AI and, you can you can rewatch the the keynote from there, through the replay. Another question that we just got was over time, repeatability is going to be important, especially as things change over time. Could I possibly use past traces to compare against, when doing changes to evaluate consistency, or is there something else you would suggest to ensure repeatability and consistency? This is something actually that we do all the time. So we have, like, previous because, actually, it's something we've noticed is that the LLMs themselves, even if you use the same LLM you have called in the past, they change their system prompt. So something that worked like, I've got examples of this. Something that worked six months ago doesn't work now and vice versa. Like so they're constantly changing their system prompts, so we need to have, yeah, checks of this over time. So, this will yeah. This can be through traces. It can be through the history itself and also just through basic evaluation. So collecting these traces and then extracting responses from them and then comparing responses now to previous responses and using an LMS judge and preferably an LLM that's not the one that's involved in any of this process. So if you're using, you know, OpenAI for your web app, then you evaluate with a cloned one. Yep. Fantastic point. And I think even to add some more color to that, some people, or really some organizations for that reason would look to use their own locally hosted, models. Let's say, from Hugging Face, because there is so much change that happens on the back end for some API hosted models, like, you know, one of OpenAI's models or Anthropics models or, Mistral. Some organizations decide it's easier and, in their opinion, for certain use cases, it may be safer, to use a locally hosted model and, also, hopefully, have more of that repeatability because now the back end system message is not being changed because they have more control over that. So with that being said, it is, I believe, 12:00 on the dot over on the East Coast. We wanna thank you guys so much for joining this Dataiku live webinar on debugging AI agents. On behalf of Martin and I, we appreciate you for joining. And you will receive a follow-up email, at some point this week, with the recording as well as the slides. So once again, thank you all so much, and we will see you next time. Thanks a lot.