So, you’ve built your agent. It takes in inputs and tools, processes them, and generates responses. Maybe it’s making decisions, retrieving information, executing tasks autonomously, or all three. But now comes the big question – how effectively is it performing? And more importantly, how do you know?
It has been revealed that building an agent is one thing; understanding its behavior is another. That’s where tracing and evaluations come in. Tracing allows you to see exactly what your agent is doing step by step—what inputs it receives, how it processes information, and how it arrives at its final output. Think of it like having an X-ray for your agent’s decision-making process. Meanwhile, evaluation helps you measure performance, ensuring your agent isn’t just functional, but actually effective. Is it producing the right answers? How relevant are its findings at each step? How well-crafted is the agent’s response? Does it align with your goals? (Related: Tech Report: Developer builds a ‘Discord kitten’ that’s...)
According to recent reports, arize Phoenix provides a centralized platform to trace, evaluate, and debug your agent's decisions in real time—all in one place. We’ll dive into how you can implement them to refine and optimize your agent. Because building is just the beginning—true intelligence comes from knowing exactly what’s happening under the hood. (Related: Tiny Agents: an MCP-powered agent in 50 lines of code...)
For this, let’s make sure that we have an Agent setup! You can follow along with the following steps or use your own agent.
Now let’s bring in the classes and tools we’ll be using:.
We’ll create a model instance powered by the Hugging Face Hub Serverless API:.
Now for the magic moment—let’s see our agent in action. The question we’re asking our agent is:“Fetch the share price of Google from 2020 to 2024, and create a line graph from it?”.
In a recent development, once your agent is running, the next challenge is making sense of its internal workflow. Tracing helps you track each step your agent takes—from invoking tools to processing inputs and generating responses—allowing you to debug concerns, optimize performance, and ensure it behaves as expected.
To enable tracing, we’ll use Arize Phoenix for visualization, and OpenTelemetry + OpenInference for instrumentation.
Install the telemetry module from smolagents:.
It has been revealed that you can run Phoenix in a bunch of different ways. This command will run a local instance of Phoenix on your machine:.
For other hosting options of Phoenix, you can create a free online instance of Phoenix, self-host the application locally, or host the application on Hugging Face Spaces.
After launching, we register a tracer provider, pointing to our Phoenix instance.
Now any calls made to smolagents will be sent through to our Phoenix instance.
Now that tracing is enabled, let’s test it with a simple query:.
Once OpenInference is set up with SmolAgents, every agent invocation will be automatically traced in Phoenix.
Once your agent is up and its run is monitored, the next step is to assess its performance. Evaluations (evals) help determine how well your agent is retrieving, processing, and presenting information.
According to recent reports, there are many types of evals you can run, such as response relevance, factual accuracy, latency, and more. Check out the Phoenix documentation for a deeper dive into different evaluation techniques.
Industry observers note that in this example, we’ll focus on evaluating the DuckDuckGo search tool used by our agent. We’ll measure the relevance of its search results using a Large Language Model (LLM) as a judge—specifically, OpenAI's GPT-4o.
First, install the necessary packages:.
We’ll be using GPT-4o to evaluate whether the search tool’s responses are relevant.This method, known as LLM-as-a-judge, leverages language models to classify and score responses.
To evaluate how well DuckDuckGo is retrieving information, we first need to extract the execution traces where the tool was called.
Next, we load the RAG Relevancy Prompt Template, which will help the LLM classify whether the search results are relevant or not.
Now, we run the evaluation using GPT-4o as the judge:.
It has been revealed that with this setup, we can now systematically evaluate the effectiveness of the DuckDuckGo search tool within our agent. Using LLM-as-a-judge, we can ensure our agent retrieves accurate and relevant information, leading to better performance.Any evaluation is easy to set up using this tutorial—just swap out the RAG_RELEVANCY_PROMPT_TEMPLATE for a different prompt template that fits your needs. Phoenix provides a variety of pre-written and pre-tested evaluation templates, covering areas like faithfulness, response coherence, factual accuracy, and more. Check out the Phoenix docs to explore the full list and find the best fit for your agent!
📻 🎙️ Hey, I generated an AI podcast about this blog post, check it out!
This podcast is generated via ngxson/kokoro-podcast-generator, using DeepSeek-R1 and Kokoro-TTS.