Community编程与开发github.com

评估

此技能用于构建智能体评估系统:确定性检查、回归测试套件、多维评分标准、质量门禁、生产监控、基线对比以及智能体流程的结果衡量。

评估 是什么?

该“评估”技能指导开发者如何为智能体系统(如Claude Code、Cursor、Codex)建立有效的评估框架,因为这些系统具有动态决策、非确定性和缺乏单一正确答案的特点。技能核心在于使用多维评分标准而非单一指标,强调评估结果而非执行路径,并优先进行确定性验证。它涵盖了从设计测试集(按复杂度分层)、构建LLM-as-Judge评估提示,到建立持续集成管道和生产监控的完整流程。此外,它还提供了避免常见陷阱(如过度拟合特定路径、LLM自增强偏差和测试集污染)的实用指南,并包含了Python和YAML格式的代码示例来演示评估实现。该技能适用于需要系统化度量、回归检测和质量门禁的任何智能体管道开发阶段。

兼容平台~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/muratcankoylan/Agent-Skills-for-Context-Engineering/tree/main/skills/evaluation

Installed? Explore more 编程与开发 skills: steipete/bluebubbles, steipete/eightctl, steipete/blucli · View all 6 →

在你喜欢的 AI 中提问

打开一个已预加载此 Agent Skill 的新对话。

文档

智能体系统评估方法

智能体系统的评估方法与传统软件不同,因为智能体会做出动态决策,在多次运行之间具有非确定性,并且常常缺乏单一正确答案。应构建能够解释这些特性、提供可操作反馈、捕捉回归问题、并验证上下文工程选择是否达到预期效果的评估框架。

何时激活

在以下情况下激活此技能:

  • 系统化测试智能体性能
  • 验证上下文工程选择
  • 衡量随时间推移的改进
  • 在部署前捕捉回归问题
  • 为智能体管道构建质量门禁
  • 比较不同的智能体配置
  • 持续评估生产系统

对于属于其他技能的相邻工作,请勿激活此技能:

  • 设计LLM评判器本身、成对比较、评判器校准或偏差缓解:advanced-evaluation。
  • 设计自主控制面、新颖性门控、回滚或PR审批边界:harness-engineering。
  • 在度量之前调试特定的上下文失效模式:context-degradation。
  • 在上下文预算内比较harness驱动和模型驱动的压缩,或分析模型的压缩行为:compaction-control-profiling。

核心概念

评估应聚焦于结果而非执行路径,因为智能体可能找到达到目标的不同有效路径。评判智能体是否通过合理的过程达到了正确的结果,而不是它是否遵循了特定的步骤序列。

使用多维评分标准而非单一分数,因为单一数字会隐藏特定维度的关键失败。将事实准确性、完整性、引用准确性、来源质量和工具效率作为独立维度进行捕捉,然后根据用例进行加权。

仅在确定性检查和评分标准稳定之后,再使用模型评判的评估。当工作中心在于评判器提示、成对比较、校准或偏差缓解时,切换到高级评估。

只要工件具有机器可检查的结构,就应在LLM评判之前运行确定性验证。模式有效性、重复键、评分标准计算、清单同步、检索状态和必需的证据路径应在评估器消耗令牌或返回主观分数之前快速失败。

性能驱动因素

在设计评估预算时应用浏览智能体的研究:令牌使用量、工具调用次数和模型选择会主导测得的性能方差(claim-evaluation-browsecomp-variance)。

因素解释的方差影响
令牌使用量主要驱动因素更多探索可以提高性能,直到成本或上下文质量崩溃
工具调用次数次要驱动因素只有在调用检索到有用证据时,更多工具使用才有帮助
模型选择次要但乘数效应更好的模型通常能更有效地使用令牌和工具

在设计评估时根据这些影响采取行动:

  • 设置现实的令牌预算:使用生产级别的令牌限制(而非无限资源)来评估智能体。
  • 将模型升级与令牌增加进行比较:更好的模型可能比预算更大的较弱模型更有效地使用令牌。
  • 验证多智能体架构:额外的智能体会增加令牌和工具调用次数;将其与单智能体基线进行比较。

详细主题

评估挑战

处理非确定性和多条有效路径

设计能够容忍路径变化的评估,因为智能体可能采取完全不同的有效路径来达到目标。一个智能体可能搜索三个来源,而另一个可能搜索十个;两者都可能产生正确答案。避免检查特定步骤。相反,定义结果标准(正确性、完整性、质量)并根据这些标准评分,将执行路径视为信息性而非评估性。

测试上下文相关的失败

跨一系列复杂级别和交互长度进行评估,因为智能体失败通常以微妙的方式依赖于上下文。一个智能体可能在简单查询上成功,但在复杂查询上失败;可能在一个工具集上运行良好,但在另一个工具集上失败;或者在扩展交互后因上下文累积而性能下降。包括简单、中等、复杂和非常复杂的测试用例,以揭示这些模式。

分别评分复合质量维度

将智能体质量分解为单独维度(事实准确性、完整性、连贯性、工具效率、过程质量)并独立评分,因为智能体可能在准确性上得分高但在效率上得分低,反之亦然。然后计算加权聚合,根据用例优先级进行调整。这种方法可以揭示哪些维度需要改进,而不是平均掉信号。

评估评分标准设计

构建多维评分标准

定义包含关键维度的评分标准,并配有从优秀到失败的描述性级别。包括以下核心维度,并根据用例调整权重:

  • 事实准确性:陈述与事实相符(知识型任务权重高)
  • 完整性:输出涵盖所要求的方面(研究型任务权重高)
  • 引用准确性:引用与所声称的来源匹配(信任敏感环境权重高)
  • 来源质量:使用适当的原始来源(权威输出权重高)
  • 工具效率:以合理次数使用正确工具(成本敏感系统权重高)

将评分标准转换为数字分数

将维度评估映射为数字分数(0.0 到 1.0),应用每个维度的权重,并计算加权总分。根据用例要求设置通过阈值,通常通用场景为0.7,高风险应用为0.9。将各个维度的分数与聚合分数一起存储,因为分解数据可以推动有针对性的改进。

评估方法论

使用LLM作为评判者进行规模化评估

构建基于LLM的评估提示,包括:清晰的任务描述、被测试的智能体输出、可用时的真实数据、带有明确级别描述的评估量表,以及要求输出包含推理的结构化判断。LLM评判器可以在大型测试集上提供一致、可扩展的评估。使用与被评估智能体不同的模型系列,以避免自增强偏差。

辅以人工评估

将边缘案例、异常查询和随机抽样的生产流量路由给人工评审者,因为人类能够注意到自动化评估遗漏的幻觉答案、系统故障和细微偏差。追踪人工评审中的模式以识别系统性问题,并将发现反馈到自动化评估标准中。

对有状态智能体应用最终状态评估

对于改变持久状态(文件、数据库、配置)的智能体,评估最终状态是否符合预期,而非智能体如何达到该状态。定义预期的最终状态断言,并在每次测试运行后以编程方式进行验证。

测试集设计

选择代表性样本

在早期开发阶段,当更改影响巨大且易发现低垂果实(指容易解决的问题)时,从小样本(20-30个案例)开始。随着系统成熟,扩展到50个以上案例以获得可靠信号。从真实使用模式中采样,添加已知的边缘案例,并确保覆盖所有复杂度级别。

按复杂度分层

跨复杂度级别构建测试集,以防止简单示例人为抬高分数:

  • 简单:单次工具调用,事实查询
  • 中等:多次工具调用,比较逻辑
  • 复杂:多次工具调用,大量歧义
  • 非常复杂:扩展交互,深度推理,综合

除了总体分数外,还需要按层级报告分数,以揭示智能体实际在哪些方面遇到困难。

上下文工程评估

系统化验证上下文策略

在相同的测试集上使用不同的上下文策略运行智能体,并比较质量分数、令牌使用量和效率指标。这可以将上下文工程的影响与其他变量隔离开来,并防止基于轶事(即基于个人经验或传闻,而非系统性数据)的决策。

运行退化测试

通过在不同上下文大小下运行智能体,测试上下文退化如何影响性能。识别上下文变得有问题的性能悬崖,并建立安全的操作限制。将这些限制反馈到上下文管理策略中。

持续评估

构建自动化评估管道

将评估集成到开发工作流程中,以便在智能体更改时自动运行评估。随时间跟踪结果,比较不同版本,并阻止在关键指标上出现回归的部署。

监控生产质量

对生产交互进行抽样并持续评估。设置告警,当通过率低于警告(0.85通过率)和严重(0.70通过率)阈值时进行通知。维护仪表板,显示随时间窗口的趋势分析,以检测逐渐退化。

实践指导

构建评估框架

按照以下顺序构建评估框架,因为跳过早期步骤会导致测量结果不能反映真实质量:

  1. 在编写任何评估代码之前,先定义与用例相关的质量维度,因为之后选择的维度往往反映的是易度量性而非重要性。
  2. 创建带有清晰、描述性级别定义的评分标准,以便评估者(人工或LLM)产生一致的分数。
  3. 从真实使用模式和边缘案例中构建测试集,按复杂度分层,至少包含50个案例以获得可靠信号。
  4. 实现自动化评估管道,在每次重要更改时运行。
  5. 在进行更改之前建立基线指标,以便可以相对于已知参考来衡量改进。
  6. 对所有重要更改运行评估,并与基线进行比较。
  7. 随时间跟踪指标以进行趋势分析,因为逐渐退化比突然下降更难注意到。
  8. 定期辅以人工评审的自动化评估。
  9. 将确定性验证失败与质量判断分开,这样无效的工件就不能通过有利的LLM评分来掩盖。

避免评估陷阱

防范以下常见失败,这些失败会破坏评估的可靠性:

  • 过度拟合特定路径:评估结果,而非特定步骤,因为智能体会找到新的有效路径。
  • 忽略边缘案例:包含涵盖完整复杂度谱的多样化测试场景。
  • 单一指标迷恋:使用多维评分标准,因为单一分数会隐藏特定维度的失败。
  • 忽视上下文效应:使用现实的上下文大小和历史进行测试,而不是在无干扰的条件下进行。
  • 跳过人工评估:自动化评估会遗漏人类能可靠捕捉的微妙问题。

示例

示例1:简单评估

def evaluate_agent_response(response, expected):
    rubric = load_rubric()
    scores = {}
    for dimension, config in rubric.items():
        scores[dimension] = assess_dimension(response, expected, dimension)
    overall = weighted_average(scores, config["weights"])
    return {"passed": overall >= 0.7, "scores": scores}

示例2:测试集结构

测试集应跨越多个复杂度级别以确保全面评估:

test_set = [
    {
        "name": "simple_lookup",
        "input": "What is the capital of France?",
        "expected": {"type": "fact", "answer": "Paris"},
        "complexity": "simple",
        "description": "Single tool call, factual lookup"
    },
    {
        "name": "medium_query",
        "input": "Compare the revenue of Apple and Microsoft last quarter",
        "complexity": "medium",
        "description": "Multiple tool calls, comparison logic"
    },
    {
        "name": "multi_step_reasoning",
        "input": "Analyze sales data from Q1-Q4 and create a summary report with trends",
        "complexity": "complex",
        "description": "Many tool calls, aggregation, analysis"
    },
    {
        "name": "research_synthesis",
        "input": "Research emerging AI technologies, evaluate their potential impact, and recommend adoption strategy",
        "complexity": "very_complex",
        "description": "Extended interaction, deep reasoning, synthesis"
    }
]

示例3:模型评判前的确定性门控

def evaluate_pr_candidate(candidate):
    structure = run_validate_repo(candidate)
    if not structure.ok:
        return {"passed": False, "reason": "deterministic validation failed", "details": structure.errors}

    quality = run_rubric_eval(candidate)
    return {"passed": quality.overall >= 0.8, "scores": quality.dimensions}

示例4:质量门禁维度

gate:
  deterministic:
    - schema_valid
    - required_files_present
    - no_duplicate_ids
  quality:
    factual_accuracy: min 0.85
    completeness: min 0.80
    source_traceability: min 0.90

准则

  1. 使用多维评分标准,而非单一指标
  2. 评估结果,而非特定的执行路径
  3. 覆盖从简单到复杂的各复杂度级别
  4. 使用现实的上下文大小和历史进行测试
  5. 持续运行评估,而不仅仅在发布前
  6. 用人工评审补充LLM评估
  7. 随时间跟踪指标以进行趋势检测
  8. 基于用例设置明确的通过/失败阈值

陷阱

  1. 评估过度拟合特定代码路径:测试通过,但智能体在微小的输入变化上失败。应根据结果和语义编写评估标准,而非表面模式,并定期轮换测试输入。
  2. LLM评判器自增强偏差:模型对自己输出的评分高于独立评判器的评分。使用与被评估模型不同的模型系列作为评估评判器。
  3. 测试集污染:评估示例泄露到训练数据或提示中。确保测试集与训练数据隔离,并定期更新测试用例以避免记忆化。

Individual skills in this repo

This repo contains 20 individual skills — each has its own dedicated page.

advanced-evaluation

This skill should be used for advanced LLM evaluation: LLM-as-judge systems, direct scoring, pairwise comparison, rubric calibration, evaluator bias mitigation, confidence scoring, and automated quality assessment.

bdi-mental-states

This skill should be used when modeling agent mental states with BDI concepts: beliefs, desires, intentions, RDF-to-belief transformations, rational agency traces, cognitive agents, BDI ontologies, and neuro-symbolic AI integration.

book-sft-pipeline

This skill should be used for book-to-SFT pipelines: ePub extraction, literary segmentation, author-voice dataset construction, style-transfer training, LoRA workflows, and model evaluation for voice replication.

compaction-control-profiling

This skill should be used when deciding, for a specific model and workload, whether the harness or the model should control compaction, and when qualifying or calibrating that choice with measurements: context-budget sweeps that compare harness-driven and model-driven compaction on one harness, the context-pressure regime where delegation pays, a per-model compaction behavior profile (interface uptake, compression factor per call, reopen rate of archived content, context fill at first compaction, response to pressure warnings), context anxiety and timing-instruction calibration, reversible collapse-and-archive interfaces, and re-qualification after a model or prompt change. Route the editable-file protocol, harness invariants, and edit-position cache cost of self-editing agents to self-managed-context, summary content to context-compression, harness thresholds and cache layout to context-optimization, and general evaluation design to evaluation.

comprehensive-research-agent

Ensure thorough validation, error recovery, and transparent reasoning in research tasks with multiple tool calls

context-compression

This skill should be used when long-running agent sessions need context compression, structured summarization, compaction, token-per-task optimization, or durable handoff summaries that preserve decisions, files, risks, and next actions.

context-degradation

This skill should be used for diagnosing and mitigating context degradation: lost-in-middle failures, context poisoning, context clash, context confusion, attention-pattern issues, and agent performance degradation caused by accumulated or conflicting context.

context-fundamentals

This skill should be used to explain or reason about the foundational concepts of context engineering: what context is, the anatomy of a context window, how attention mechanics work, the U-shaped attention curve, why context quality matters more than quantity, and the mental models needed to interpret every other context-engineering decision. Use this for conceptual explanation, onboarding, and background reading. Route operational work to the specialized skills: debugging attention failures goes to context-degradation, token-efficiency work goes to context-optimization, conversation summarization goes to context-compression, and project-shape decisions go to project-development.

context-optimization

This skill should be used for improving context efficiency: context budgeting, observation masking, prefix or KV-cache strategy, partitioning, token-cost reduction, retrieval scoping, and extending effective context capacity without lowering answer quality.

filesystem-context

This skill should be used when agent work needs file-backed context: durable scratchpads, tool-output offloading, just-in-time discovery, cross-agent handoff files, filesystem memory, or cleanup policies for context stored outside the prompt.

harness-engineering

This skill should be used when designing autonomous agent harnesses: research loops, evaluation scaffolds, locked and editable surfaces, durable logs, novelty gates, pruning, rollback, PR preparation, and human approval boundaries.

hosted-agents

This skill should be used when designing hosted or background agent infrastructure: sandboxed execution, remote coding environments, warm pools, session persistence, multiplayer collaboration, self-spawning agents, or Modal-style sandboxes.

instruction-surface-security

Hardens agent runtimes against persistent prompt injection or unauthorized changes to instructions and permissions. Use to audit what agents auto-load, design reviewed activation for project rules, skills, memory, or tool configuration, and test whether trust boundaries hold after reload, restart, or delegation.

latent-briefing

This skill should be used when the user asks to "share memory between agents", "KV cache compaction for multi-agent", "orchestrator worker context", "latent briefing", "reduce worker tokens", "cross-agent memory without summarization", or discusses Attention Matching compaction, recursive language models with workers, or token explosion in hierarchical agents.

long-horizon-prompting

This skill should be used when writing, enhancing, or evaluating the launch prompt for a long-running autonomous agent or a parallel multi-agent orchestration attacking a hard problem: pseudo-formal task briefs that define terms and an exact success predicate linguistically, enumerate non-counting outcomes, set persistence rules with explicit stop and return conditions and effort floors, manage a diverse portfolio of parallel approaches with an approach registry and blocked-route bookkeeping, and gate the return on adversarial audit. Route agent topology and coordination protocols to multi-agent-patterns, runtime control surfaces and loop governance to harness-engineering, evaluator and quality-gate construction to evaluation, judge design to advanced-evaluation, and compaction or memory mechanics to context-compression and memory-systems.

memory-systems

This skill should be used for persistent semantic memory in agent systems: cross-session knowledge retention, entity tracking, temporal validity, graph or vector retrieval, memory consolidation, and memory benchmark selection. Route file-backed scratchpads to filesystem-context, handoff summaries to context-compression, and token-efficiency tactics to context-optimization.

multi-agent-patterns

This skill should be used when designing multi-agent systems that need context isolation, supervisor or swarm coordination, explicit handoffs, parallel execution, or a decision on whether multiple agents are justified.

project-development

This skill should be used for project-level decisions about LLM-powered systems: whether an LLM is the right primitive for the task at hand, the shape of a multi-stage batch or agent pipeline, token and cost estimation, choosing between single-agent and multi-agent at the project level, structured output design for downstream parsing, and structuring agent-assisted iteration. Use this when the unit of work is a whole project or a multi-stage pipeline. Route individual tool design to tool-design and individual skill-loading or context-budget tactics to context-optimization.

self-improvement-loops

This skill should be used when the harness, scaffold, workflow, or optimizer itself is the optimization target: recursive self-improvement (RSI) loops, meta-harnesses, self-improving harnesses that mine their own failures and propose bounded edits, evolutionary or population-based search over agent scaffolds, acceptance gates for self-modifying systems, and agentic context evolution where the mechanism that produces context is versioned and evolved. Route governance of a single autonomous loop (locked surfaces, durable logs, rollback, novelty gates, approval boundaries) to harness-engineering, measurement and quality-gate design to evaluation, judge design to advanced-evaluation, and remote sandbox infrastructure to hosted-agents.

self-managed-context

This skill should be used when a model gets read-write control over its own live context window instead of a harness-scheduled compaction policy: the context exposed as an editable file the model rewrites with code tools, model-driven eviction and in-place updates, the harness invariants that keep self-editing safe (pinned prefix, edit gate, edit receipts, budget readouts, rollback on overflow), the prefix-cache cost of mid-context edits, and steering or training the model's own context-editing strategy. Route note content and fixed-threshold summarization to context-compression, cache-stable layout under harness control to context-optimization, file offloading to filesystem-context, and loop governance to self-improvement-loops.

相关技能