Assessing AI Agents
When you first create a simple agent, it’s easy enough to understand what’s happening. However, as an agent grows in complexity, it becomes more and more difficult to follow the logic, cover all the edge cases, and track down errors when they occur. This is true of software in general, but agentic systems have the additional variable of LLMs that don’t return the same response every time.
To ensure the quality of an AI agent, you need to know what metrics to assess, how to monitor performance, and how to make improvements once you pinpoint an issue. First, you’ll look at what to measure.
Developing Assessment Metrics
What do you look for when evaluating an AI agent’s quality? Some areas to consider are accuracy, user satisfaction, and efficiency. Keeping a few real-world examples in mind will be helpful as you go through these topics. Remember the localizer app you’ve been building throughout the module. Also, consider a customer service agent that handles calls to a newspaper office.
Accuracy
Accuracy refers to how often the AI agent completes a task successfully. This can be thought of in terms of the agent’s success or error rate.
Take your application string localizer agent as an example. If you had a hundred strings that you needed the agent to translate, and the agent translated 95 of them correctly and five incorrectly, then the success rate would be 95%, while the error rate would be 5%. Is that acceptable? That may depend on what you’re counting as an error. A “correct” translation is somewhat subjective. If a phrase is correct in meaning but sounds a bit awkward, do you count that as an error? That’s something you’ll need to think about.
How about the customer service AI agent at the newspaper office? What do you count as a success? What’s an error? A success would probably be that the customer accomplishes what they called about: They got a question answered. They put their newspaper on hold while they’re on vacation. They canceled their subscription. Even if the AI agent can’t handle a task, you might still count it as a success if the agent successfully passes the customer over to a human.
User Satisfaction
User satisfaction is closely related to accuracy. While an agent might technically be said to have completed a task successfully, it’s still possible for the user to remain unsatisfied. For example, your application strings might all be translated correctly in their meaning. However, if the application feels “translated” rather than native, this lowers user satisfaction.
Going back to the newspaper customer service agent, a customer might “successfully” get a discount on their subscription, but if they had to repeat their request 20 times, that hardly makes for a satisfied customer. You could say that a satisfied user is the gold standard for evaluating the success of an AI agent.
Nowadays, hardly anybody wants to talk to a machine. The experience is too painful. It’s much more pleasant and effective to talk to a human. Can you imagine a world, though, where the agent is so knowledgeable, so natural sounding, and so effective that people universally prefer talking to an AI agent over a human? Can you build that kind of agent? The technology to do so is perhaps already here. Architecting and building that system is your job.
Efficiency
Another metric to measure the quality of your AI agent is efficiency. Time and resources are both issues here.
Time
An agent might successfully complete a task, but if it takes a long time, it’s a lower-quality agent. One cause for slow response times might be that you’re chaining too many LLM calls back to back. Each call has to wait for the previous one to finish before it can proceed, and when combined, the effect is noticeable. Another cause for a slow response might be server overload.
All this depends on your application. If it’s a string localizer, you probably don’t care if the response takes a few extra seconds. However, a three-second delay before answering might be unacceptable if you’re building a voice-based customer service agent.
Resources
Resources for an AI agent largely refer to the number of tokens a task uses. More tokens mean more money. The cost per million tokens is decreasing, but it can still be significant for certain applications. That means you don’t want to waste tokens unnecessarily.
One major case where you might be passing more tokens than you need is with the chat message history. With each turn between the human and the chatbot, the AIMessage and HumanMessage list gets longer and longer. If that context isn’t needed, then why pay for it?