
🧠 记忆锚点:别只看最终答案;评任务、轨迹、工具、恢复、成本与安全。
💡 答案要点
Agent评测 = 用标准化任务集量化Agent在规划/工具使用/多轮交互的能力
评测维度
| 维度 | 含义 | 指标 |
|---|---|---|
| 任务成功率 | 从头到尾完成任务 | 成功率% |
| 工具使用准确性 | 选对工具+正确参数 | 工具调用准确率 |
| 规划效率 | 步骤数 vs 最优步骤数 | 效率比 |
| 鲁棒性 | 面对错误/噪声的恢复能力 | 错误恢复率 |
| 成本效率 | 完成任务的Token/时间开销 | Cost per task |
主流Benchmark
1. AgentBench(清华/伯克利)
# 8种真实环境测试
environments = {
"OS": "操作系统Shell命令",
"DB": "数据库SQL查询",
"KG": "知识图谱推理",
"WebShop": "网购任务",
"WebArena": "网页操作",
"HumanEval": "代码生成",
"Mind2Web": "网页导航",
"Card Game": "卡牌游戏策略",
}
# GPT-4在AgentBench的表现
gpt4_scores = {
"OS": 0.58,
"DB": 0.33,
"KG": 0.92,
"WebShop": 0.40,
# 开源模型普遍<0.05
}2. 自建Benchmark(生产环境推荐)
展开 Python 代码示例(107 行)
class AgentBenchmark:
"""针对业务场景的自定义评测"""
def __init__(self, agent, test_cases):
self.agent = agent
self.test_cases = test_cases # 标注好的测试集
def evaluate(self):
results = {
"task_success": [], # 任务成功率
"tool_accuracy": [], # 工具调用准确率
"step_efficiency": [], # 步骤效率
"cost": [], # Token消耗
}
for case in self.test_cases:
start_time = time.time()
# 运行Agent
try:
result = self.agent.run(case["input"])
success = self.evaluate_success(result, case["expected_output"])
except Exception as e:
success = False
result = None
elapsed = time.time() - start_time
# 记录指标
results["task_success"].append(success)
if hasattr(self.agent, "tool_calls_log"):
tool_acc = self.evaluate_tool_accuracy(
self.agent.tool_calls_log,
case["expected_tools"]
)
results["tool_accuracy"].append(tool_acc)
results["cost"].append(self.agent.total_tokens)
# 汇总
return {
"task_success_rate": sum(results["task_success"]) / len(results["task_success"]),
"avg_tool_accuracy": sum(results["tool_accuracy"]) / len(results["tool_accuracy"]),
"avg_tokens_per_task": sum(results["cost"]) / len(results["cost"]),
}
def evaluate_success(self, result, expected):
"""评估任务是否成功"""
# 方式1:精确匹配
if result == expected:
return True
# 方式2:语义相似度
similarity = compute_similarity(result, expected)
return similarity > 0.85
# 方式3:LLM-as-Judge
judge_prompt = f"""
预期答案:{expected}
Agent实际输出:{result}
Agent是否正确完成了任务?(是/否):
"""
judgment = llm.generate(judge_prompt, temperature=0)
return "是" in judgment
def evaluate_tool_accuracy(self, actual_calls, expected_calls):
"""评估工具调用准确率"""
if not expected_calls:
return 1.0
correct = 0
for i, (actual, expected) in enumerate(zip(actual_calls, expected_calls)):
# 工具名正确
if actual["tool"] == expected["tool"]:
correct += 0.5
# 参数正确
param_match = sum(
actual["params"].get(k) == v
for k, v in expected["params"].items()
) / len(expected["params"])
correct += 0.5 * param_match
return correct / len(expected_calls)
# 使用
test_cases = [
{
"input": "查询北京明天天气",
"expected_output": "明天北京气温X度,晴天",
"expected_tools": [{"tool": "weather_api", "params": {"city": "北京", "date": "tomorrow"}}]
},
{
"input": "帮我发邮件给张三,告诉他明天开会",
"expected_output": "邮件已发送",
"expected_tools": [{"tool": "send_email", "params": {"to": "[email protected]", "subject": "开会通知"}}]
}
]
benchmark = AgentBenchmark(my_agent, test_cases)
scores = benchmark.evaluate()
print(f"任务成功率: {scores['task_success_rate']:.1%}")
print(f"工具准确率: {scores['avg_tool_accuracy']:.1%}")
print(f"平均Token消耗: {scores['avg_tokens_per_task']:.0f}")持续评测体系
展开 Python 代码示例(35 行)
class AgentMonitor:
"""生产环境持续监控"""
def log_interaction(self, session_id, query, result, tools_used, tokens):
"""记录每次Agent交互"""
record = {
"session_id": session_id,
"timestamp": time.time(),
"query": query,
"result": result,
"tools_used": tools_used,
"tokens": tokens,
"user_feedback": None # 后续收集
}
self.db.insert(record)
def collect_feedback(self, session_id, rating: int, comment: str = ""):
"""收集用户反馈(1-5星)"""
self.db.update(session_id, {
"user_feedback": rating,
"comment": comment
})
def generate_weekly_report(self):
"""每周评测报告"""
records = self.db.query_last_7_days()
return {
"total_sessions": len(records),
"success_rate": self.calc_success_rate(records),
"avg_feedback": self.calc_avg_feedback(records),
"tool_usage_stats": self.calc_tool_stats(records),
"failure_cases": self.find_failures(records),
"cost_summary": sum(r["tokens"] for r in records)
}面试话术:
示例表达(仅在能用本人经历或可复现实验佐证时使用): "Agent评测分离线和在线两套。离线用自建Benchmark:覆盖任务成功率、工具调用准确率、步骤效率、Token成本4个维度,测试集至少100条覆盖各种边界情况。评判方式用LLM-as-Judge,比精确匹配更灵活,准确率和人工评估一致性>85%。在线用生产监控:记录每次交互,收集用户1-5星反馈,每周生成报告。我们的Agent上线后,通过持续评测发现工具参数错误率偏高,针对性优化Prompt后,工具准确率从72%→91%。"
主流 Benchmark 三:VAKRA(IBM Research 2026年4月新版企业级Agent评测)
VAKRA = Tool-grounded, Executable Benchmark for Enterprise Agents
| 维度 | 说明 |
|---|---|
| 发布时间 | 2026年4月15日 |
| 发布方 | IBM Research |
| 定位 | 企业级 API Agent 评测基准 |
| 规模 | 8000+ 本地托管 API,62个领域,真实数据库 |
| 核心特点 | 可执行环境 + 完整执行轨迹 |
四大评测任务:
| 任务 | 测试能力 | 实例数 | 工具数 |
|---|---|---|---|
| API Chaining | 商业智能 API 链式调用 | 2077 | SLOT-BIRD + SEL-BIRD |
| Tool Selection | 从仪表板 API 中选择正确工具 | 1597 | REST-BIRD,6-328个/域 |
| Multi-Hop Reasoning | 多跳推理 | 869 | REST-BIRD |
| Doc Retrieval + API | 文档检索 + API 调用混合 | 待确认 | MCP 协议 |
VAKRA vs 传统 Benchmark:
| 维度 | 传统 Benchmark(AgentBench等) | VAKRA |
|---|---|---|
| 环境 | 模拟/离线评测 | 真实可执行环境 |
| API | 静态测试用例 | 8000+ 真实 API |
| 数据 | 人工构造 | 真实数据库 |
| 执行 | 不可执行 | MCP 协议真实调用 |
| 评测方式 | 最终答案匹配 | 完整执行轨迹验证 |
VAKRA 的 MCP 架构亮点:
# VAKRA 使用 MCP 协议连接 API
# get_data(tool_universe_id) 初始化数据源
# 避免大量数据通过 MCP 传输
# API 选择限制:OpenAI API 最多 128 个工具
# VAKRA 提供 tool shortlisting 机制处理这个问题关键洞察:模型在 VAKRA 上表现很差
"Unlike traditional benchmarks that test isolated skills, VAKRA measures compositional reasoning across APIs and documents... models perform poorly on VAKRA"
这说明:
- 即使是 GPT-4,在真实企业 API 场景下也表现不佳
- API Agent 的评测需要真实执行环境,而非静态测试
- 2026 年企业级 Agent 岗位面试,VAKRA 代表了"真实能力评估"的新方向
面试话术:
"VAKRA 是 2026年4月 IBM Research 发布的企业级 Agent 评测基准,和传统 Benchmark 的本质区别是'真实可执行'——8000+ 真实 API、真实数据库、MCP 协议调用,不是静态测试用例。四个任务覆盖 API 链式调用、工具选择、多跳推理、文档+API 混合。关键洞察是'模型在 VAKRA 上表现很差',这告诉我们:即使 GPT-4 在简单场景下很强,在真实企业 API 环境里也远未达到可靠水平。面试时能说出 VAKRA 的特点,说明你对 Agent 评测有实战理解,不只是纸上谈兵。"