Token导航 LogoToken导航TokenDH.com
Agent Benchmark logo
浏览器工具未说明官方级别未说明来源级核验

Agent Benchmark

MCP Server

agent-benchmark是一个基于Model Context Protocol (MCP)的AI代理测试框架,支持多LLM提供商的系统化测试、验证和基准测试。

工具数

0

提示词数

0

GitHub Stars

8

资源数

0
HTMLClaude自动化测试ClaudeCursorVS Code

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

作者 / 组织

mykhaliev

提供方

mykhaliev

最后核验

2026/5/17 20:20

快速接入

先看主来源和安装命令,再打开仓库或文档;下面只保留这个条目的关键接入事实。

详细介绍

代理基准文档

代理基准 是一个基于模型上下文协议(MCP)的AI代理综合测试框架。它能够通过强大的断言功能对不同LLM提供商的AI代理进行系统测试、验证和基准测试。

______________________________________________________________________

目录

  1. 概述
  2. 主要特点
  3. 安装
  4. 命令行参考
  5. 测试生成
  6. 探索性测试
  7. 配置
  8. 测试/套件定义
  9. 断言
  10. 模板系统
  11. 数据提取
  12. 报告
  13. 用法示例
  14. 最佳实践
  15. 故障排除
  16. CI/CD集成
  17. 架构说明
  18. 贡献

______________________________________________________________________

概述

代理基准测试提供了一种基于YAML的声明性方法来测试与MCP服务器交互的AI代理。它支持多个LLM提供者、各种MCP服务器类型和全面的断言机制来验证代理行为。

______________________________________________________________________

主要特点

1.多提供商支持

并行测试不同LLM提供商的代理:

  • 谷歌人工智能 (双子模型)
  • 顶点AI (谷歌云双子座)
  • Anthropic → 安thropic(音译)或 人类中心(意译) (克劳德模型)
  • 开放人工智能 (GPT型号)
  • Azure OpenAI
  • 格罗克

2.MCP服务器集成

通过以下方式连接到MCP服务器:

  • 标准:将MCP服务器作为本地进程运行
  • 上海证券交易所:通过服务器发送事件连接到远程MCP服务器
  • 命令行界面:将命令行工具包装为类似MCP的服务器,用于测试基于CLI的工具

3.基于会话的测试

将测试组织成具有共享上下文和消息历史的会话,模拟真实的会话流。

4.测试套件支持

使用集中配置、共享变量和统一的成功标准运行多个测试文件。

5.丰富的断言库

使用20多种断言类型验证代理行为,包括:

  • 工具使用模式
  • 输出验证
  • 性能指标
  • 用于复杂逻辑的布尔组合子(anyOf、allOf、not)

6.模板引擎

使用Handlebars样式模板生成动态测试,支持:

  • 随机数据生成
  • 时间戳操作
  • Faker集成
  • 字符串操作

7.数据提取

使用JSONPath从工具结果中提取数据,以便在会话中的测试之间传递。

8.综合报告

生成多种格式的报告:

  • 带有颜色编码结果的控制台输出
  • 带有性能比较的HTML报告
  • JSON导出
  • Markdown文档

9.代理技能支持

按照以下步骤加载特定领域的知识 agentskills.io规范:

  • 解析 SKILL.md 带有YAML frontmatter的文件
  • 逐步披露参考文件
  • 模板变量 {{SKILL_DIR}} 技能路径

______________________________________________________________________

安装

快速安装(推荐)

使用单个命令安装最新版本:

Linux/macOS:

curl -fsSL https://raw.githubusercontent.com/mykhaliev/agent-benchmark/master/install.sh | bash

Windows(PowerShell):

irm https://raw.githubusercontent.com/mykhaliev/agent-benchmark/master/install.ps1 | iex

替代安装方法

Minimal Install (60-70% smaller download)

对于较慢的连接或节省带宽,请使用UPX压缩版本:

curl -fsSL https://raw.githubusercontent.com/mykhaliev/agent-benchmark/master/install-min.sh | bash

注: 最低版本可能会在某些系统上触发防病毒警告,因为安全软件有时会标记UPX压缩。

Manual Installation from Pre-built Binaries

从以下网址下载适用于您系统的文件 发布页面:

常规版本(推荐):

  • Linux(AMD64): agent-benchmark_vX.X.X_linux_amd64.tar.gz
  • Linux(ARM64): agent-benchmark_vX.X.X_linux_arm64.tar.gz
  • macOS(英特尔): agent-benchmark_vX.X.X_darwin_amd64.tar.gz
  • macOS(苹果硅): agent-benchmark_vX.X.X_darwin_arm64.tar.gz
  • Windows(AMD64): agent-benchmark_vX.X.X_windows_amd64.zip
  • Windows(ARM64): agent-benchmark_vX.X.X_windows_arm64.zip

UPX压缩(尺寸较小,不适用于Windows ARM64):

  • Linux(AMD64): agent-benchmark_vX.X.X_linux_amd64_upx.tar.gz
  • Linux(ARM64): agent-benchmark_vX.X.X_linux_arm64_upx.tar.gz
  • macOS(英特尔): agent-benchmark_vX.X.X_darwin_amd64_upx.tar.gz
  • macOS(苹果硅): agent-benchmark_vX.X.X_darwin_arm64_upx.tar.gz
  • Windows(AMD64): agent-benchmark_vX.X.X_windows_amd64_upx.zip

提取并移动到您的PATH:

# Linux/macOS
tar -xzf agent-benchmark_*.tar.gz
sudo mv agent-benchmark /usr/local/bin/

# Windows
# Extract the ZIP file and add the binary to your PATH

Build from Source

要求:达到1.25或更高

Linux/macOS:

# Clone the repository
git clone https://github.com/mykhaliev/agent-benchmark
cd agent-benchmark

# Build the binary
go build -o agent-benchmark

# (Optional) Move to your PATH
sudo mv agent-benchmark /usr/local/bin/

Windows(PowerShell):

# Clone the repository
git clone https://github.com/mykhaliev/agent-benchmark
cd agent-benchmark

# Build the binary
.\build.ps1
# or
go build -o agent-benchmark.exe

验证安装

安装后,验证其是否正常工作:

agent-benchmark -v

人工智能助理技能(可选)

在VS Code、Cursor或其他编辑器中编写测试配置时,获得AI支持的帮助 代理技能 支持。

下载 agent-benchmark-skills_*.zip发布 并提取:

Linux/macOS:

unzip agent-benchmark-skills_*.zip -d ~/.copilot/skills/

Windows(PowerShell):

Expand-Archive agent-benchmark-skills_*.zip -DestinationPath $env:USERPROFILE\.copilot\skills\

安装后,您的AI助手将具有以下领域的知识:

  • 提供商配置(Azure、OpenAI、Anthropic、Google、Vertex AI、Groq)
  • 所有20多种断言类型及其示例
  • 模板助手(faker、randomValue、now等)
  • 编写可靠测试配置的最佳实践

技能/README.md 了解更多详情。

快速开始

运行第一个基准测试:

agent-benchmark -f tests.yaml -o report.html -verbose

______________________________________________________________________

命令行参考

agent-benchmark [options]

Required (one of):
  -f          Path to test configuration file (YAML)
  -s          Path to suite configuration file (YAML)
  -g          Path to generator config file (enables test generation mode)
  -e          Path to explorer config file (enables exploratory testing mode)
  -generate-report   Generate HTML report from existing JSON results file
                           (reads test_file from JSON to load AI summary config)

Generator options (require -g):
  --dry-run           Preview generated YAML without saving
  --output-dir   Directory for generated test files (default: ./generated_tests)
  --seed         Random seed for deterministic generation

Explorer options (require -e):
  (none currently — all settings live in the explorer: YAML block)

Optional:
  -o          Output report path/filename without extension
                      Default: /test_results/report
                      The test_results folder is auto-created and git-ignored
  -l          Log file path (default: stdout)
  -reportType  Report format(s): html, json, md (default: html)
                      Multiple formats supported as comma-separated values
                      Examples: -reportType html
                                -reportType html,json
                                -reportType html,json,md
  -verbose          Enable verbose logging
  -v                Show version and exit

示例:

# Run single test file with verbose output
# Reports saved to: examples/test_results/report.html
./agent-benchmark -f examples/tests.yaml -verbose

# Run test suite with JSON report (custom output path)
./agent-benchmark -s suite.yaml -o ./my-reports/results -reportType json

# Run with custom log file
./agent-benchmark -f tests.yaml -l test-run.log

# Generate Markdown report
./agent-benchmark -f tests.yaml -o report -reportType md

# Generate HTML report from existing JSON results (fast iteration)
# Reads test_file from JSON to load AI summary configuration
./agent-benchmark -generate-report results.json -o new-report

# Generate both JSON and HTML reports (for later regeneration)
./agent-benchmark -f tests.yaml -o results -reportType json,html

______________________________________________________________________

测试生成

使用 -g 标志,用于从生成器配置自动生成准备运行的测试套件。 生成器连接到MCP服务器,发现工具模式,并使用LLM生成 带有类型化断言的测试会话——无需进行测试编写。

# Preview generated YAML without saving anything
./agent-benchmark -g examples/generator-config.yaml --dry-run

# Generate and save to a timestamped directory under ./generated_tests/
./agent-benchmark -g examples/generator-config.yaml

# Custom output directory and deterministic seed
./agent-benchmark -g gen.yaml --output-dir ./tests --seed 42

一代人是如何工作的

发电机运行三个顺序阶段:

第一阶段——计划 一个专注的LLM调用会生成一个紧凑的JSON测试计划:会话名称、测试名称、预期工具, 以及高级断言思想。在移动之前,根据实际工具清单验证该计划 如果验证失败,则重新生成计划(最多 max_retries 时间)。

第二阶段——意图 对于计划中的每个测试,单独的LLM调用都会生成 TestIntent:一个扁平的JSON对象 提示、类型化断言检查和可选的JSONPath提取器。意图得到验证 (正确的断言类型,真实的工具名称,没有正向变量引用)。如果验证失败, 进行一次自动修复尝试;如果这也失败了,生成器将重试完整意图 一代。只有当一切都失败时,才是真正的失败 max_retries 筋疲力尽。

第3阶段——建造 经过验证的意图被确定性地组装成 model.Session 结构和 序列化为YAML。在此阶段,不再进行LLM调用。

输出结构

每次运行都会写入以下带时间戳的子目录 --output-dir (默认值 ./generated_tests):

generated_tests/
└── generated_20260301_120000/
    ├── suite.yaml          ← run this with: agent-benchmark -s
    ├── file-operations.yaml
    └── error-handling.yaml

suite.yaml 引用每个会话文件,并预先填充原始提供者, 生成器配置中的服务器、代理和变量——因此输出可以立即运行:

./agent-benchmark -s generated_tests/generated_20260301_120000/suite.yaml

发电机配置参考

generator: 块控制生成行为:

字段描述默认值
agentLLM用于生成的代理第一个代理
test_count所有会话中要生成的测试数量5
complexitysimplemediumcomplex (见下文)medium
include_edge_cases包括误差/边界条件测试false
max_steps_per_test每次测试预期的最大工具调用步骤5
max_retries放弃前每个阶段的最大LLM尝试次数3
max_tokens如果累积LLM令牌超过此限制(0=无限制),则停止0
max_iterations每代呼叫的最大LLM会话次数引擎默认值
plan_chunk_size每个计划块的最大测试数(0=使用默认值5)5
plan_chunk_max_tokens每个计划块LLM调用的最大输出令牌数(0=自动)自动
tools要测试的工具名称允许列表(空=所有工具)所有工具
goal在生成提示符中注入额外指令--

复杂性级别:

级别行为
simple每次测试一次工具调用;直截了当的提示
medium一到三次工具调用;可以链接工具结果
complex多步骤工作流程;使用 anyOf/allOf 断言组合子

examples/generator-config.yaml 对于一个完全注释的示例。

______________________________________________________________________

探索性测试

使用 -e 标记以运行自主探索会话。探险家LLM 迭代地决定下一步运行什么测试,对配置的测试执行它 代理,观察结果,并计划下一次迭代——所有这些都没有 预定义的测试用例。

# Run an exploration session with default HTML report
./agent-benchmark -e examples/explorer-config.yaml

# With verbose logging and custom report path
./agent-benchmark -e explorer.yaml -o ./reports/explore -reportType html,json -verbose

explorer: 配置中的块控制行为:

字段描述默认值
goal探险家试图测试什么(必填)--
max_iterations最大测试迭代次数10
stop_on_pass_count连续N次通过后停止(0=运行所有迭代)0
max_retries如果解析失败,LLM每次迭代都会重试3
max_tokens如果累计令牌超过此限制(0=无限制),则停止探索循环0
agent代理名称引用--必须与顶级中的名称匹配 agents 列表。它的提供者和服务器用于探索决策和测试执行。省略时默认为第一个代理。

勘探结果如何显示在报告中:

结果被输入到标准报告管道中,不需要新的报告格式。 勘探元数据被编码到现有的报告字段中:

元数据呈现位置
Exploration: 套房标题
Exploration Goal: 会话组标头
`[Iter NN \prompt-NNN] `测试组标题
Explorer LLM推理+决策提示对话历史(系统消息)

examples/explorer-config.yaml 对于一个完全注释的示例。

______________________________________________________________________

配置

配置文件使用YAML格式,有六个主要部分:

providers:    # LLM provider configurations
servers:      # MCP server definitions
agents:       # Agent configurations
sessions:     # Test sessions
settings:     # Global test settings
variables:    # Reusable variables

测试套件配置

该框架支持通过套件配置运行多个测试文件:

name: "Complete Test Suite"
test_files:
  - tests/basic-operations.yaml
  - tests/advanced-features.yaml
  - tests/edge-cases.yaml

providers:
  - name: gemini
    type: GOOGLE
    token: "{{GOOGLE_API_KEY}}"
    model: gemini-2.0-flash

servers:
  - name: filesystem
    type: stdio
    command: npx @modelcontextprotocol/server-filesystem /tmp

agents:
  - name: test-agent
    provider: gemini
    servers:
      - name: filesystem

settings:
  verbose: true
  max_iterations: 10
  tool_timeout: 30s
  test_delay: 2s

variables:
  base_path: "/tmp/tests"
  timestamp: "{{now format='unix'}}"

criteria:
  success_rate: "0.8"  # 80% of tests must pass

套件配置优势:

  • 集中式提供者和服务器定义
  • 所有测试文件中的共享变量
  • 统一的成功标准
  • 对多个测试文件执行单个命令

______________________________________________________________________

测试/套件定义

提供商

提供商类型:

  • GOOGLE -谷歌人工智能(双子座)
  • VERTEX -顶点AI(谷歌云双子座)
  • ANTHROPIC -人类学(克劳德)
  • OPENAI -OpenAI(GPT)
  • AZURE -Azure OpenAI
  • GROQ -Groq

为您的代理定义LLM提供商:

providers:
  - name: gemini-flash
    type: GOOGLE
    token: {{GOOGLE_API_KEY}}
    model: gemini-2.0-flash
    
  - name: claude-sonnet
    type: ANTHROPIC
    token: {{ANTHROPIC_API_KEY}}
    model: claude-sonnet-4-20250514
    
  - name: gpt-4
    type: OPENAI
    token: {{OPENAI_API_KEY}}
    model: gpt-4o-mini
    baseUrl: https://api.openai.com/v1  # Optional
    
  - name: azure-gpt
    type: AZURE
    token: {{AZURE_API_KEY}}
    model: gpt-4
    baseUrl: https://your-resource.openai.azure.com
    version: 2024-02-15-preview

  - name: azure-entra
    type: AZURE
    auth_type: entra_id  # Use Microsoft Entra ID authentication (passwordless)
    model: gpt-4
    baseUrl: https://your-resource.openai.azure.com
    version: 2024-02-15-preview

  - name: vertex-ai
    type: VERTEX
    project_id: "your-gcp-project-id"
    location: "us-central1"
    credentials_path: "/path/to/service-account.json"
    model: gemini-2.0-flash
    
  - name: gpt-4
    type: GROQ
    token: {{GROQ_API_KEY}}
    model: openai/gpt-oss-120b
    baseUrl: https://api.groq.com/openai/v1 # Optional

Azure OpenAI身份验证

AZURE提供程序支持两种身份验证方法:

API密钥身份验证(默认):

providers:
  - name: azure-apikey
    type: AZURE
    auth_type: api_key  # Optional, this is the default
    token: {{AZURE_OPENAI_API_KEY}}
    model: gpt-4
    baseUrl: https://your-resource.openai.azure.com
    version: 2024-02-15-preview

Microsoft Entra ID身份验证(无密码):

providers:
  - name: azure-entra
    type: AZURE
    auth_type: entra_id  # Uses DefaultAzureCredential
    model: gpt-4
    baseUrl: https://your-resource.openai.azure.com
    version: 2024-02-15-preview
    # No token required - uses Azure credentials from environment

Entra ID身份验证使用Azure的 DefaultAzureCredential,它会自动按顺序尝试多种身份验证方法:

  1. 环境变量: AZURE_CLIENT_ID, AZURE_TENANT_ID, AZURE_CLIENT_SECRET
  2. 工作负载标识 (适用于Kubernetes)
  3. 管理身份 (在Azure中运行时)
  4. Azure命令行界面 (az login)
  5. Azure开发者命令行界面 (azd auth login)
  6. Azure PowerShell (Connect-AzAccount)

所需RBAC角色:

您的身份必须具有 “认知服务OpenAI用户” 在Azure OpenAI资源上分配的角色(或更高)。如果没有此角色,您将收到401 Unauthorized错误。

要使用Azure CLI分配角色,请执行以下操作:

# Get your Azure OpenAI resource ID
az cognitiveservices account show \
  --name  \
  --resource-group  \
  --query id -o tsv

# Assign the required role
az role assignment create \
  --assignee  \
  --role "Cognitive Services OpenAI User" \
  --scope 
注: 角色分配可能需要5-10分钟才能传播。

有关更多信息,请参见 Azure身份验证Azure OpenAI RBAC角色.

速率限制

提供程序可以配置速率限制,以主动限制请求并避免超过API配额:

providers:
  - name: azure-gpt
    type: AZURE
    token: {{AZURE_API_KEY}}
    model: gpt-4
    baseUrl: https://your-resource.openai.azure.com
    version: 2024-02-15-preview
    rate_limits:
      tpm: 30000               # Tokens per minute limit (proactive throttling)
      rpm: 60                  # Requests per minute limit (proactive throttling)
    retry:
      retry_on_429: true       # Enable retry on 429 errors (default: false)
      max_retries: 3           # Max retry attempts (default: 3 when enabled)

配置选项:

选项描述默认值
rate_limits.tpm每分钟最大令牌数无限制
rate_limits.rpm每分钟最大请求数无限制
retry.retry_on_429对429个错误启用自动重试false
retry.max_retries重试次数3(启用时)

它是如何工作的:

  • 使用令牌桶算法在发送请求之前主动限制请求
  • 使用以下方法估算代币 令牌。 对于OpenAI模型
  • 回落到 cl100k_base 非OpenAI模型(Claude、Gemini、Llama等)的编码
  • 运行时校准根据实际API响应调整估计值
  • 429重试处理在估计值不足时提供安全网

最佳实践: 启用两者 rate_limits (主动)和 retry_on_429 (反应性)用于纵深防御。

重要提示: 限速是最好的努力,不是保证。令牌估计因提供商而异。 有关详细的技术信息,请参阅 docs/费率限制.md.

______________________________________________________________________

服务器

配置代理将与之交互的MCP服务器:

本地/标准服务器

servers:
  - name: filesystem-server
    type: stdio
    command: npx @modelcontextprotocol/server-filesystem /tmp

SSE服务器

servers:
  - name: remote-api
    type: sse
    url: https://api.example.com/mcp/events
    headers:
      - "Authorization: Bearer {{API_TOKEN}}"
      - "X-Custom-Header: value"

服务器类型:

  • stdio -标准输入/输出通信
  • sse -服务器通过HTTP发送事件
  • cli -CLI工具包装器(请参见 CLI服务器 在......下面

CLI服务器

将命令行工具包装为类似MCP的服务器。适用于测试基于CLI的工具:

servers:
  - name: excel-cli
    type: cli
    command: excel-cli
    shell: powershell      # Shell: powershell, pwsh, cmd, bash, sh, zsh
    working_dir: "{{TEST_DIR}}"  # Working directory for CLI commands
    tool_prefix: excel     # Tool name becomes excel_execute
    help_commands:         # Help content for LLM context
      - "excel-cli --help"
选项描述默认值
command要包装的CLI可执行文件(必需)-
shell在中运行命令的Shellpowershell (Windows), bash (Unix)
working_dir命令工作目录当前目录
tool_prefix生成的工具名称的前缀cli (工具名称: cli_execute)
help_commandsCLI帮助启动时运行的命令-

主要特点:

  • 自动发现: 自动从中发现子命令 COMMANDS: 帮助输出中的部分
  • 帮助内容注入: CLI帮助包含在LLM上下文的工具描述中
  • CLI特定断言: cli_exit_code_equals, cli_stdout_contains, cli_stdout_regex, cli_stderr_contains

📖 完整的CLI服务器文档 -完整的指南,包括示例、最佳实践和故障排除

服务器定时配置

控制服务器初始化和进程延迟:

servers:
  - name: slow-server
    type: stdio
    command: python server.py
    server_delay: 45s      # Wait up to 45s for initialization
    process_delay: 1s      # Wait 1s after process starts

延迟参数:

  • server_delay -等待服务器初始化的最长时间(默认值:30秒)
  • process_delay -初始化前启动过程后的延迟(默认值:300ms)

带身份验证的SSE服务器

servers:
  - name: authenticated-api
    type: sse
    url: https://api.example.com/mcp/sse
    headers:
      - "Authorization: Bearer {{API_TOKEN}}"
      - "X-API-Version: 2024-01"
      - "X-Client-ID: agent-benchmark"

______________________________________________________________________

代理

定义将提供者与MCP服务器相结合的代理:

agents:
  - name: research-agent
    provider: gemini-flash
    system_prompt: |
      You are an autonomous research agent.
      Execute tasks directly without asking for clarification.
      Use available tools to complete the requested tasks.
    servers:
      - name: filesystem-server
        allowedTools:  # Optional: restrict tool access
          - read_file
          - list_directory
      - name: remote-api
        
  - name: coding-agent
    provider: claude-sonnet
    servers:
      - name: filesystem-server  # No tool restrictions

代理配置:

  • name -唯一代理标识符
  • provider -引用提供者名称
  • skill -要加载的可选代理技能(请参阅 代理技能 部分)
  • system_prompt -所有对话前都会添加可选的系统提示(支持模板)
  • servers -MCP服务器列表
  • allowedTools -每台服务器的可选工具白名单

系统提示模板:

system_prompt 字段支持动态上下文的模板变量:

  • {{AGENT_NAME}} -当前代理名称
  • {{SESSION_NAME}} -当前会话名称
  • {{PROVIDER_NAME}} -正在使用的提供商名称

例子:

agents:
  - name: test-agent
    provider: gemini-flash
    system_prompt: |
      You are {{AGENT_NAME}} using {{PROVIDER_NAME}}.
      Currently running session: {{SESSION_NAME}}.
      Execute all tasks autonomously.

______________________________________________________________________

会话

将测试组织成具有共享会话上下文的会话:

sessions:
  - name: File Operations
    tests:
      - name: Create a file
        prompt: "Create a file called {{filename}} with content: Hello World"
        assertions:
          - type: tool_called
            tool: write_file
            
      - name: Read the file
        prompt: "Read the file {{filename}}"
        assertions:
          - type: tool_called
            tool: read_file
          - type: output_contains
            value: "Hello World"

会话功能:

  • 会话共享消息历史记录中的测试
  • 变量在会话中的测试中持续存在
  • 模拟多回合对话

______________________________________________________________________

代理技能

代理技能为代理提供特定领域的知识,遵循以下步骤 agentskills.io规范。技能从包含以下内容的目录中加载 SKILL.md 文件,它们的内容被注入到代理的系统提示符中。

agents:
  - name: skilled-agent
    provider: azure-openai
    skill:
      path: "./skills/my-skill"  # Path to skill directory
    system_prompt: |
      Additional instructions here...

如果技能有 references/ 目录,内置工具(list_skill_references, read_skill_reference)自动添加以供按需访问。

有关完整文档,请参阅 docs/agent-skills.md.

______________________________________________________________________

设置

测试执行的全局配置:

settings:
  verbose: true                 # Enable detailed logging
  max_iterations: 10            # Maximum agent reasoning loops
  timeout: 30s                  # Tool execution timeout (legacy, use tool_timeout)
  tool_timeout: 30s             # Tool execution timeout
  test_delay: 2s                # Delay between tests
  session_delay: 30s            # Delay between sessions (for COM cleanup, resource release)
  variable_policy: suite_only   # Controls are combined (test-only, suite-only, merge-test-priority, merge-suite-priority)

______________________________________________________________________

可变策略

当作为测试的一部分运行测试时 测试套件,变量可以在两者上定义 这 套房级别 和那个 测试级别.

variable_policy 设置控制如何解析这些变量。

可用策略

政策说明
suite-only *(默认)*仅使用套件级别的变量。测试级别变量被忽略。
test-only仅使用测试级变量。套件级别变量被忽略。
merge-test-priority套件和测试变量被合并。测试变量在键冲突时覆盖套件变量。
merge-suite-priority套件和测试变量被合并。套件变量在密钥冲突时覆盖测试变量。

如果 variable_policy 未设置或具有未知值,默认为 suite-only.

______________________________________________________________________

变量

使用模板支持定义可重用变量:

variables:
  filename: "test-{{randomValue type='ALPHANUMERIC' length=8}}.txt"
  timestamp: "{{now format='unix'}}"
  user_id: "{{randomInt lower=1000 upper=9999}}"
  email: "{{faker 'Internet.email'}}"

变量可以:

  • 使用模板助手
  • 参考环境变量

______________________________________________________________________

测试时间控制

启动延迟

延迟单个测试执行:

tests:
  - name: Rate-limited API call
    prompt: "Make API request"
    start_delay: 5s  # Wait 5 seconds before starting
    assertions:
      - type: tool_called
        tool: api_request

全局测试延迟

在所有测试之间暂停:

settings:
  test_delay: 2s  # 2 second pause after each test

使用案例:

  • 遵守API费率限制
  • 允许系统状态稳定
  • 防止资源枯竭

会话延迟

在会话之间暂停以允许资源清理:

settings:
  session_delay: 30s  # 30 second pause between sessions

使用案例:

  • 允许外部应用程序和资源在会话之间完全释放
  • 在测试与有状态应用程序交互时防止资源争用
  • 避免前几次会议遗留的流程影响新的会议
  • 让MCP服务器有时间在会话之间干净地关闭

______________________________________________________________________

测试标准和退出代码

定义测试套件的最低成功率:

criteria:
  success_rate: 0.75  # 75% pass rate required

退出代码行为:

场景退出代码
所有测试均已通过/达到成功率0
某些测试失败/未达到成功率1

______________________________________________________________________

环境变量

配置中的参考环境变量:

providers:
  - name: claude
    type: ANTHROPIC
    token: "{{ANTHROPIC_API_KEY}}"
    model: claude-sonnet-4-20250514

servers:
  - name: api-server
    type: sse
    url: "{{API_BASE_URL}}"
    headers:
      - "Authorization: Bearer {{API_TOKEN}}"

variables:
  workspace: "{{WORKSPACE_PATH}}"

公约:

  • 使用 {{VAR_NAME}} 语法
  • 运行测试前设置
  • 常见于令牌、URL、路径
export ANTHROPIC_API_KEY="sk-ant-..."
export API_BASE_URL="https://api.example.com"
export WORKSPACE_PATH="/tmp/workspace"

./agent-benchmark -f tests.yaml

______________________________________________________________________

内置模板变量

该框架提供了在模板上下文中自动可用的内置变量。变量根据其可用时间分为两类:

变量类别

类别可用描述
静态无处不在(提供者、服务器、变量、提示、断言)在配置加载时可用
运行时提示、断言、系统提示仅在测试执行期间可用

静态变量(随处可用)

这些变量可用于服务器命令、提供程序配置、用户变量、提示和断言:

变量描述
{{TEST_DIR}}包含测试YAML文件的目录的绝对路径
{{TEMP_DIR}}系统临时目录(跨平台: %TEMP% 在Windows上, /tmp 在Linux/macOS上)
{{RUN_ID}}此测试运行的唯一UUID v4(例如。, 550e8400-e29b-41d4-a716-446655440000)
{{ANY_ENV_VAR}}任何环境变量(例如。, {{HOME}}, {{AZURE_OPENAI_ENDPOINT}})
用户定义变量中定义的变量 variables: 配置的一部分

运行时变量(在测试执行期间可用)

这些变量仅在提示、断言和系统提示中可用,而在服务器命令或提供程序配置中不可用:

变量描述
{{AGENT_NAME}}当前代理名称
{{SESSION_NAME}}当前会话名称
{{PROVIDER_NAME}}正在使用的提供商名称

将TEST_DIR用于可移植路径:

{{TEST_DIR}} 启用无论存储库克隆到何处都能正常工作的测试配置:

variables:
  # Paths relative to the test file location
  data_dir: "{{TEST_DIR}}/test-data"
  output_dir: "{{TEST_DIR}}/../TestResults"
  mcp_server: "{{TEST_DIR}}/bin/my-server.exe"

servers:
  - name: filesystem
    type: stdio
    command: npx @modelcontextprotocol/server-filesystem {{output_dir}}

  - name: custom-server
    type: stdio
    command: "{{mcp_server}}"

sessions:
  - name: File Tests
    tests:
      - name: Process test data
        prompt: "Read files from {{data_dir}} and save results to {{output_dir}}"

______________________________________________________________________

断言

代理基准测试提供了20多种断言类型来验证代理行为:

工具断言

无幻觉工具

验证代理仅使用可用工具:

assertions:
  - type: no_hallucinated_tools

工具调用

验证是否调用了特定工具:

assertions:
  - type: tool_called
    tool: create_file

工具未调用

确保未调用工具:

assertions:
  - type: tool_not_called
    tool: delete_database

tool_call_count

验证工具调用的确切次数。工具名称是可选的;如果未指定,则将验证所有工具调用的次数:

assertions:
  - type: tool_call_count
    tool: search_api
    count: 3

tool_call_order

验证工具是否按特定顺序调用:

assertions:
  - type: tool_call_order
    sequence:
      - validate_input
      - process_data
      - save_results

tool_param_equals

检查刀具参数是否完全匹配:

assertions:
  - type: tool_param_equals
    tool: create_user
    params:
      name: "John Doe"
      age: 30
      email: "john@example.com"
      settings.theme: "dark"  # Nested parameter with dot notation

嵌套参数验证:

对嵌套参数使用点符号:

assertions:
  - type: tool_param_equals
    tool: create_resource
    params:
      name: "test-resource"
      config.timeout: "30"
      config.retry.max_attempts: "3"
      config.retry.backoff: "exponential"
      metadata.tags.environment: "production"

点符号规则:

  • 使用点导航嵌套地图
  • 验证深度嵌套值
  • 比较任何深度的精确匹配

tool_param_matches_regex

使用正则表达式模式验证参数:

assertions:
  - type: tool_param_matches_regex
    tool: send_email
    params:
      recipient: "^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,}$"

tool_result_matches_json

使用JSONPath验证工具结果:

assertions:
  - type: tool_result_matches_json
    tool: get_user
    path: "$.data.user.name"
    value: "John Doe"

______________________________________________________________________

输出断言

输出内容

检查输出是否包含特定文本:

assertions:
  - type: output_contains
    value: "Operation completed successfully"

输出_非内容

确保输出不包含特定文本:

assertions:
  - type: output_not_contains
    value: "error"

output_regex

使用正则表达式模式验证输出:

assertions:
  - type: output_regex
    pattern: "^User ID: [0-9]{4,}$"

______________________________________________________________________

性能断言

max_tokens

限制近似令牌使用:

assertions:
  - type: max_tokens
    value: 1000

代币估算:

OpenAI、Google和Anthropic模型的代币使用情况来自GenerationInfo 对于其他型号,公式为:

tokens = output_length / 4

该近似值:

  • 提供粗略的令牌计数
  • 适用于max_tokens断言
  • 不准确(因标记器而异)

max_latency_ms

确保在规定时间内完成执行:

assertions:
  - type: max_latency_ms
    value: 5000  # 5 seconds

______________________________________________________________________

错误断言

无错误消息

验证执行已完成且无错误:

assertions:
  - type: no_error_messages

无速率限制错误

验证测试没有遇到任何HTTP 429速率限制错误:

assertions:
  - type: no_rate_limit_errors

此断言检查提供程序在执行过程中是否返回了任何429错误。它适用于:

  • 确保测试保持在API配额范围内
  • 验证速率限制配置是否足够
  • 检测何时需要节流

______________________________________________________________________

行为断言

无澄清_问题

直接验证代理执行的任务,而不要求澄清。需要 clarification_detection 要在代理上启用:

assertions:
  - type: no_clarification_questions

______________________________________________________________________

布尔组合器

布尔组合子允许您使用JSON模式风格的运算符创建复杂的断言逻辑。当LLM可以通过不同的方法实现相同的结果时,这些是有用的。

任一

通过如果 任何 子断言通过(OR逻辑):

assertions:
  # Pass if the LLM used keyboard_control OR ui_automation
  - anyOf:
      - type: tool_called
        tool: keyboard_control
      - type: tool_called
        tool: ui_automation

全部

通过如果 全部 子断言通过(AND逻辑):

assertions:
  # Pass if both conditions are met
  - allOf:
      - type: tool_called
        tool: create_file
      - type: output_contains
        value: "File created successfully"

如果儿童断言通过 失败 (否定):

assertions:
  # Pass if output does NOT contain "error" (equivalent to output_not_contains)
  - not:
      type: output_contains
      value: "error"

嵌套组合器

组合器可以嵌套复杂的逻辑:

assertions:
  # Pass if: (keyboard OR ui_automation) AND no errors
  - allOf:
      - anyOf:
          - type: tool_called
            tool: keyboard_control
          - type: tool_called
            tool: ui_automation
      - type: no_error_messages
  
  # Pass if NOT (error in output AND failed tool)
  - not:
      allOf:
        - type: output_contains
          value: "error"
        - type: tool_not_called
          tool: success_handler

使用案例:

  • 测试可能使用不同工具实现相同目标的LLM
  • 验证是否出现了几个可接受的结果中的至少一个
  • 创建排除规则(不得与模式匹配)
  • 复杂的条件验证逻辑

______________________________________________________________________

模板系统

agent基准测试包括一个基于Handlebars的强大模板引擎,带有自定义助手:

随机值生成

随机值

生成随机字符串:

# Alphanumeric (default)
{{randomValue length=10}}
# Output: aB3xY9kL2m

# Alphabetic only
{{randomValue type='ALPHABETIC' length=8}}
# Output: AbCdEfGh

# Numeric only
{{randomValue type='NUMERIC' length=6}}
# Output: 123456

# Hexadecimal
{{randomValue type='HEXADECIMAL' length=8}}
# Output: 1a2b3c4d

# Alphanumeric with symbols
{{randomValue type='ALPHANUMERIC_AND_SYMBOLS' length=12}}
# Output: aB3@xY9!kL2#

# UUID
{{randomValue type='UUID'}}
# Output: 550e8400-e29b-41d4-a716-446655440000

# Uppercase
{{randomValue type='ALPHABETIC' length=8 uppercase=true}}
# Output: ABCDEFGH

类型:

  • ALPHANUMERIC (默认)-字母和数字
  • ALPHABETIC -仅限信件
  • NUMERIC -仅限数字
  • HEXADECIMAL -十六进制字符(0-9,a-f)
  • ALPHANUMERIC_AND_SYMBOLS -字母、数字和符号
  • UUID -UUID v4

randomInt 的

生成随机整数:

# Random int between 0 and 100 (default)
{{randomInt}}

# Custom range
{{randomInt lower=1000 upper=9999}}
# Output: 5847

# Negative range
{{randomInt lower=-100 upper=100}}

随机十进制

生成随机十进制数:

# Random decimal between 0.00 and 100.00 (default)
{{randomDecimal}}

# Custom range
{{randomDecimal lower=10.5 upper=99.9}}
# Output: 45.73

______________________________________________________________________

时间戳助手

现在

生成具有格式和偏移的时间戳:

# Current ISO8601 timestamp (default)
{{now}}
# Output: 2024-01-15T14:30:00Z

# Unix epoch (milliseconds)
{{now format='epoch'}}
# Output: 1705329000000

# Unix timestamp (seconds)
{{now format='unix'}}
# Output: 1705329000

# Custom format (Java SimpleDateFormat style)
{{now format='yyyy-MM-dd HH:mm:ss'}}
# Output: 2024-01-15 14:30:00

# With timezone
{{now timezone='America/New_York'}}

# With offset
{{now offset='3 days'}}
{{now offset='-24 hours'}}
{{now offset='1 years'}}

# Combined
{{now format='yyyy-MM-dd' offset='7 days' timezone='UTC'}}

偏移单位:

  • seconds / second
  • minutes / minute
  • hours / hour
  • days / day
  • weeks / week
  • months / month
  • years / year

______________________________________________________________________

Faker集成

伪造者

生成真实的假数据:

# Names
{{faker 'Name.first_name'}}      # John
{{faker 'Name.last_name'}}       # Smith
{{faker 'Name.full_name'}}       # John Smith
{{faker 'Name.prefix'}}          # Mr.
{{faker 'Name.suffix'}}          # Jr.

# Addresses
{{faker 'Address.street'}}       # 123 Main St
{{faker 'Address.city'}}         # New York
{{faker 'Address.state'}}        # California
{{faker 'Address.state_abbrev'}} # CA
{{faker 'Address.country'}}      # United States
{{faker 'Address.postcode'}}     # 12345

# Phone
{{faker 'Phone.number'}}         # 555-1234
{{faker 'Phone.number_formatted'}} # (555) 123-4567

# Internet
{{faker 'Internet.email'}}       # john@example.com
{{faker 'Internet.username'}}    # john_doe_123
{{faker 'Internet.url'}}         # https://example.com
{{faker 'Internet.ipv4'}}        # 192.168.1.1
{{faker 'Internet.ipv6'}}        # 2001:0db8:85a3::8a2e:0370:7334
{{faker 'Internet.mac'}}         # 00:1B:44:11:3A:B7

# Company
{{faker 'Company.name'}}         # Tech Corp
{{faker 'Company.suffix'}}       # Inc.
{{faker 'Company.profession'}}   # Software Engineer

# Lorem
{{faker 'Lorem.word'}}           # ipsum
{{faker 'Lorem.sentence'}}       # Lorem ipsum dolor sit amet
{{faker 'Lorem.paragraph'}}      # Full paragraph text

# Finance
{{faker 'Finance.credit_card'}}  # 4532-1234-5678-9010
{{faker 'Finance.currency'}}     # USD

# Misc
{{faker 'Misc.uuid'}}            # 550e8400-e29b-41d4-a716-446655440000
{{faker 'Misc.boolean'}}         # true/false
{{faker 'Misc.date'}}            # 2024-01-15
{{faker 'Misc.time'}}            # 14:30:00
{{faker 'Misc.timestamp'}}       # 1705329000
{{faker 'Misc.digit'}}           # 7

______________________________________________________________________

字符串操作

删除子字符串:

{{cut "Hello World" "World"}}
# Output: Hello 

{{cut filename ".txt"}}

替换

更换基板:

{{replace "Hello World" "World" "Universe"}}
# Output: Hello Universe

{{replace email "@example.com" "@test.com"}}

子字符串

提取子字符串:

{{substring "Hello World" start=0 end=5}}
# Output: Hello

{{substring text start=6}}
# Output: Rest of string from position 6

______________________________________________________________________

数据提取

从工具结果中提取数据以用于后续测试:

sessions:
  - name: User Workflow
    tests:
      - name: Create user
        prompt: "Create a new user"
        extractors:
          - type: jsonpath
            tool: create_user
            path: "$.data.user.id"
            variable_name: user_id
        assertions:
          - type: tool_called
            tool: create_user
      
      - name: Get user details
        prompt: "Get details for user {{user_id}}"
        assertions:
          - type: tool_called
            tool: get_user
          - type: tool_param_equals
            tool: get_user
            params:
              id: "{{user_id}}"

提取器配置:

  • type -提取方法(目前: jsonpath)
  • tool -要提取的工具名称
  • path -JSONPath表达式
  • variable_name -模板上下文的变量名称

使用案例:

  • 从创建操作中提取ID
  • 在连续测试之间传递数据
  • 验证跨操作的一致性

______________________________________________________________________

报告

代理基准生成多种格式的综合报告。您可以使用-o(自动添加扩展名)指定输出文件名,并使用逗号分隔值的-reportType同时生成多种格式。

📊 查看示例报告 -请参阅涵盖所有测试配置排列(单/多代理、单/多测试、会话、套件)的示例HTML报告。

📖 报告文件 -关于报告层次结构、部分和自适应显示的详细文档。

支持格式

  • 控制台 -执行过程中的实时彩色输出(默认,始终显示)
  • 超文本标记语言 -带有图表和指标的丰富可视化仪表板
  • JSON -用于程序分析的结构化数据
  • 标记语言 -文档友好格式
  • 实时 -在每次测试完成时逐行写入NDJSON流

例子

# Console output only (default)
agent-benchmark -f test.yaml

# Generate HTML report
agent-benchmark -f test.yaml -o my-report -reportType html

# Generate multiple formats
agent-benchmark -f test.yaml -o my-report -reportType html,json,md

# Realtime streaming report (useful for CI/CD pipelines and live dashboards)
agent-benchmark -f test.yaml -o my-report -reportType realtime

# Combine realtime with other formats
agent-benchmark -f test.yaml -o my-report -reportType html,json,realtime

实时报告

realtime 报告类型将结果流式传输到 .jsonl (JSON行)在每个测试完成时,无需等待整个套件完成。这使得外部工具能够逐步使用结果。

输出文件: .jsonl (例如。 -o my-reportmy-report.jsonl)

格式——每行一个JSON对象:

{"type":"test","data":{...full TestRun...}}
{"type":"test","data":{...full TestRun...}}
{"type":"summary","data":{"total_tests":5,"passed":4,"failed":1,"pass_rate":0.8,"total_duration_ms":12340,"generated_at":"2026-04-08T10:00:00Z"}}
END

线路类型:

描述
{"type":"test",...}每个完成的测试一行,在断言评估后立即编写。这 data 字段包含完整 TestRun:断言、时间戳、延迟、令牌计数、工具调用、错误等。
{"type":"summary",...}在所有测试完成后编写一次汇总统计数据。
END最后一行是非JSON哨兵。向解析器发出流已完成的信号。

解析器模式:

with open("my-report.jsonl") as f:
    for line in follow(f):          # tail -f style
        if line.strip() == "END":
            break                   # suite finished
        row = json.loads(line)
        if row["type"] == "test":
            process_test(row["data"])
        elif row["type"] == "summary":
            process_summary(row["data"])

控制台报告

测试执行期间显示的实时彩色输出有三个主要部分:

服务器比较摘要

  • 跨代理逐个测试比较
  • 带复选标记的通过/失败状态
  • 每个代理的持续时间
  • 供应商信息
  • 摘要统计数据(例如,“通过了2/2台服务器”)

详细测试结果

  • 每个试剂的单独测试结果
  • 所有带有通过/失败指示符的断言结果
  • 每个断言的详细指标(预期值与实际值)
  • 令牌使用和延迟信息
  • 错误详细信息(如有)

执行摘要

  • 总测试数、通过数和失败数
  • 通过率百分比
  • 工具调用总数
  • 总错误数
  • 总持续时间和平均持续时间
  • 使用的令牌总数

例子:

═══════════════════════════════════════════════════════════════
                    SERVER COMPARISON SUMMARY
═══════════════════════════════════════════════════════════════

📋 Test: Create file [100% passed]
   Summary: 2/2 servers passed

   ┌─────────────────────────────────────────────────────────────┐
   │ Server/Agent              │ Status     │ Duration          │
   ├─────────────────────────────────────────────────────────────┤
   │ gemini-agent              │ ✓ PASS     │ 2.34s            │
   │   └─ [GOOGLE]             │            │                  │
   │ claude-agent              │ ✗ FAIL     │ 3.12s            │
   │   └─ [ANTHROPIC]          │            │                  │
   └─────────────────────────────────────────────────────────────┘

═══════════════════════════════════════════════════════════════
                     DETAILED TEST RESULTS
═══════════════════════════════════════════════════════════════

📋 Test: Create file
  ✓ gemini-agent [GOOGLE] (2.34s)
    ✓ tool_called: Tool 'write_file' was called
    ✓ tool_param_equals: Tool called with correct parameters
    ✓ max_latency_ms: Latency: 2340ms (max: 5000ms)
      • actual: 2340
      • max: 5000

  ✗ claude-agent [ANTHROPIC] (3.12s)
    ✓ tool_called: Tool 'write_file' was called
    ✗ tool_param_equals: Tool called with incorrect parameters
      • expected: {"path": "test.txt", "content": "Hello"}
      • actual: {"path": "test.txt"}
    ✓ max_latency_ms: Latency: 3120ms (max: 5000ms)
      • actual: 3120
      • max: 5000

═══════════════════════════════════════════════════════════════
Total: 2 | Passed: 1 | Failed: 1
═══════════════════════════════════════════════════════════════

================================================================================
[Summary] Test Execution Summary
================================================================================
  Total Tests:      2
  Passed:           1 (50.0%)
  Failed:           1 (50.0%)
  Total Tool Calls: 2
  Total Errors:     1
  Total Duration:   5460ms (avg: 2730ms per test)
  Total Tokens:     350
================================================================================

HTML报告

丰富的视觉报告,具有以下特点:

摘要仪表板

  • 总/通过/失败测试计数
  • 颜色编码统计的总体成功率

代理性能比较

  • 按代理使用可视化指标进行统计
  • 带有百分比指标的成功率
  • 平均持续时间和延迟
  • 令牌使用情况(每次测试的总使用量和平均使用量)
  • 每个代理的通过/失败计数

服务器比较摘要

  • 跨代理的并排测试结果
  • 每次测试成功率
  • 执行时间比较
  • 失败的服务器详细信息,并显示错误消息

详细测试结果

  • 每个代理的完整执行细节
  • 具有通过/失败状态的单个断言结果
  • 性能指标(持续时间、令牌、延迟)
  • 工具调用信息和参数

HTML报告模板架构

HTML报告是由模块化、可重用的模板组件构建的。每种报告类型根据上下文(单代理与多代理、单文件与套件等)不同地组成这些构建块。

组件层级

graph TD
    subgraph "Main Layout"
        A[report.html] --> B[summary-cards]
        A --> C[comparison-matrix]
        A --> D[agent-leaderboard]
        A --> E[file-summary]
        A --> F[session-summary]
        A --> G[test-results]
        A --> H[fullscreen-overlay]
        A --> I[scripts]
    end

    subgraph "Test Results Container"
        G --> J[test-group]
    end

    subgraph "View Selection"
        J -->|"1 agent"| K[single-agent-detail]
        J -->|"2+ agents"| L[multi-agent-comparison]
    end

    subgraph "Single Agent Components"
        K --> K1[agent-assertions]
        K --> K2[agent-errors]
        K --> K3[agent-sequence-diagram]
        K --> K4[agent-tool-calls]
        K --> K5[agent-messages]
        K --> K6[agent-final-output]
    end

    subgraph "Multi-Agent Components"
        L --> L1[comparison-table]
        L --> L2[tool-comparison]
        L --> L3[errors-comparison]
        L --> L4[sequence-comparison]
        L --> L5[outputs-comparison]
    end

报告层次结构(简单→ 复杂)

报告是分层设计的,每一层都建立在前一层之上:

级别报告类型描述关键组件
1单代理,单测试最简单的情况-一个代理,一个测试总结卡,单代理详细信息
2单个代理,多个测试多个独立测试,同一代理+测试概述表
3多个代理比较同一测试中的代理+比较矩阵、代理排行榜
4多个会话按共享上下文的会话分组的测试+会话摘要
5全套多代理、多会话、多文件所有组件组合在一起

为每个级别生成示例报告:

go run test/generate_reports.go

这将在中创建分层示例报告 generated_reports/:

  • 01_single_agent_single_test.html -第一级:一个代理,一个测试
  • 02_single_agent_multi_test.html -第二级:一个代理,多个测试
  • 03_multi_agent_single_test.html -第三级:多个代理,一个测试(排行榜)
  • 04_multi_agent_multi_test.html -第四级:多个代理,多个测试(矩阵)
  • 05_single_agent_multi_session.html -第5级:一个代理,多个会话
  • 06_multi_agent_multi_session.html -级别6:多个代理,多个会话
  • 07_single_agent_multi_file.html -第7级:一个代理,多个文件
  • 08_multi_agent_multi_file.html -级别8:全套(多个代理、会话、文件)
  • 09_failed_with_errors.html -错误显示示例

报告类型及其组成部分

单一代理报告 -一个代理正在运行测试:

graph LR
    subgraph "Single Agent Report"
        A[summary-cards] --> B[test-results]
        B --> C[test-group]
        C --> D[single-agent-detail]
        D --> D1[assertions]
        D --> D2[errors]
        D --> D3[sequence-diagram]
        D --> D4[tool-calls]
        D --> D5[messages]
        D --> D6[final-output]
    end

多代理报告 -在相同测试中比较多个代理:

graph LR
    subgraph "Multi-Agent Report"
        A[summary-cards] --> B[comparison-matrix]
        B --> C[agent-leaderboard]
        C --> D[test-results]
        D --> E[test-group]
        E --> F[multi-agent-comparison]
        F --> F1[comparison-table]
        F --> F2[tool-comparison]
        F --> F3[errors-comparison]
        F --> F4[sequence-comparison]
        F --> F5[outputs-comparison]
    end

多会话报告 -按会话组织的测试:

graph LR
    subgraph "Multi-Session Report"
        A[summary-cards] --> B[session-summary]
        B --> C[test-results]
        C --> D[test-group]
        D --> E[single-agent-detail]
    end

全套报告 -带有可选多代理的多个测试文件:

graph LR
    subgraph "Full Suite Report"
        A[summary-cards] --> B[comparison-matrix]
        B --> C[agent-leaderboard]
        C --> D[file-summary]
        D --> E[test-results]
        E --> F[test-group]
        F -->|"1 agent"| G[single-agent-detail]
        F -->|"2+ agents"| H[multi-agent-comparison]
    end

模板组件参考

组件用途用于
summary-cards顶级统计数据(总计/通过/失败/令牌/持续时间)所有报告
comparison-matrix测试×代理通过/失败矩阵多代理
agent-leaderboard代理性能排名表多代理
file-summary使用统计数据对测试文件进行分组套件运行
session-summary使用流程图进行会话分组多会话
test-results所有测试组的容器所有报告
test-group单次测试,决定单视图与多视图所有报告
single-agent-detail一个代理的详细可扩展视图单个代理
multi-agent-comparison并列对照表多代理
agent-assertions断言结果列表单个代理
agent-errors显示错误消息单个代理
agent-sequence-diagram美人鱼执行流程图单代理
agent-tool-calls带有参数/结果的工具调用时间线单个代理
agent-messages对话历史单个代理
agent-final-output最终代理响应单个代理
tool-comparison并行工具调用多代理
errors-comparison并排错误多代理
sequence-comparison并排图表(点击全屏)多代理
outputs-comparison最终输出并排多代理
fullscreen-overlay放大图的模态叠加所有报告
scriptsMermaid初始化、展开/折叠、全屏JS所有报告

AI摘要(LLM生成的执行摘要)

通过添加以下内容生成AI驱动的测试结果执行摘要 ai_summary 到你的测试YAML:

ai_summary:
  enabled: true
  judge_provider: azure-gpt  # Provider name from your providers section

该分析在HTML报告中显示为“AI摘要”部分,其中包含判决、权衡分析、显著观察结果、故障模式和可操作的建议。

📖 完整的AI摘要文档

JSON报告

程序分析和CI/CD集成的结构化测试结果:

{
  "agent_benchmark_version": "1.0.0",
  "generated_at": "2024-01-15T14:30:00Z",
  "summary": {
    "total": 10,
    "passed": 8,
    "failed": 2
  },
  "comparison_summary": {
    "Test Name": {
      "testName": "Create file",
      "serverResults": {
        "gemini-agent": {
          "agentName": "gemini-agent",
          "provider": "GOOGLE",
          "passed": true,
          "duration": 2340,
          "errors": []
        },
        "claude-agent": {
          "agentName": "claude-agent",
          "provider": "ANTHROPIC",
          "passed": false,
          "duration": 3120,
          "errors": ["Tool parameter mismatch"]
        }
      },
      "totalRuns": 2,
      "passedRuns": 1,
      "failedRuns": 1
    }
  },
  "detailed_results": [
    {
      "execution": {
        "testName": "Create file",
        "agentName": "gemini-agent",
        "providerType": "GOOGLE",
        "startTime": "2024-01-15T14:30:00Z",
        "endTime": "2024-01-15T14:30:02Z",
        "tokensUsed": 150,
        "latencyMs": 2340,
        "errors": []
      },
      "assertions": [
        {
          "type": "tool_called",
          "passed": true,
          "message": "Tool 'write_file' was called"
        },
        {
          "type": "tool_param_equals",
          "passed": true,
          "message": "Tool 'write_file' called with correct parameters"
        }
      ],
      "passed": true
    }
  ]
}

关键字段

  • summary-总体测试统计
  • comparisonsummary-跨代理比较数据
  • detailed_results-带有断言的完整执行细节
  • agent_benchmark_version-所用工具的版本
  • generated_at-报告生成时间戳

Markdown报告

文档友好格式,非常适合README文件、wiki和技术文档。 主要特点

  • 清晰易读的文档格式
  • 带有比较数据的汇总表
  • 每个代理的详细断言结果
  • 易于包含在GitHub README或wiki页面中
  • 跨文档平台可移植
  • 快速视觉识别通过/失败状态

______________________________________________________________________

用法示例

示例1:基本文件操作

providers:
  - name: gemini
    type: GOOGLE
    token: ${GOOGLE_API_KEY}
    model: gemini-2.0-flash

servers:
  - name: fs
    type: stdio
    command: npx @modelcontextprotocol/server-filesystem /tmp

agents:
  - name: file-agent
    provider: gemini
    servers:
      - name: fs

settings:
  verbose: true
  max_iterations: 5

variables:
  filename: "test-{{randomValue length=8}}.txt"
  content: "{{faker 'Lorem.paragraph'}}"

sessions:
  - name: File Tests
    tests:
      - name: Create file
        prompt: "Create a file {{filename}} with content: {{content}}"
        assertions:
          - type: tool_called
            tool: write_file
          - type: file_created
            path: "/tmp/{{filename}}"
          
      - name: Read file
        prompt: "Read {{filename}}"
        assertions:
          - type: tool_called
            tool: read_file
          - type: output_contains
            value: "{{content}}"

运行:

./agent-benchmark -f file-tests.yaml -o results.html -verbose

______________________________________________________________________

示例2:API集成测试

providers:
  - name: claude
    type: ANTHROPIC
    token: ${ANTHROPIC_API_KEY}
    model: claude-sonnet-4-20250514

servers:
  - name: api-server
    type: sse
    url: https://api.example.com/mcp/events
    headers:
      - "Authorization: Bearer ${API_TOKEN}"

agents:
  - name: api-agent
    provider: claude
    servers:
      - name: api-server

settings:
  tool_timeout: 10s
  max_iterations: 8

variables:
  user_id: "{{randomInt lower=1000 upper=9999}}"
  email: "{{faker 'Internet.email'}}"
  timestamp: "{{now format='unix'}}"

sessions:
  - name: User Management
    tests:
      - name: Create user
        prompt: |
          Create a new user with:
          - ID: {{user_id}}
          - Email: {{email}}
          - Created: {{timestamp}}
        assertions:
          - type: tool_called
            tool: create_user
          - type: tool_param_equals
            tool: create_user
            params:
              id: "{{user_id}}"
              email: "{{email}}"
          - type: output_json_valid
          - type: max_latency_ms
            value: 5000
          
      - name: Fetch user
        prompt: "Get user {{user_id}}"
        assertions:
          - type: tool_called
            tool: get_user
          - type: output_matches_json
            path: "$.data.email"
            value: "{{email}}"

______________________________________________________________________

GitLab 的

test:
  stage: test
  script:
    - ./agent-benchmark -s suite.yaml -o results.json -reportType json
  artifacts:
    when: always
    paths:
      - results.json
    reports:
      junit: results.json
  variables:
    GOOGLE_API_KEY: ${GOOGLE_API_KEY}
    ANTHROPIC_API_KEY: ${ANTHROPIC_API_KEY}

______________________________________________________________________

架构说明

会话消息历史记录

在会话中,测试共享对话历史记录:

Session Start
  ├─ Test 1: "Create file" 
  │   └─ Messages: [user, assistant, tool_response]
  ├─ Test 2: "Read file"      # Has Test 1 history
  │   └─ Messages: [prev..., user, assistant, tool_response]
  └─ Test 3: "Delete file"    # Has Test 1 & 2 history
      └─ Messages: [prev..., user, assistant, tool_response]

代理推理循环

1. User sends prompt
2. Agent calls LLM with tools
3. LLM responds with:
   a) Final answer → Done
   b) Tool calls → Execute tools → Back to step 2
4. Repeat until:
   - Final answer received
   - Max iterations reached
   - Context cancelled
   - Error occurred

澄清请求检测

代理可以检测到LLM何时要求澄清而不是采取行动(例如,“你想让我……”,“我应该继续……”)。此功能使用基于LLM的语义分类来跨任何语言进行准确检测。

agents:
  - name: autonomous-agent
    provider: my-provider
    clarification_detection:
      enabled: true
      judge_provider: azure-openai-judge  # Recommend gpt-4.1 for best accuracy

有关完整文档,请参阅 文档/澄清-检测.md.

许可证

Apache 2.0许可证-有关详细信息,请参阅许可证文件

______________________________________________________________________

支持与贡献

问题: https://github.com/mykhaliev/agent-benchmark/issues

贡献:

  1. 分叉存储库
  2. 创建特征分支
  3. 提交拉取请求

目录标签

目录标签

HTMLClaude自动化测试本地部署AI测试LLM验证多提供商支持性能基准

支持客户端

ClaudeCursorVS Code

接入字段

传输方式(transport,传输协议)

未说明

鉴权方式(authType,认证方式)

token

工具数量(toolCount,工具数)

0

资源数量(resourceCount,资源数)

0

提示词数量(promptCount,提示词数)

0

权限和风险

未说明token部署方式未说明

接入前请确认传输方式、认证方式和部署位置,并根据实际工具能力限制访问范围。

安装前确认

不要直接授予不必要的文件、网络或账号权限;先核对安装命令和配置内容。

仍需确认:installCommand

来源信息

继续浏览同类 MCP