Community程式設計與開發github.com

評估

此技能用於建構代理系統評估:確定性檢查、回歸測試套件、多維度評分標準、品質閘門、生產監控、基準比較與結果衡量。

評估 是什麼?

此技能專注於為代理系統設計與實施評估框架。與傳統軟體評估不同,代理系統的動態決策與非確定性行為需要新的評估方法。它強調以結果為導向,而非執行路徑,並使用多維度評分標準(如事實準確性、完整性、引用準確性等)來捕捉單一分數可能隱藏的關鍵失敗。技能內容涵蓋了從設計測試集、建立自動化評估管道,到監控生產環境品質的完整流程,並提供了具體的範例與實務準則。此技能適用於 Claude Code、Cursor 等支援自訂技能的工具,主要應用於需要系統性驗證代理行為、比較不同配置、或建立品質閘門的開發場景。

相容平台~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。

核心概念

評估應專注於結果而非執行路徑,因為代理可能找到達成目標的不同有效路徑。判斷代理是否透過合理的流程達成了正確的結果,而不是它是否遵循了特定的步驟順序。

使用多維度評分標準而非單一分數,因為一個數字會隱藏特定維度的關鍵失敗。將事實準確性、完整性、引用準確性、來源品質和工具效率作為獨立維度進行評估,然後根據使用案例進行加權。

僅在確定性檢查和評分標準穩定之後,再使用模型評判的評估。當工作重點在於評判提示、成對比較、校準或偏差緩解時,請切換到「進階評估」(Advanced Evaluation)。

只要產出物具有機器可檢查的結構,應先執行確定性驗證,再進行 LLM 判斷。結構有效性、重複金鑰、評分數學、清單同步、檢索狀態和必要證據路徑應快速失敗,然後評估器才會花費 Token 或返回主觀分數。

效能驅動因素

在設計評估預算時應用瀏覽代理研究:Token 使用量、工具呼叫次數和模型選擇可能主導測量到的效能變異(claim-evaluation-browsecomp-variance)。

因素解釋的變異量影響
Token 使用量主要驅動因素更多的探索可以提高效能,直到成本或上下文品質崩潰
工具呼叫次數次要驅動因素只有在呼叫檢索到有用的證據時,更多的工具使用才有幫助
模型選擇次要但具倍增性更好的模型通常能更有效地使用 Token 和工具

在設計評估時,應根據這些影響採取行動:

  • 設定實際的 Token 預算:使用接近生產環境的 Token 限制來評估代理,而不是無限制的資源。
  • 比較模型升級與 Token 增加:更好的模型可能比預算較大的較弱模型更有效地使用 Token。
  • 驗證多代理架構:額外的代理會增加 Token 和工具呼叫;應將其與單一代理基準進行比較評估。

詳細主題

評估挑戰

處理非確定性與多重有效路徑

設計能容忍路徑變化的評估,因為代理可能採取完全不同的有效路徑來達成目標。一個代理可能搜尋三個來源,另一個搜尋十個;兩者都可能產生正確答案。避免檢查特定步驟。相反地,定義結果標準(正確性、完整性、品質)並據以評分,將執行路徑視為參考資訊而非評估項目。

測試上下文相關的失敗

在各種複雜度層級和互動長度下進行評估,因為代理的失敗通常以微妙的方式取決於上下文。代理可能在簡單查詢上成功,但在複雜查詢上失敗;可能在一組工具上表現良好,但在另一組工具上失敗;或者隨著上下文累積,在長時間互動後效能下降。包含簡單、中等、複雜和非常複雜的測試案例,以揭示這些模式。

分別評估複合品質維度

將代理品質分解為獨立維度(事實準確性、完整性、連貫性、工具效率、流程品質)並分別評分,因為代理可能在準確性上得分高,但在效率上得分低,反之亦然。然後計算根據使用案例優先級調整的加權總分。這種方法能揭示哪些維度需要改進,而不是將訊號平均掉。

評估評分標準設計

建立多維度評分標準

定義涵蓋關鍵維度的評分標準,並附有從優異到失敗的描述性等級。包含以下核心維度,並根據使用案例調整權重:

  • 事實準確性:聲明與基本事實相符(知識任務權重高)
  • 完整性:輸出涵蓋要求的面向(研究任務權重高)
  • 引用準確性:引用與所聲稱的來源相符(信任敏感環境權重高)
  • 來源品質:使用適當的原始來源(權威性輸出權重高)
  • 工具效率:以合理的次數使用正確的工具(成本敏感系統權重高)

將評分標準轉換為數值分數

將維度評估映射到數值分數(0.0 到 1.0),應用每個維度的權重,並計算加權總分。根據使用案例要求設定通過門檻,一般用途通常為 0.7,高風險應用為 0.9。將各個維度的分數與總分一起儲存,因為細部分數能驅動針對性的改進。

評估方法

使用 LLM 作為評判以實現規模化

建立基於 LLM 的評估提示,包括:清晰的任務描述、被測試的代理輸出、可用的基本事實、帶有明確等級描述的評估量表,以及要求提供帶有推理的結構化判斷。LLM 評判能跨大型測試集提供一致、可擴展的評估。使用與被評估代理不同的模型系列,以避免自我增強偏差。

輔以人工評估

將邊緣案例、不常見的查詢以及生產流量中的隨機樣本分配給人工審查員,因為人類能注意到自動評估遺漏的幻覺答案、系統故障和細微偏差。追蹤人工審查中的模式以識別系統性問題,並將發現回饋到自動評估標準中。

對有狀態代理應用最終狀態評估

對於改變持久化狀態(檔案、資料庫、配置)的代理,評估最終狀態是否符合預期,而不是代理如何達到該狀態。定義預期的最終狀態斷言,並在每次測試執行後以程式方式進行驗證。

測試集設計

選擇代表性樣本

在早期開發階段從小型樣本(20-30 個案例)開始,此時變更影響劇烈且容易取得初步成果。隨著系統成熟,擴展到 50 個以上案例以獲得可靠的訊號。從實際使用模式中取樣,添加已知的邊緣案例,並確保跨複雜度層級的覆蓋率。

按複雜度分層

為防止簡單案例人為提高分數,應按複雜度層級組織測試集:

  • 簡單:單一工具呼叫,事實查詢
  • 中等:多個工具呼叫,比較邏輯
  • 複雜:許多工具呼叫,顯著模糊性
  • 非常複雜:長時間互動,深度推理,綜合分析

除了總分之外,也報告每個層級的分數,以揭示代理實際上的困難所在。

提示工程評估

系統性地驗證上下文策略

在相同的測試集上執行使用不同上下文策略的代理,並比較品質分數、Token 使用量和效率指標。這能隔離上下文工程的影響與其他變數,並防止基於軼事的決策。

執行降級測試

透過在不同上下文大小下執行代理,測試上下文降級如何影響效能。識別上下文變得有問題的效能懸崖,並建立安全的操作限制。將這些限制回饋到上下文管理策略中。

持續評估

建立自動化評估管道

將評估整合到開發工作流程中,以便在代理變更時自動執行評估。追蹤一段時間內的結果,比較版本,並阻止在關鍵指標上出現回歸的部署。

監控生產品質

抽樣生產環境的互動並持續進行評估。設定警報,以便在品質低於警告門檻(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.

相關技能