Every agent demo goes the same way. You ask three questions you already know the answers to, the agent gets them right, and the room nods.
Then the agent meets real users, and someone asks the fourth question. It might be a slightly different phrasing, a term nobody defined, or something the agent should have politely declined.
A handful of good answers says very little about the next question.
I wanted a more honest way to know how good an agent is before that happens. Cortex Agent evaluations give you one. You write a small set of test questions with the answers you expect, run the agent against them, and read the scores. CoCo can drive almost every step, from building the agent to running the evaluation.
In this post I build a tiny orders agent, grade it, make one small fix, and grade it again. The use case is deliberately simple so the evaluation stays in the spotlight.
Think of an evaluation as a report card. Each test question comes with the answer you expect. Snowflake runs your agent on every question, and an LLM judge compares what the agent said with what you expected. We use two metrics.
The agent has a single tool, so I left the tool selection metrics out to keep things simple.
You need a Snowflake account with CoCo in Snowsight, a role that can create databases, semantic views and agents, and OWNERSHIP or MONITOR on the agent so the role can run evaluations.
Note: In the steps below, prompts will appear in bold italics so they are easy to spot.
Open a SQL sheet in Snowsight and create the database and the orders table.
The insert script in the repo then inserts 40 orders across Electronics, Apparel and Home. Each order is either Delivered or Returned.
Open a new SQL sheet and invoke CoCo . A panel opens on the right side. Then type the prompt below.
Create a semantic view on RETURNS_DESK_DB.DEMO.ORDERS for Cortex Analyst. Treat STATUS and CATEGORY as dimensions, AMOUNT as a measure, and add a metric for the number of returned orders.
CoCo will prompt you to allow execution for each step, so you could review ansd approve.
Cortex Analyst turns plain English into SQL, and the semantic view is how it learns what each column means. Review what CoCo generates and accept it once the measure and the returned orders metric look right.
Type the prompt below.
Create a Cortex Agent named RETURNS_DESK_AGENT in RETURNS_DESK_DB.DEMO with one Cortex Analyst tool that uses the semantic view from Step 1. Keep the instructions to one sentence, for example “You answer questions about orders and returns.”
I kept the instructions thin on purpose. The first draft gives the evaluation something real to find, and it makes the before and after comparison more honest.
The Agent is created successfully.
The test set is a table with two columns. One holds the question and the other holds a JSON object with the answer you expect. Here is one row.
{ “ground_truth_output”: “14 orders were returned.” }
The other four rows follow the same pattern.
Two of these questions are traps on purpose. The revenue question depends on a definition the agent has not been told yet, and the weather question checks that the agent declines instead of making something up. I computed the expected answers from the generated data.
Now that the agent exists, run 02_eval_dataset.sql from the repo in a SQL sheet. It creates the AGENT_EVALUATION_DATA table with the five rows from Step 4. Then run a quick query to confirm the rows landed.
You should see five rows, each with a question and its expected answer.
This is where the demo turns into a number.
“Evaluate RETURNS_DESK_DB.DEMO.RETURNS_DESK_AGENT against RETURNS_DESK_DB.DEMO.AGENT_EVALUATION_DATA using answer correctness and logical consistency. Name the run v1_baseline_strict.”
CoCo runs the agent on every question, traces each step and scores the run. You can also start the same run from the Evaluations tab of the agent in Snowsight. The tab will display “Evaluation in Progress” until it completes.
Answer correctness is 0.93 and logical consistency is 1.00. Four of the five questions pass, and revenue scores 0.67 because the agent gave two figures. It gave the all orders figure of $2,386 and then the $1,525 figure with returns taken out. That is the definition gap the fix should close, and the other four rows are already at 1.00. The agent also declined the Houston weather question correctly.
Ask CoCo to explain the weak spots and apply a fix.
“Show me the questions that scored lowest in v1_baseline_strict and explain why. Suggest changes to the agent instructions and apply them. As a starting point, tell the agent that revenue counts delivered orders only and that questions outside orders and returns should be declined.”
Then run the same evaluation again.
“Run the same evaluation again and name the run v1_tuned. Compare it with v1_baseline_strict in a table.”
CoCo performs the evaluation. Access the Evaluations tab for the Agent in Snowsight.
Comparing the two runs:
On the revenue question, answer correctness moved from 0.67 to 1.00, which lifted the overall score from 0.93 to 1.00.
In this post we built a small orders agent with CoCo, graded it on five questions, and found one real gap. The revenue answer mixed the all orders figure with the delivered orders figure, which scored 0.67 and held answer correctness at 0.93. One change to the agent instructions fixed it, and the second run scored 1.00 on both metrics.
Five questions will not prove an agent is ready for production, and I would not claim otherwise. What they give you is a baseline, a way to watch a score move after a single edit, and a habit that CoCo makes cheap enough to keep.
When you are ready, the same pattern carries over to a larger test set, more tools and the tool selection metrics.
The setup script, the test set and the CoCo prompts are in the GitHub repo.
I share hands-on, implementation-focused perspectives on Generative & Agentic AI, LLMs, Snowflake and Cortex AI, translating advanced capabilities into practical, real-world analytics use cases. Do follow me on LinkedIn and Medium for more such insights.
Agentic AI in Action Part 34: How Good Is Your Agent? Let Snowflake CoCo Grade It was originally published in Towards AI on Medium, where people are continuing the conversation by highlighting and responding to this story.
原文来源:pub.towardsai.net