अध्याय 8 · Application engineering 8.7
Agent evaluation: system ko naapo, model ko nahi
Agent evaluation ka object poora system hai - model, prompts, tools, control loop, environment. Episode task, trial, trace, outcome se banta hai; pass^k reliability naapta hai, stateful grading final state check karta hai, cost per-successful-task par hota hai।
यह पृष्ठ पूरा करने पर आप
- Agent evaluation aur model evaluation ka farq saaf bataayein: system + protocol evaluate hota hai, parameters nahi।
- Ek evaluation episode ko task, trial, trace, outcome se describe karein; agent harness aur eval harness ki zimmedari alag karein।
- pass^k calculate karein, pass@k se ka farq batayein, aur agent evaluation pehle ko kyun dekhta hai yeh samjhayein।
- Samjhayein stateful grading (DB final state) aur final-state invariants "reply jaisa dikhta hai" se zyada reliable kyun hain।
- Do agent options ko "per-successful-task cost" se compare karein, aur uske blind spots batayein।
इस पृष्ठ पर
- Kya evaluate hota hai: system + protocol
- Metrics: reliability pehle, cost saath mein
- pass^k: deployer ka metric
- Pehle per-task, phir average
- Stateful grading: environment final state check
- Cost: per successful task
- Traces se fix points dhoondo
- Simulated calendar se grader validate karna
- Common traps
- Summary aur exercises
- Quick self-test
- Exercises
- Aage padhein
- अक्सर पूछे जाने वाले सवाल
Model evaluation poochhta hai “yeh model kya kar sakta hai”; agent evaluation poochhta hai “yeh system real tasks mein reliably kaam karwa sakta hai?”. Agar aapne LLM evaluation methodology padhi hai, to yeh page usi rigour ko multi-step, tool-wale, state-wale systems par le jaata hai।
Kya evaluate hota hai: system + protocol
Ek agent benchmark ka score naapta hai “specific system x specific task distribution x specific protocol”. System = model, prompts, memory, tools, control loop, execution environment; koi bhi ek badla to score badal sakta hai. Isliye:
- Mushkil sawaal = agent evaluation, nahi. Sirf questions mushkil kar diye aur system phir bhi ek answer output karta hai - woh sirf mushkil model evaluation hai. Agent evaluation ki key change: system act kar sakta hai, consequences observe karta hai, aur usi ke aadhar par adjust karta hai।
- Score protocol ke saath padho. Koi bhi score - pehle poochho: benchmark version aur split, system config, allowed tools, budget (steps/tokens/time), kaun sa grader।
- Harness system ka hissa bhi hai, eval ka bhi. Agent harness tay karta hai model kya context dekhta hai, tool calls kaise execute hote hain, kab rukta hai; eval harness task init karta hai, limits lagata hai, evidence save karta hai, grader call karta hai, results summarize. Do responsibilities alag: system-under-test apne grading rules ko touch nahi kar sakta।
Ek evaluation episode ka conceptual model (Anthropic ke eval guide aur Harvard CS2680 lectures se adapted):
for task in frozen_task_set: # task set frozen; beech mein change nahi
for trial in trials_for(task): # same task kai trials - jitter naapte hain
env = reset_to(task.initial_state) # environment resettable
while not done(agent) and within(budget):
obs = env.observe() # model sirf instructions, observations, tools dekhta hai
action = agent.next_action(obs) # reference answers aur grading state model se hidden
env.execute(action)
scores = protected_graders(env, trajectory) # graders protected
Task, trial, trace, outcome - chaar shabd yaad rakho: multiple trials jitter naapte hain, naye tasks nahi bante; trace appeal aur diagnostics ka evidence hai - failures, timeouts, tool errors sahit poora rakho।
Metrics: reliability pehle, cost saath mein
Task-level reliability ka repeat-run calculation dekhein
pass^k: deployer ka metric
pass@k poochhta hai “k samples, best wala safal?” - ceiling; pass^k poochhta hai “same task k independent retries - har baar safal?” - reliability. Real users agent ko baar-baar use karte hain - har failure asli loss - isliye agent scenarios pass^k par zyada. Independence assumption se magnitude (is page ka arithmetic - khud recompute kar sakte hain):
def passk(p, k): return 1 - (1 - p) ** k # yeh "at least one success" hai
# pass^k (har baar safal) = p**k; dono compare karne se "retry se reliability" ki keemat dikhti hai
for p in (0.4, 0.6, 0.8):
print(f"p={p:.1f}: p^4={p**4:.3f} 1-(1-p)^4={1-(1-p)**4:.3f}")
Output:
p=0.4: p^4=0.026 1-(1-p)^4=0.870
p=0.6: p^4=0.130 1-(1-p)^4=0.974
p=0.8: p^4=0.410 1-(1-p)^4=0.998
Note: numbers original run se hain; print labels Latin transliteration mein likhe gaye hain।
Neeche widget pass^k aur pass@k ko curves ki tarah draw karta hai, aur dikhta hai ki ek jaise average wale «concentrated» aur «spread» distributions ke pass^2 ulat hote hain.
Ek task ki single-run success 0.8 ho to independent-repetition assumption par 4 mein sab-safal ki probability lagbhag 0.41. Live system mein tasks ki difficulty alag hai - har task ka alag estimate chahiye।
Pehle per-task, phir average
τ-bench pass^k ko same task ki attempts sab-safal ki probability ke roop mein define karta hai, phir tasks par average. Total tasks. Task ne runs, safal - inmein se uthao sab-safal hone ka combination ratio:
Har task ke paas kam se kam trials hon chahiye; kam hon to aur chalao, ya us ka coverage clearly report karo. Sab tasks ko ek success count mein milana nahi; overall single-run success ko seedha power nahi. Neeche dono self-written task sets ka per-task rate 50% hai, par success distribution alag. Apple M2 Max, Python 3.12.14 se।
from collections.abc import Sequence
from math import comb
def pass_all(tasks: Sequence[Sequence[bool]], k: int) -> float:
"""Estimate task-average all-success probability."""
if k < 1 or not tasks or any(len(trials) < k for trials in tasks):
raise ValueError("need k >= 1 and at least k trials per task")
ratios = [comb(sum(row), k) / comb(len(row), k) for row in tasks]
return sum(ratios) / len(ratios)
concentrated = [(True, True), (False, False)]
spread = [(True, False), (False, True)]
assert pass_all(concentrated, 1) == pass_all(spread, 1) == 0.5
assert pass_all(concentrated, 2) == 0.5 and pass_all(spread, 2) == 0
for name, tasks in zip(('concentrated', 'spread'), (concentrated, spread)):
first, second = pass_all(tasks, 1), pass_all(tasks, 2)
print(f"{name}: k=1 {first:.0%}, k=2 {second:.0%}")
concentrated: k=1 50%, k=2 50%
spread: k=1 50%, k=2 0%
Note: numbers original run se hain; print labels Latin transliteration mein badle gaye।
Concentrated: ek task baar-baar sahi ho sakta hai; spread: har task kam se kam ek baar fail. High repeat-success sirf ek easy-task batch se bhi aa sakta hai - isliye task family aur difficulty ke hisaab se bhi report karo, task-level resampling se uncertainty estimate karo. Trials ek running environment share karte hon to pehle environment reset, phir independence baat karo।
Stateful grading: environment final state check
τ-bench-style support task: user eligible item return karna chahta hai; policy maangti hai pehle confirm, phir refund. Grader check karta hai: refund record exists aur state sahi; unrelated orders untouched; reply mein zaroori content; confirmation write se pehle hua. Aisi stateful grading “reply standard answer jaisa dikhta hai?” se bahut zyada reliable - agent ka object environment hai, text nahi।
Cost: per successful task
AI Agents That Matter accuracy aur cost saath compare karne ka argument deta hai. Product mein ek task ke planning, tool calls, retries, verification aur human remediation gino. Neeche is site ke self-written 100 tasks:
baseline: $1.50/successful task (80/100)
candidate: $1.20/successful task (75/100)
difference: 5 fewer successes, unit cost $0.30 lower
Candidate unit cost kam, par 5 safal kam; business floor 80% success hai to candidate fail. Agent options ko quality-cost poore frontier par compare karo, aur yeh bhi ki kaun se tasks gained/lost hue; “per-successful-task cost” success rate zero par undefined hai, aur yeh nahi batata kaun si task types degrade hui।
CS2680 course 48-item benchmark catalog maintain karta hai; core classification idea udhaar lo - fame se nahi, evaluate-what se:
| Category | Representative benchmarks | Kya evaluate, kaise grade |
|---|---|---|
| Interactive task completion | WebArena (2307.13854), OSWorld (2404.07972), GAIA (2311.12983), SWE-bench (2310.06770), Terminal-Bench, BrowseComp | Real web/desktop/repo environments mein task complete; final state ya artifacts check |
| Single-capability isolation | BFCL (tool selection), ToolSandbox (state-dependent tool use), LongMemEval (long-term memory), τ-bench / τ²-bench (2406.12045 / 2506.07982), AgentDojo (2406.13352), MultiAgentBench | Tool selection, memory, instruction-following alag-alag; precise, reproducible rules |
| Workflows aur outputs | MLE-bench, KernelBench, GDPval | End-to-end outputs (chalta hua model, kernel, docs) expert ya program se grade |
| Harder, fresher questions | GPQA, FrontierMath, HLE, LiveBench, ARC-AGI-3 | Contamination kam karta hai, par abhi bhi model evaluation ka extension - agent evaluation nahi |
Apne agent ke liye benchmark chunte waqt pehle apne product ke failure mode ka class diagnose karo, phir usse cover karne wala benchmark; aur grading protocol padho - same-name benchmarks ke versions mein tasks aur grading poori tarah alag ho sakte hain।
Traces se fix points dhoondo
Berkeley Advanced LLM Agents memory, planning aur multimodal interaction ko alag lectures mein rakhta hai. Scalable AI spring application assignment app quality aur system performance saath measure karne ko kehta hai. Ek hi sandbox task se in factors ko alag kiya ja sakta hai - jaise agent ko user ki saved preferences ke aadhar par simulated calendar mein specified meeting move karwana।
- Observation aur memory. Har run ko same calendar snapshot aur session history; retrieved preferences aur unke versions record. Sirf memory module switch karo; cross-session preference chahiye ya nahi uske hisaab se group karke report।
- Planning aur execution. Chuni gayi meeting aur tool ko diye times check. Tool timeouts ko same canned responses se replay; final state sahi? duplicate events bane?।
- Final results. Event IDs, times, participants aur bina-maange badle events check; call count, total time, per-success cost bhi record. Failure traces rakho; regression tests mein same initial states।
Pehle original system par baseline jama karo. Ek baar mein sirf ek cheez badlo - model, memory, planning ya tools - tabhi difference ko us change par attribute ho sakta hai।
Simulated calendar se grader validate karna
Neeche chaar hand-built traces - correct update, no update, duplicate event, aur galat event badalna. Apple M2 Max, Python 3.14.3; do grading rules; sirf standard Python।
before = [("standup", "09:00"), ("interview", "14:00")]
expected = [("standup", "10:00"), ("interview", "14:00")]
traces = [
(True, expected),
(True, before),
(True, expected + [("standup", "10:00")]),
(True, [("standup", "10:00"), ("interview", "15:00")]),
]
reported = sum(claim for claim, _ in traces)
verified = sum(sorted(events) == sorted(expected) for _, events in traces)
assert verified == 1 and reported == len(traces)
print(f"claimed success: {reported}/{len(traces)}")
print(f"final-state correct: {verified}/{len(traces)}")
claimed success: 4/4
final-state correct: 1/4
Note: numbers original run se hain; sample events Hindi/Latin transliteration mein badle gaye।
Do grading results ka gap demo traces ke design se aata hai. Lists compare karte waqt pehle sort - event order ki freedom, duplicates phir bhi pakde jaate hain. Asli calendar stable event IDs use kare, aur participants, timezone jaise success-affecting fields bhi check mein।
Common traps
- Harness drift: scaffolding (prompt templates, retry policy, tool descriptions) badla, score badla - tumhe laga model degrade hua. Mitigation: harness config version control mein; model change par harness freeze।
- Sirf ek run report karna: agent ka jitter single-turn QA se bahut zyada; ek run ka score bekaar. Kam se kam kai trials ka mean + spread; behtar pass^k।
- Environment non-resettable: tasks ke beech state leak; “pichhla answer yaad rakhna” capability ban jaati hai. Eval harness har trial se pehle reset kare।
- Grader exposed: reference answers ya grading logic model context mein aa gaye - score turant fake-high. Grading state eval harness ke paas।
- Task set training mein leak: agent traces garam commodity; benchmark tasks training set mein gaye to scores inflate (benchmark contamination wali hi logic)।
Summary aur exercises
- Agent evaluation = system x task distribution x protocol; harness system ka hissa; do harnesses ki zimmedari alag; system-under-test grader ko touch nahi kar sakta।
- Metrics mein reliability (pass^k) > ceiling (pass@k); cost per successful task, par success rate aur latency ke saath।
- Benchmarks “kya evaluate” se chuno; score se pehle protocol padho।
Quick self-test
1. Same model, nayi prompt template aur retry policy - agent benchmark score kaisa ho sakta hai?
- Kaafi badal sakta hai - score “model + scaffolding + protocol” poora system naapta hai
- Same rahega - score sirf model parameters par hai
- Sirf behtar hoga, bura nahi ho sakta
Harness system ka hissa hai. Systems compare karte waqt protocol fix aur config clear।
2. Single-run success 0.8 wale task ke 4 lagatar trials sab-safal hone ki probability lagbhag?
- 0.8
- 0.998
- 0.41
pass^k (har baar safal) = 0.8^4 lagbhag 0.410; 0.998 “at least one success” hai. Deployment pehla dekhta hai।
3. τ-bench-style stateful grading mainly kya check karta hai?
- Environment final state (refund record, unrelated orders untouched) aur operation order (confirmation write se pehle)
- Reply aur reference answer ki semantic similarity
- Trace mein thinking steps ki lambai
Agent ka object environment hai. Final state + constraint order seedha check karne se “muh se bola, waqai kuch nahi kiya” wala grading loophole band hota hai।
4. Candidate agent option ka per-successful-task cost kam hai - kya wohi better hai?
- Haan - cost hi ek maatra decision metric hai
- Zaroori nahi: success rate kam ho sakta hai, key tasks kho sakte hain; cost ko success rate aur latency ke saath dekho
- Cost kam hai to success rate automatically zyada
Is page ka demo: 1.50 per success, par candidate 5 tasks kam safal - business floor toot sakti hai।
5. Har trial se pehle environment reset kyun zaroori?
- Tasks ke beech state leak na ho; “pichhla answer yaad” ko capability na samajh lein
- Traces lambe banane ke liye
- Compute bachane ke liye
Reset guarantee deta hai har trial same task test kar raha hai; state leak se results unexplainable।
Exercises
- Apna aam agent-type app chuno (support ya coding assistant), uska cost ledger template likhein: har episode par kaun se fields (model calls, cache hits, tool fees, human remediation…)?
- Do agent benchmarks jo aap matter karte hain chuno; har ek ke liye teen lines mein likho “system kya receive karta hai, kya karta hai, grader kya check karta hai”; phir judge karo kaun se failure modes cover, kaun se miss।
Reference answer (exercise 1 ke key fields):
Expand karein
Har model call: model name, role (main loop / planning / compression / verification), input/output tokens, cache hit; tool calls: naam, count, cost; episode-level: total latency (p50/p95), retry count, ending (success/fail/timeout), human intervention time. Summary metrics: verified success rate, total spend / successful tasks, per-attempt cost, cost distribution across tasks. Offline costs (teacher traces, fine-tuning, evaluation itself) alag ledger - per-call mein spread na karein।
Aage padhein
- Anthropic, Demystifying evals for AI agents aur Building effective agents: is page ke episode conceptual model ke sources।
- Yao adi, τ-bench (2024); Si adi, τ²-bench (2025): stateful grading aur pass^k ke landmark works।
- Kapoor adi, AI Agents That Matter (2024): cost accounting aur “quality-cost frontier” ka argument।
- Liu adi, AgentBench (2023); Zhou adi, WebArena (2023); Jimenez adi, SWE-bench (2023); Mialon adi, GAIA (2023); Xie adi, OSWorld (2024): interactive environment benchmarks ke chaar task formats।
- Debenedetti adi, AgentDojo (2024): agent ki safety aur utility ka joint eval; bhi dekhein prompt injection aur jailbreaks।
- Course notes: Harvard CS2680 ke “Agent Evaluation and Benchmarks” aur “Cost-effective Agents” (2026); is page ki benchmark classification aur cost framework inhi dono se borrowed hai।
अक्सर पूछे जाने वाले सवाल
- Same model doosre agent harness mein dalein to score badlega?
- Haan, aur aksar model badalne se bhi zyada. Score "model + prompt + memory + tool interface + control loop + execution environment" ka fixed protocol ke under performance naapta hai; tool descriptions badalne, retry budget badalne, stop conditions badalne - sab score badalta hai. Isliye do systems compare karte waqt protocol fix karo, aur report mein harness config clear likho।
- pass^k aur pass@k ka farq?
- pass@k poochhta hai "k samples mein best wala safal maane?" - capability ceiling; pass^k poochhta hai "same task independently k retries - har baar safal tabhi pass" - reliability. Deployed agents par users baar-baar use karte hain - har ek failure asli loss hai - isliye agent scenarios pass^k dekhte hain।
- τ-bench DB state check karta hai, sirf reply nahi - kyun?
- Kyunki agent ka object environment hai. "Refund ho gaya" muh se bola ja sakta hai, ya DB mein waqai ek sahi-state refund record ho, unrelated orders untouched hon, confirmation write se pehle hua ho. Stateful grading seedha final state aur constraint order check karta hai - "reply padhne mein sahi, waqai kuch sahi nahi" wala loophole band।
- Per-successful-task cost kam hai to wohi option chun lein?
- Hamesha nahi. Is site ka demo: 100 tasks par baseline $120 mein 80 safal ($1.50/safal), candidate $90 mein 75 safal ($1.20/safal). Candidate ki unit cost kam, par 5 safal tasks kam; business ko 80% success rate chahiye to candidate hi fail. Cost metric success rate ke saath, aur yeh bhi ki kaun se tasks degrade hue।
- Agent benchmarks itne hain - kaise chunein?
- Pehle "kya evaluate hota hai" se classify: interactive environments jo real tasks karte hain (WebArena, OSWorld, SWE-bench); isolated single capabilities (tool selection, memory, instruction-following); workflow outputs (MLE-bench). Phir apne product ke failure modes kis class ke hain - us class ko cover karne wala benchmark chuno, aur grading protocol padho - same naam ke versions aur rules bilkul alag ho sakte hain।