@agentskit/eval

中文文档
0.7.0发布于 2026/10/10MITTypeScriptESM + CJS构建来源已验证近 30 天下载 1.1万

Agent evaluation and benchmarking for AgentsKit.

原始使用文档
文档目录15 节
  1. Verified proof
  2. How this fits the ecosystem
  3. Why eval
  4. Install
  5. Quick example
  6. Features
  7. Result records
  8. Deterministic replay
  9. Braintrust lifecycle
  10. Ecosystem
  11. Contributors
  12. License
  13. Docs
  14. Maturity and compatibility
  15. Contributing

@agentskit/eval

Profile: concise-package

AgentsKit

Measure agent quality with numbers, not vibes — ship with confidence.

npm version npm downloads bundle size license stability GitHub stars

Tags: ai · agents · llm · agentskit · ai-agents · eval · evaluation · benchmarking · testing · ci-cd · llm-testing

Verified proof

How this fits the ecosystem

@agentskit/eval is the quality layer: replay agent runs, compare outputs, snapshot behavior, and catch regressions before users do.

  • AgentsKit: compose it with the other packages in this repo to build agents from small, swappable parts.
  • Registry: look for ready agents and templates that already use this layer at registry.agentskit.io.
  • Playbook: learn the production patterns behind this layer at playbook.agentskit.io.

Docs: package guide · agent handoff

Why eval

  • Replace "it seemed to work" with real metrics — accuracy, per-case latency, optional token usage, and pass/fail for every test case in a single result object
  • CI/CD ready — exit codes reflect suite results; gate deployments on accuracy thresholds so regressions never reach production
  • Flexible assertions — substring matching or full control with a custom (result) => boolean predicate per case
  • Provider-agnostic — the agent closure can wrap any async boundary: createRuntime, a custom controller, or an HTTP endpoint
  • Failure isolation — malformed responses, agent failures, and assertion failures become failed cases without aborting the suite

Install

npm install @agentskit/eval

Quick example

import { runEval } from '@agentskit/eval'
import { createRuntime } from '@agentskit/runtime'
import { anthropic } from '@agentskit/adapters'

const runtime = createRuntime({
  adapter: anthropic({ apiKey: process.env.ANTHROPIC_API_KEY, model: 'claude-sonnet-4-6' }),
})

const result = await runEval({
  agent: async (input) => {
    const r = await runtime.run(input)
    return r.content
  },
  suite: {
    name: 'qa-baseline',
    cases: [
      { input: 'What is 2+2?', expected: '4' },
      { input: 'Capital of France?', expected: 'Paris' },
      { input: 'Is TypeScript a superset of JavaScript?', expected: (r) => r.toLowerCase().includes('yes') },
    ],
  },
})

console.log(`Accuracy: ${(result.accuracy * 100).toFixed(1)}%`)
console.log(`Passed: ${result.passed}/${result.totalCases}`)

Features

  • runEval({ agent, suite }) — run a named test suite against any agent function
  • Result: { accuracy, passed, totalCases, cases[] } — per-case latency and outcome
  • Assertion modes: exact match, includes, custom predicate
  • CI exit codes — non-zero on failure for pipeline gating
  • Pair with @agentskit/observability to trace failed cases

Result records

Use @agentskit/eval/provenance to preserve benchmark identity and metrics without running an agent:

import { createResultRecord, serializeResultRecord, verifyResultRecord, precisionRecall } from '@agentskit/eval/provenance'

const record = createResultRecord({
  suiteId: 'baseline',
  caseSetDigest: 'a'.repeat(64), // SHA-256 of the frozen cases
  subject: { revision: 'revision-1', digest: 'b'.repeat(64) },
  runnerVersion: '1',
  metrics: { measured: 2, unavailable: 1, invalid: 0, ...precisionRecall({ tp: 3, fp: 1, fn: 2 }) },
})
const saved = serializeResultRecord(record)
verifyResultRecord(JSON.parse(saved)) // true

ResultRecordInput requires non-empty suiteId, subject.revision, and runnerVersion, lowercase 64-character SHA-256 caseSetDigest and subject.digest, and a JSON metrics object (ResultMetric supports nested arrays and objects). Creation snapshots the input. ResultRecord adds digest: SHA-256 of the UTF-8 RFC 8785 canonical JSON of all input fields except timestamp. Serialization includes the digest and optional timestamp. Omit the timestamp for byte-identical reruns; changing it does not invalidate the digest. Core's canonical JSON semantics apply: undefined object fields are omitted, undefined array entries become null, and non-finite numbers and cycles are rejected.

verifyResultRecord(unknown) returns false for malformed provenance or a mismatched digest, without throwing. It checks integrity, not authenticity or whether the supplied revision and digests correspond to real artifacts. A party able to rewrite the record and its digest can produce another valid record.

precisionRecall({ tp, fp, fn }) accepts non-negative safe integers and returns { precision, recall } in [0, 1]. A zero denominator yields zero. Counts and per-unit results can be stored directly in metrics; these helpers do not run or judge cases.

Deterministic replay

Import recording, replay, cassette serialization, time travel, and comparison APIs from @agentskit/eval/replay. That entry is safe for Node, browsers, Expo, and React Native; browser and native package conditions exclude filesystem code.

Node applications that persist cassettes to disk should import saveCassette and loadCassette from the explicit Node-only subpath:

import { createCassette } from '@agentskit/eval/replay'
import { saveCassette, loadCassette } from '@agentskit/eval/replay/io'

await saveCassette('./fixtures/session.json', createCassette())
const cassette = await loadCassette('./fixtures/session.json')

The original Node exports from @agentskit/eval/replay remain available for compatibility. Browser and native builds retain those export names so types and runtime stay aligned, but calls reject with a Node-only diagnostic. Those hosts should combine serializeCassette or parseCassette with their own storage APIs.

@agentskit/eval/snapshot and @agentskit/eval/ci are Node-oriented subpaths because they write files and inspect CI environment variables. Pure comparison helpers remain callable anywhere their entry can be bundled, but browser applications should not depend on their filesystem workflows.

Replay boundaries snapshot cassettes, requests, chunks, dates, and plain metadata. Mutating a live request or a replayed chunk does not rewrite the recorded cassette.

Braintrust lifecycle

@agentskit/eval/braintrust computes every score locally. When BRAINTRUST_API_KEY or options.apiKey is present, it lazily initializes Braintrust, awaits each experiment log, flushes the experiment, and then summarizes it. Non-fatal SDK failures are returned as bounded result.warnings; local cases and summaries remain available.

Remote case fields are excluded by default. Use options.upload to explicitly allow selected input, output, expected, or metadata fields; selected values are capped by maxFieldBytes (default 4096), and run-level metadata follows the same allowlist.

Custom scorer results are validated at runtime. A malformed name or score outside [0, 1] becomes an isolated scorer_error rather than corrupting the aggregate.

Ecosystem

PackageRole
@agentskit/runtimeTypical agent under test
@agentskit/coreStable I/O contracts for eval harnesses
@agentskit/observabilityTraces for failed cases

Contributors

AgentsKit contributors

License

MIT — see LICENSE.

Docs

Full documentation · GitHub

Maturity and compatibility

  • Stability: beta — see docs/STABILITY.md
  • Node.js 20+ and TypeScript strict mode
  • Published as @agentskit/eval

Contributing

See CONTRIBUTING.md and the monorepo LICENSE.

版本与发布记录

@agentskit/eval 共发布 41 个版本,首次发布于 2026/04/06;过去 12 个月发布了 41 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
0.7.0latest2026/10/1026 天前
0.6.122026/10/031 个月前
0.6.112026/10/031 个月前
0.6.102026/09/291 个月前
0.6.92026/09/281 个月前
0.6.82026/09/281 个月前

关于 @agentskit/eval 的常见问题

@agentskit/eval 是什么?

Agent evaluation and benchmarking for AgentsKit.

如何安装 @agentskit/eval?

在项目目录运行 npm install @agentskit/eval,或使用 pnpm add / yarn add / bun add。

@agentskit/eval 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@agentskit/eval 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

@agentskit/eval 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >=20.19。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@agentskit/eval 可以商用吗?

@agentskit/eval 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@agentskit/eval 的下载量有多少?

根据 npm 官方下载统计,@agentskit/eval 在 2026/10/05 – 2026/11/03 这 30 天内被下载 10,794 次,日均约 360 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@agentskit/eval 还在维护吗?

最新版本 0.7.0 发布于 2026/10/10(26 天前);至今共发布 41 个版本,其中过去 12 个月发布了 41 个;首次发布于 2026/04/06。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。