Did My Agent Go Haywire?#
If you're using Agents today, there will be plenty of times where you overestimate or underestimate the performance quality and output of what your Agent is doing. One day, it could build you the most flush feature or fix a problem in the most effective way possible and the next day, it fumbles on a task that appears too obvious.
That's why knowing how your Agent will perform, both live, after the fact, and in the future is a key planning need for everyone and anyone using agentic workflows.
In this blog, you'll learn how to test, evaluate, and understand your Agent with kagent + Agent Substrate and agentevals.
Prereqs#
To follow along with this blog post in a hands-on fashion, you will need the following:
- A Kubernetes cluster running k8s v1.37 or above.
- Everything that's running/deployed in the Instrumenting Agentic Observability in Kagent + Agent Substrate blog post, which you can find here.
- Clone down this repo as it's where the manifests live for certain commands in this guide.
Did My Agent Do Good?#
The reality any time you run an Agent is that you realistically have no idea whether or not it's going to do what it was supposed to. Sure, you can have tools, Agent Skills, and specialized prompts, which of course help significantly, but you still can't measure what the output of an Agent will be by default.
A great example of this is when a new model comes out. After the release of a new LLM, a lot of people say "X model now doesn't work as good", and that's largely because what frontier providers do is allocate the hardware resources from the old model to the new model so it performs better, which means worse inference for the old model as it's not utilizing the same amount of hardware under load.

The "how" behind an Agent performing as expected has many variables as well.
- Was the same LLM used?
- Was the Agent run at peak load time for an LLM?
- Was caching involved?
- Were there tools or Agent Skills used?
- Was the same prompt used?
And as mentioned above, you don't know if the smallest change will break things. That's why evaluators are so important because without them, you can never really, truly trust your Agent.
The Goal#
For the hands-on portion (and the theoretical portion above) of this article, we want to prove out how evaluations can help us in our engineering work with Agents. We want to know how evaluating how an Agent works can help us trust our Agents more and also get better outcomes.
Here is what things will look like:
- Baseline: an Agent answers a fixed set of cluster questions. This will be done with a golden eval set.
- Score it: Run a deterministic check (
tool_trajectory_avg_score), LLM as a judge (final_response_match_v2) and a rubric, so you can see both kinds of scoring. - Make a realistic change: Switch to a cheaper model.
- Re-run the same prompts: See if the scores drop or if it's the same.
- See the same results in Grafana: Every score event in Loki carries the trace ID of the turn it judged, which you open in Tempo, and agent latency by
service_version(the revision) shows what the change did to speed.
Before the next section, ensure to forward traffic to the following UIs:
kubectl port-forward -n kagent svc/kagent-controller 8083:8083 # kagent CLIkubectl port-forward -n agentevals svc/agentevals 8001:8001 # agentevals UI and APIkubectl port-forward -n telemetry svc/kube-prometheus-stack-grafana 3000:80 # Grafanakubectl port-forward -n kagent svc/kagent-ui 8081:8080 # kagent
This is so you can access agentevals, the kagent UI, Grafana, and the kagent Controller is port-forwarded if you want to run Agent turns/calls programmatically instead of on the UI.
Deploying An Agent#
The first step from a hands-on standpoint, before even evaluating an Agent, is to have an Agent up and operational. You'll also want to record a baseline of an Agent run so you have an idea of what's expected or have a trace to turn into a golden eval set.
-
Set up your terminal for the rest of the guide to run the commands/manifests. Run these from the repo you cloned down via the prereqs section.
cd kagent-oss/v1/evalsexport AGENT=cluster-helper # the agent under testexport AE=http://localhost:8001 # agentevals, through its port-forwardecho "AGENT=$AGENT AE=$AE" -
Deploy the new
AgentandModelConfig. For the purposes of this article, OpenAI Models are used, so you will need an OpenAI API key.kubectl apply -f - <<EOFapiVersion: api.kagent.dev/v1alpha3kind: ModelConfigmetadata:name: gpt-62-solnamespace: kagentspec:provider: OpenAImodel: gpt-6.2-solapiKeySecret: kagent-openaiapiKeySecretKey: OPENAI_API_KEYstream: trueopenAI:apiFormat: responses---apiVersion: api.kagent.dev/v1alpha3kind: Agentmetadata:name: cluster-helpernamespace: kagentspec:harnessRef:name: kagent-defaulttemplate:inline:description: Read-only Kubernetes assistant used as the agent under test in the agentevals lab.modelConfig:name: gpt-62-solsystemPrompt: >-You are a Kubernetes assistant for this cluster. Use your Kubernetes tools(k8s_get_resources, k8s_describe_resource, k8s_get_events, k8s_get_pod_logs) to answerquestions about the cluster. Don't use bash for cluster questions, because it has noaccess to the cluster. Answer in one or two sentences.tools:- mcp:server:kind: RemoteMCPServername: kagent-tool-servertools:- k8s_get_resources- k8s_describe_resource- k8s_get_events- k8s_get_pod_logsEOF -
Run the below as agentevals keeps every session it receives, and when you get to the section below for changing models used, it needs to tell the "before and after". The kagent revision is how that's done.
REV=$(kubectl get agent "$AGENT" -n kagent -o jsonpath='{.status.latestSuccessfulRevision}' | cut -c1-12)BASELINE_REV=$REVecho "$REV"
Scoring Your Agent#
With the Agent deployed, you can now begin scoring it. There are quite a few ways to score Agents and the categories typically break down into:
- Trajectory
- Response
- Safety
- Multi-turn
- Quality
- Efficiency
For the purposes of this scoring, you will use scoring for the tool trajectory/average scoring, final response quality, and token usage.
-
Deploy the broken app, which will give your Agent something to troubleshoot/an action to perform so you have something valuable to test against.
kubectl apply -f - <<'EOF'apiVersion: v1kind: Namespacemetadata:name: evals-lab---# The Pod needs no network access.apiVersion: networking.k8s.io/v1kind: NetworkPolicymetadata:name: default-deny-allnamespace: evals-labspec:podSelector: {}policyTypes:- Ingress- Egress---apiVersion: v1kind: Podmetadata:name: checkoutnamespace: evals-lablabels:app: checkoutspec:restartPolicy: AlwaysautomountServiceAccountToken: falsesecurityContext:runAsNonRoot: truerunAsUser: 65534seccompProfile:type: RuntimeDefaultcontainers:- name: checkoutimage: busybox:1.37.0command:- sh- -c- |echo "checkout service starting"echo "loading configuration"if [ -z "$DATABASE_URL" ]; thenecho "ERROR: DATABASE_URL is not set; cannot connect to the orders database"exit 1fiecho "connecting to the orders database"while true; do sleep 3600; doneresources:requests:cpu: 10mmemory: 16Milimits:cpu: 50mmemory: 32MisecurityContext:allowPrivilegeEscalation: falsereadOnlyRootFilesystem: truecapabilities:drop:- ALLEOFThe Pod starts, logs why it can't run, and exits, so it ends up in
CrashLoopBackOff. The reason that it's failing (DATABASE_URLisn't set) is only in its logs, so the Pod status says it's crashing, but it doesn't say why (that's for the Agent to figure out). -
Below, you will see a question within the env var to ask your Agent, which gets asked twice, and each time the question gets asked (the
forloop you run below), a new kagent session gets created. The reason why is because one session needs to create the golden eval set and another is the control you score in the next section, Make A Change To Your Agent. The kagent CLI talks to the controller onlocalhost:8083.export QUESTION="The checkout app in the evals-lab namespace isn't working. Find out why."for run in 1 2; dosession=$(kagent agent session create --agent "$AGENT" -o json | jq -r '.session.id')echo "== run $run session $session"kagent agent invoke --session "$session" -t "$QUESTION"done
Each session shows up on agentevals Local Development page as one session card, marked completed a few seconds after the answer.
You'll see an output similar to the below:

Ironically enough, see how even the output has a different explanation?
Sidenote: Even though you'll be scoring the Agent against the change (in the next section), it's still good to have two turns/sessions for GPT 6.2 Sol because if you wanted to (it's optional), you can see how much the Agent varies on its own by evaluating them against each other with the same exact Agent configs (to the point above about seeing the output difference).
Make A Change To Your Agent#
In the two previous sections, you deployed an Agent, got a baseline, and scored the Agent. Now, let's see what happens when we change something fundamental for the Agent - the LLM that's used. The LLM that was used originally is GPT 6.2 Sol. Let's change it to gpt-4.1-mini and see what the output will now be. The goal is to prove out:
- On the three single-tool lookups, gpt-4.1-mini calls the same tools and gives answers as good as GPT-6.2 Sol, within the control run's normal variation.
- On diagnose-checkout, a smaller model is more likely to skip GPT 6.2 Sol's steps, such as reading the logs, and miss the real cause. Agentevals shows the exact turn and step where it fell short, so "is the cheaper model good enough?" gets an answer for each kind of task.
- Tokens and latency for each revision, from agentevals and from Grafana by service_version, show what the downgrade buys. Every score links back to the exact trace that explains it, so the decision is quality against cost with actual data backing it.
-
Deploy the change, which is swapping out the GPT 6.2 model with the gpt 4.1 Mini model
kubectl apply -f - <<EOFapiVersion: api.kagent.dev/v1alpha3kind: ModelConfigmetadata:name: gpt-41-mininamespace: kagentspec:provider: OpenAImodel: gpt-4.1-miniapiKeySecret: kagent-openaiapiKeySecretKey: OPENAI_API_KEYstream: true---apiVersion: api.kagent.dev/v1alpha3kind: Agentmetadata:name: cluster-helpernamespace: kagentspec:harnessRef:name: kagent-defaulttemplate:inline:description: Read-only Kubernetes assistant used as the agent under test in the agentevals lab.modelConfig:name: gpt-41-minisystemPrompt: >-You are a Kubernetes assistant for this cluster. Use your Kubernetes tools(k8s_get_resources, k8s_describe_resource, k8s_get_events, k8s_get_pod_logs) to answerquestions about the cluster. Don't use bash for cluster questions, because it has noaccess to the cluster. Answer in one or two sentences.tools:- mcp:server:kind: RemoteMCPServername: kagent-tool-servertools:- k8s_get_resources- k8s_describe_resource- k8s_get_events- k8s_get_pod_logsEOF -
Ask the same question as the previous section, but this time, only ask it once (this is what we'll be scoring against).
session=$(kagent agent session create --agent "$AGENT" -o json | jq -r '.session.id')echo "== session $session"kagent agent invoke --session "$session" -t "$QUESTION" -
Open the agentevals UI via
127.0.0.1:8001and go to the Local Development dashboard. You'll see 2-3 runs in there. -
Click the Set as EvalSet button for the session that has GPT-6.2-SOL as that will be the golden eval set.

-
Click the purple Continue to Evaluation button.

-
Ensure tool_trajectory_avg_score and final_response_match_v2 are chosen for the scoring. Then, scroll down to Evaluation Settings, have the model as gpt-4o, and click the purple Run Evaluation button.

You can now see the scoring results.

