In addition to testing your agents skills and router capabilities, you need to ensure that your agent can respond to a user's query in an efficient number of steps. In this lesson, you'll learn how to assess this by computing a convergent score and apply the test to your agent. Example. Let's go. Now what is an agent trajectory? A trajectory is simply the path the agent takes through different router tool and other logic steps. For a given input. Looking at your example agent, you can examine a few different trajectories to get a sense of how these work. First, you can examine a query like which store had the most sales in 2021? In this case, the agent would go from the user to the router and then would go from that router to, in this case, the lookup sales data tool, as well as the data analysis tool. Back to the router and then finally back to the user. Now one important thing to call out here is that in this case, the agent has been built to allow for multiple tool calls from one router step. So that's why you see both the Lookup sales data tool and the data analysis tool being called together in the one step between routers. Some agents limit their routers to only call one tool at a time. That's just an architectural decision that you can make when building your agent. To look at a more complicated trajectory. You might have a query like plot sales data volume over time. In this case, your agent would go through a user to the router to your to look up sales data and data analysis tools back to the router, which then decides to call the data visualization tool to generate that visualization code that would then return back to the router and finally go back to the user. So these are pretty straightforward trajectories so far. All told. But you can imagine that trajectories get very complicated very quickly. Your example agent has three tools. But agents in production can have ten, 20, 30 different tools that they use. And even some systems will start to compose multiple agents together. So those agents can work together with each other to accomplish some sort of goal. in these multi-agent systems. You can have trajectories getting very complicated very, very quickly. Now you might be asking if your agent's output is correct. Does the trajectory really matter all that much? And the answer is yes, because efficiency matters in this case. Now you might have a certain use case, like if you're working on a hobby project or you're doing some research where the efficiency of your agent doesn't matter. That might be okay. But in most production agents or real world agents, some amount of efficiency matters. If you can answer a user's question in six steps as opposed to 11 steps, that means fewer limb calls. That means less variability. That means lower cost and lower latency for the user. So how can you track and measure trajectories? One way to do that is using a tool called convergence. convergence as a measurement for how closely your agent follows an optimal path for a given query. So you can think about this as a measurement of how much your agent has converged towards an optimal path for a certain type of query. So how do you test for convergence. Well one way to do it is using the following technique. You can run your agent on a set of similar queries. In this case it could be a bunch of questions that ask your agent to retrieve sales data from November 21st, and then construct a set of different graphs or visualizations on that data. And the idea here is you want questions that are similar enough where your agent really should take the same path through each of them, but different enough that there could be some variation that you can improve upon within your agent. Next, you run each of these queries through your agent and record the number of steps taken for each of those queries, and then find the length of the optimal path taken. In this case, that's the minimum number of steps that your agent took to get through one of these queries. Then you can use all of those different numbers to calculate your convergence score, which is a numeric representation of how often your agent is taking that optimal path. Another way to think about the convergence score is what percent of the time is your agent taking the optimal path for that given set of inputs? So a convergence score of one means that your agent's taking the optimal path 100% of the time, and your convergence score will always be between 0 and 1. There's a couple things to keep in mind when running convergence evaluations. First is that convergence evaluations will typically not catch situations where your agent takes an unnecessary step every time for every query in your test set. And the reason being here is that the optimal path in a convergence eval is typically the minimum number of steps the agent took to get through one of the queries. So again, if you have an unnecessary step that's taken by all the runs of your agent, typically convergence values won't catch that situation. Second, you want to make sure when running convergence evaluators that you're only running them using four completed runs of your agent. If your agent takes three steps to get into a problem and then errors out, you don't want to track those three steps because that will skew your convergence evaluation data. In this lesson, you've learned what trajectory and convergence are, why they're important to track and measure. And then one way to measure and calculate convergence. in the next notebook you'll implement this convergence measurement and evaluation technique.