> ## Documentation Index
> Fetch the complete documentation index at: https://niceeval.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# NiceEval：面向 Agent 的评估工具

> NiceEval 帮助团队衡量、评估并改进生产环境中的 AI：比较模型、迭代 Agent、发现回归、用真实数据持续改进。

export const DirectMode = () => <div className="ne-w ne-flow">
    <div className="ne-hd">
      直连模式
      <span className="ne-hd-hint">对着前端本来就在用的那个接口收发</span>
    </div>
    <div className="ne-flow-body">
      <div className="ne-flow-plain ne-lit" style={{
  animationDelay: "0s"
}}>
        evals/*.eval.ts
      </div>

      <div className="ne-flow-edge">
        <span className="ne-flow-line ne-lit" style={{
  animationDelay: "0.6s"
}} />
        <span className="ne-flow-tip">▼</span>
      </div>

      <div className="ne-flow-node ne-lit" style={{
  animationDelay: "1.2s"
}}>
        <div className="ne-flow-name">niceeval</div>
        <div className="ne-flow-sub">发现评估用例、排期、判定、出报告</div>
      </div>

      <div className="ne-flow-edge">
        <span className="ne-flow-line ne-lit" style={{
  animationDelay: "1.8s"
}} />
        <span className="ne-flow-edge-text">Agent 适配器（官方，或者自己实现）</span>
        <span className="ne-flow-line ne-lit" style={{
  animationDelay: "2.1s"
}} />
        <span className="ne-flow-tip">▼</span>
      </div>

      <div className="ne-flow-node ne-lit" style={{
  animationDelay: "2.4s"
}}>
        <div className="ne-flow-name">你自己的 AI Agent</div>
        <div className="ne-flow-sub">AI SDK · LangGraph · Pi · 自研 agent loop 等</div>
      </div>
    </div>
    <div className="ne-ft">不需要 Docker，应用代码一行不改。</div>
  </div>;

export const SandboxMode = () => <div className="ne-w ne-flow">
    <div className="ne-hd">
      Sandbox 模式
      <span className="ne-hd-hint">被测对象需要一个能改文件、跑命令的工作区</span>
    </div>
    <div className="ne-flow-body">
      <div className="ne-flow-plain ne-lit" style={{
  animationDelay: "0s"
}}>
        evals/*.eval.ts
      </div>

      <div className="ne-flow-edge">
        <span className="ne-flow-line ne-lit" style={{
  animationDelay: "0.6s"
}} />
        <span className="ne-flow-tip">▼</span>
      </div>

      <div className="ne-flow-node ne-lit" style={{
  animationDelay: "1.2s"
}}>
        <div className="ne-flow-name">niceeval</div>
        <div className="ne-flow-sub">发现评估用例、排期、判定、出报告</div>
      </div>

      <div className="ne-flow-edge">
        <span className="ne-flow-line ne-lit" style={{
  animationDelay: "1.8s"
}} />
        <span className="ne-flow-edge-text">Agent 适配器（官方）</span>
        <span className="ne-flow-line ne-lit" style={{
  animationDelay: "2.1s"
}} />
        <span className="ne-flow-tip">▼</span>
      </div>

      <div className="ne-flow-node ne-lit" style={{
  animationDelay: "2.4s"
}}>
        <div className="ne-flow-name">Docker Sandbox</div>
        <div className="ne-flow-sub">每个 Attempt 一个干净工作区</div>
        <div className="ne-flow-inner ne-lit" style={{
  animationDelay: "3s"
}}>
          <div className="ne-flow-name">Codex / Claude Code</div>
          <div className="ne-flow-sub">需要隔离工作区的应用</div>
        </div>
      </div>
    </div>
    <div className="ne-ft">Fixture 写进这个工作区，跑完在里面收文件与命令结果。</div>
  </div>;

[NiceEval](https://niceeval.com/) 是一个 Agent 评估工具，帮助团队衡量、评估并改进生产环境中的 AI。借助 NiceEval，团队可以比较模型、迭代 Agent、发现回归问题，并利用真实用户数据持续改进 AI 应用。

NiceEval 以本地优先为核心：你的评估在你自己的环境中运行。当团队需要分享评估结果、做回归跟踪时，可以通过 Report 上报到 BrainTrust 等平台，或者自定义报告导出。

它既能评估用于 Claude Code / Codex 的 Plugins、Hook 和 Skill，也能直接评你自己的 AI Agent 应用。无论你的 Agent 基于 AI SDK、LangGraph、Pi 还是自研 Agent SDK，都可以通过 Adapter 接入同一套评估体系。

## 构建评估用例

```ts theme={null}
// evals/eval-tool-call.eval.ts
import { defineEval } from "niceeval";
import { includes } from "niceeval/expect";

export default defineEval({
  judge: true,
  description: "测试 agent 在实时天气问题中正确调用工具并基于结果作答的能力",

  async test(t) {
    const turn = await t.send("北京今天天气怎么样？");
    turn.succeeded().label("Turn 成功");

    await t.group("调用 get_weather 且回答天气", () => {
      t.calledTool("get_weather").label("调用天气工具");
      t.check(turn.message, includes("天气")).label("说明天气");
    });

    const second = await t.send("上海明天天气怎么样?");
    t.check(second.message, includes("上海")).label("第二轮回答上海");

    turn.judge.autoevals.closedQA("助手是否基于工具返回的天气数据作答？")
      .atLeast(0.7)
      .label("回答有依据");
  },
});
```

```sh theme={null}
pnpm exec niceeval exp local eval-tool-call  # 用 local experiment 只跑 eval-tool-call
pnpm exec niceeval show             # 当前项目全部仍有效的结果，适合人和 AI
pnpm exec niceeval view             # 在网页中浏览同一份 Sample
```

## 为什么有了 DeepEval、LangFuse、BrainTrust 还需要 NiceEval

NiceEval 是一个 Agent-Native 的评估工具。Dataset / golden 那一套「构建 Input 与 Expected Output」的模式，并不适合真实的 Agent 评估。现在的 Agent 要在多轮对话、多 agent 协作、工具调用、Skill 加载等细粒度场景下被检查，NiceEval 就是为这类场景设计的：断言直接落在工具调用、消息内容、结构化输出和用量上，而不是要求你先手工准备一份 golden 测试集。

像 LangFuse、BrainTrust 这类工具更偏 tracing 和监控，对「写评估用例、跑评估用例、看结果」这条路径来说太重。NiceEval 从一开始就针对这条路径做了友好的开发体验。两者也不冲突：NiceEval 能与 LangFuse、BrainTrust 共存——可以用它们做 tracing，或者把评估结果上传到两者。

## 你可以评什么

<CardGroup cols={2}>
  <Card title="Coding Agent" icon="code">
    把 Claude Code、Codex、bub 放进 Sandbox，给它任务，再用真实测试和文件断言验证结果。
  </Card>

  <Card title="你自己的 AI Agent 应用" icon="globe">
    直连你的应用接口，断言回复、工具调用和结构化输出。通过 Flag 切换测试不同版本的 Prompt
  </Card>
</CardGroup>

## 两种接入模式

<Tabs>
  <Tab title="Sandbox mode">
    适合 Codex、Claude Code 这类必须在真实文件系统中改代码、跑命令的 coding agent。

    <SandboxMode />
  </Tab>

  <Tab title="Direct mode">
    适合你自己的 AI Agent，不需要 Docker。

    <DirectMode />
  </Tab>
</Tabs>

## 核心概念一览

| 概念         | 一句话                                                                            |
| ---------- | ------------------------------------------------------------------------------ |
| 评估用例       | 一个测试用例：写在 `evals/*.eval.ts` 里，描述测什么。                                           |
| Experiment | 可签入的运行配置：决定连哪个 Adapter、什么 model、什么 flags。                                      |
| Adapter    | 连接被测系统的适配层：实现一个 `send`，把返回翻译成标准事件流。                                            |
| Sandbox    | 需要隔离工作区的 coding agent 才用得到。直连 Web Agent 不需要。                                   |
| Tier       | 接入 Adapter 的三档投入：Tier 1 只接 send，Tier 2 加 OTel 换调用瀑布图，Tier 3 侵入改造做 feature A/B。 |

完整术语表见[架构概览](/docs/zh/explanation/overview)。

## 从你的场景开始

<CardGroup cols={3}>
  <Card title="接入 Agent" icon="code-branch" href="/docs/zh/tutorials/connect-your-agent">
    连接你的 Agent，写一个 Adapter，把消息、工具调用和结构化输出翻译成标准事件流。
  </Card>

  <Card title="评估 Coding Agent 扩展" icon="wand-magic-sparkles" href="/docs/zh/examples/coding-agent-extensions">
    用真实 Workspace 和对照实验衡量 Skill、提示词与 Plugin Benchmark 的效果。
  </Card>

  <Card title="学习如何写评估用例与实验" icon="robot" href="/docs/zh/tutorials/authoring">
    了解如何写评估用例、断言、实验配置和报告。
  </Card>
</CardGroup>

## 接下来读什么

[快速开始](/docs/zh/tutorials/quickstart) 会带你安装 [NiceEval](https://niceeval.com/)、构建评估用例、得到评估报告。
