professional-services / agent-eval
CLAUDE.md3.1k starsChanged 3 months agoApache-2.0View on GitHub
This file provides context for Claude Code. It is loaded automatically when you run claude from a project that uses agent-eval. agent-eval is an evaluation CLI for ADK agents. It acts as the glue between OpenTelemetry traces from ADK, Vertex AI Evaluation for LLM-as-judge metrics, and Gemini for analysis. The evaluation cycle: 1. Generate — Generate agent traces via agent-eval generate (using --mode simulate for UserSim multi-turn or --mode live for DIY single-turn; aliases simulate and interact are supported). 2.…
- Reads credentials
- Deletes or force-pushes
Trending
Quiet this year.thin dataabout the whole repository
Who's talking about GoogleCloudPlatform/professional-services
- googleapis/google-api-nodejs-client“Support Google Workspace Impersonation Without Service Account Key”GitHub · Feb 2, 2022 · 4 reactions
- googleworkspace/python-samples“admin-sdk report_v1 : Client secret must be for a web or installed app”GitHub · Jul 22, 2020
The biggest 2 of 2 mentions linking to the repository that our crawl found. Each line is their own headline.
In this repository3 other files it gives its agents.
- agent-evalSkill
- agent-eval-workflowSkill
- eval-breakdownSkill
The file
We split this CLAUDE.md into the rules it gives an agent
3 rules. About 0 are common, 1 is distinctive, and 2 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈1
Distinctive · estimate
This author's own choices. Worth a look.
2
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 142
Every entry MAY carry these optional fields:
- Very specific: line 157
Manual creation: Write entries directly in metric_definitions.json matching the schema above.
- Very specific: line 240
Clear eval_history: before each ADK User Sim run — generate --mode simulate (or simulate) does this automatically.
≈ “Common” is an estimate: at least 1 in 5 of the 12,729 CLAUDE.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
agent-eval — AI Assistant Context
This file provides context for Claude Code. It is loaded automatically when you run
claudefrom a project that usesagent-eval.
What is agent-eval?
agent-eval is an evaluation CLI for ADK agents. It acts as the glue between OpenTelemetry traces from ADK, Vertex AI Evaluation for LLM-as-judge metrics, and Gemini for analysis.
The evaluation cycle:
- Generate — Generate agent traces via
agent-eval generate(using--mode simulatefor UserSim multi-turn or--mode livefor DIY single-turn; aliasessimulateandinteractare supported). - Grade — Score traces via
agent-eval grade(or aliasevaluate) with deterministic metrics (latency, tokens, cost) + LLM-as-judge metrics (quality, accuracy) - Analyze — Generate AI-powered root cause analysis
Context Engineering Principles guide optimizations:
- Offload: Move deterministic logic out of the LLM into tools/code
- Reduce: Summarize or compact stale context to prevent "context rot"
- Retrieve: Replace static knowledge with RAG
- Isolate: Split monolithic agents into specialized sub-agents
- Cache: Restructure prompts for prefix caching
Typical Project Structure
agent-eval init writes ONE unified tests/eval/ folder at the agent project root (the directory with pyproject.toml) — NEVER inside the agent module. There is one source of truth — tests/eval/dataset.jsonl — that feeds every command:
generate --mode simulate(orsimulate) reads multi-turn rows (rows withhistoryorconversation_plan)generate --mode live(orinteract) reads single-turn rowsagent-enginereads single-turn rows (skips multi-turn with a clear pointer atgenerate --mode simulate)grade(orevaluate) consumes whichever interaction/traces file the previous step wrote
my-agent/
├── my_agent/ # ADK agent source code
│ ├── agent.py
│ ├── tools/
│ └── ...
├── tests/eval/ # Unified — ONE source of truth
│ ├── dataset.jsonl # All rows (prompt / response / reference / history / intermediate_events / session_inputs / expected_*)
│ ├── metrics/metric_definitions.json # LLM-as-judge metric rubrics
│ └── results/ # Evaluation outputs (eval_summary.json, gemini_analysis.md, ...)
├── pyproject.toml
└── .envADK's adk eval runtime expects conversation_scenarios.json, session_input.json, and eval_config.json next to agent.py. agent-eval generate --mode simulate (or simulate) projects those from dataset.jsonl at run time and writes them inside my_agent/ as ephemeral cache (gitignore them). Users never edit those files — they edit dataset.jsonl.
Migrating an old project? Run
agent-eval migrateto fold every legacy location into the unified file:
<agent>/eval/scenarios/conversation_scenarios.json(legacy UserSim)<agent>/eval/eval_data/golden_dataset.json(legacy DIY)<agent>/eval/metrics/metric_definitions.json(relocated to<project_root>/tests/eval/metrics/)<agent>/tests/eval/dataset.jsonl(the wrongly-placed F3 location from pre-rescue scaffolds — folded into the canonical project-root location, source removed) Originals are copied to<project_root>/tests/eval/.backup/<timestamp>/first.
CLI Commands
| Command | Purpose |
uv run agent-eval setup | Walk gcloud auth, ADC, project + location, Vertex AI API enablement, autorater IAM (run once per shell) |
uv run agent-eval init | Scaffold eval files (with optional AI metric generation via --ai-metrics) |
uv run agent-eval migrate | Fold legacy eval/scenarios/ + golden_dataset.json AND any wrongly-placed <agent>/tests/eval/dataset.jsonl (F3) into the canonical <project_root>/tests/eval/dataset.jsonl. Idempotent. |
uv run agent-eval import --from <evalset>.json | Flatten an ADK .evalset.json file into tests/eval/dataset.jsonl |
uv run agent-eval run | Full pipeline: generate + grade + compare + analyze |
uv run agent-eval generate | Generate traces: --mode simulate (UserSim, multi-turn) or --mode live (DIY, single-turn) |
uv run agent-eval grade | Grade traces with deterministic + LLM-as-judge metrics |
uv run agent-eval compare | Head-to-head delta comparison between candidate and baseline runs |
uv run agent-eval optimize | GEPA evolutionary prompt optimization |
uv run agent-eval analyze | Generate AI-powered analysis reports |
uv run agent-eval convert | Convert ADK traces to evaluation format (used by generate) |
uv run agent-eval create-dataset | Convert ADK test files to golden dataset format |
uv run agent-eval dashboard | Launch interactive Gradio dashboard for comparing runs |
Common Tasks You Should Help With
Interpreting Evaluation Results
eval_summary.json→ Aggregated metrics (start here)gemini_analysis.md→ AI root cause analysisquestion_answer_log.md→ Per-question detailed breakdown with scores
Debugging Evaluation Issues
- Use
--debugon any command (run,generate,grade,compare,optimize,analyze,simulate,interact,evaluate) to see detailed logs from ADK, Vertex AI SDK, and other services. By default, third-party logs are suppressed to keep the CLI output clean —--debugopens the floodgates. - Auth issues? → Re-run
agent-eval init— it verifies project ID, ADC, API enablement, and quota project automatically - Zero token usage →
app_nameinsession_input.json(the cached file projected fromdataset.jsonl) doesn't match the agent module folder name. Fix thesession_inputsfield in yourdataset.jsonlrow, not the cache. - Multi-turn metric
SKIPPED — no rows have required capabilities: multi_turn→ expected when your dataset has no rows withhistoryorconversation_plan. Add multi-turn rows or just remove the metric. simulatedies atModuleNotFoundError: No module named 'app'→_clean_envis supposed to putproject_rootonPYTHONPATH. If this regresses, checkcli/commands/simulate.py:_clean_env.agent-enginefirst run errorsProject may not create storageClass STANDARD buckets with locationConstraint GLOBAL→_resolve_bucket_locationshould have mappedglobal→us-central1. If this regresses, checkcli/commands/agent_engine.py:_resolve_bucket_locationand the--bucket-locationflag.- Empty metrics → Using
GOOGLE_API_KEYinstead of Vertex AI; setGOOGLE_CLOUD_PROJECTinstead - Permission denied on autorater → Grant
roles/aiplatform.serviceAgentto the AI Platform service account - Failed metric in eval table → the
Reasons:block under the table shows the actual exception class. NEVER tell the user it's an "API rate limit" without checking — that was the F1 demo lie.
Creating Custom Metrics
Metrics live in <project_root>/tests/eval/metrics/metric_definitions.json. The schema is the canonical Vertex AI Gen AI Eval SDK schema — six kind values that mirror the docs exactly. See core/metric_schema.py for the single-source-of-truth spec.
The six metric kinds (from docs/determine-eval)
kind | SDK call | When to use |
managed | types.RubricMetric.<NAME> | Vertex's predefined rubrics (GENERAL_QUALITY, SAFETY, FINAL_RESPONSE_MATCH, etc.) — ~17 metrics, see docs/rubric-metric-details |
parametrized_managed | types.RubricMetric.<NAME>(metric_spec_parameters={"guidelines": "..."}) | Same predefined rubrics with custom guidelines or rubric_groups overlay |
custom_llm_judge | types.LLMMetric(name=..., prompt_template=types.MetricPromptBuilder(instruction=..., criteria={...}, rating_scores={...})) | Agent-specific behaviors. Default to binary rating_scores={"1":..., "0":...} |
computation | types.Metric(name='bleu' | 'rouge_l' | 'exact_match') | Deterministic algorithms (BLEU/ROUGE/exact_match/tool_*) |
python_function | types.Metric(custom_function=callable) | Local Python check returning {"score": float} |
remote_code | types.Metric(remote_custom_function=code_str) | Sandboxed code snippet executed by Vertex |
metric_factory.build_metric(name, spec) is the single dispatch — both evaluator.py (local) and agent_engine.py (managed) route through it.
Custom LLM judge — the canonical pattern
{
"cites_source_when_required": {
"kind": "custom_llm_judge",
"instruction": "Evaluate whether the agent cited a source for any factual claim.",
"criteria": {
"factual_claim_present": "Response contains at least one factual claim about a date, person, policy, or number.",
"citation_present": "Each factual claim is followed by a citation (URL, doc id, or 'per <source>')."
},
"rating_scores": {
"1": "Pass: every factual claim has a citation, OR no factual claims",
"0": "Fail: at least one factual claim is missing a citation"
},
"requires_reference": false // optional — agent-eval extension for per-row routing
}
}Default to binary 0/1 rating_scores. LLM judges have poor inter-rater reliability on multi-point scales. Multi-tier (1-5) is structurally valid (the docs' simplicity_metric example uses it) but only when (a) the criterion truly cannot be decomposed AND (b) you can write a sentence per integer with observable anchors. Decompose, don't tier — multiple sharp binary metrics > one fuzzy multi-tier metric. Aggregating binary signals over a dataset (% pass rate) IS your continuous score with better statistical properties.
The criteria dict is a list of yes/no observables the judge evaluates. The rating_scores dict maps integer-as-string keys to score descriptions. instruction is one sentence on what to evaluate overall.
agent-eval extras (orthogonal to the SDK schema)
Every entry MAY carry these optional fields:
requires_reference: true— only run on rows whosereference_dataslot is populated (golden-style rows).requires_multi_turn: true— only run on rows with multi-turn history.dataset_mapping: {...}— projects ADK trace columns into the SDK's per-metric column names. Mostcustom_llm_judgemetrics don't need this — defaults frommetric_schema.SDK_COLUMN_DEFAULTS(prompt←user_inputs[-1],response←final_response) work. Add only when you need a specific source column (e.g.extracted_data:tool_interactions).reference_field: "<name>"— for managed metrics that consumereference, names which slot inreference_datato compare against.
requires_multi_turnandrequires_referenceCOMPOSE. The evaluator routes per-row: a row withhistory/conversation_planAND populatedreference_datamatches a metric flagging both. Use this for "judge the trajectory AND compare the final answer to a reference" (e.g., RAG agents that should both navigate clarification AND land on the right answer). The data generator (Gemini Call 3) emits both shapes; for the both-flags combo it adds areference_datablock to multi-turn scenarios. Sim trace conversion preservesreference_databy joining the trace's first user message back to the sourcedataset.jsonlrow'sprompt(seeAdkHistoryConverter.prompt_to_reference).
Per-row routing inspects the row's actual columns via dataset_io.detect_capabilities — mixed-capability datasets just work.
How to create them
- AI generation (recommended):
agent-eval init→ "Generate with AI". Gemini analyzes agent code, picks managed metrics, generates 2-4 binarycustom_llm_judgemetrics tailored to the agent's tools/state/behaviors. The generator prompt enforces the canonical schema and the binary preference. Re-runninginitpreserves existing metrics. Manual edits during the iterative review pause flow forward to dataset generation. - Manual creation: Write entries directly in
metric_definitions.jsonmatching the schema above. The validator (metric_generator._validate_single_metric) checkskind, per-kind required fields,rating_scoresshape (integer-as-string keys), anddataset_mappingsource column validity.
The validator + factory share the same
core/metric_schema.pyconstants (ALL_KINDS,REQUIRED_FIELDS,SDK_COLUMN_DEFAULTS,MANAGED_METRIC_REQUIRED_COLUMNS). When the schema evolves, change one place.
Diagnosing Agent Issues from Metrics
| Signal | Metric to Check | Fix |
| Agent invents capabilities | custom: capability_honesty < 3.0 | Add **KNOWN LIMITATIONS** to tool docstrings |
| Agent takes wrong paths | custom: trajectory_accuracy < 3.0 | Isolate into specialized sub-agents |
| Tools called with bad args | managed: TOOL_USE_QUALITY < 3.0 | Add Pydantic schemas, stricter types |
| High latency, bloated context | deterministic: prompt_tokens > 10,000 | Compact stale tool outputs, offload to disk |
| Agent fabricates data on failure | custom: pipeline_integrity < 3.0 | Add circuit breaker checks |
| Low cache hits | deterministic: cache_hit_rate < 50% | Put static instructions in global_instruction |
The
analyzecommand includes ADK-specific design patterns in its Gemini prompt, enabling actionable recommendations mapped to the five Context Engineering Principles. The patterns are insrc/agent_eval/core/adk_optimization_patterns.py.
Creating Optimization Logs (Comparing Results)
The analyze command automatically creates and maintains OPTIMIZATION_LOG.md in the parent results directory. Every time you run analyze, it:
- First run: creates a baseline entry (Iteration 1)
- Subsequent runs: auto-detects the previous run, computes deltas, and appends a new iteration with metric changes, git diff info, and Gemini's comparison summary
# First run — creates baseline entry
uv run agent-eval analyze --results-dir eval/results/baseline --agent-dir ./my_agent
# Second run — auto-compares to baseline, appends Iteration 2
uv run agent-eval analyze --results-dir eval/results/v2 --agent-dir ./my_agent
# Override which run to compare against
uv run agent-eval analyze --results-dir eval/results/v3 --compare-to eval/results/v1
# Highlight specific metrics in the terminal table
uv run agent-eval analyze --results-dir eval/results/v2 --focus "latency, cache"For manual optimization logs (e.g., when using an AI assistant to create a more detailed log), use this prompt structure:
Role: You are a Senior Agent Architect and QA Analyst.
Objective: Update the OPTIMIZATION_LOG.md to document whether the applied strategy worked.
Inputs:
1. Strategy Applied: [e.g., "Iteration 1: Tool Hardening"]
2. New Evaluation Data: [metrics from eval_summary.json]
3. Qualitative Analysis: [key insights from gemini_analysis.md]
4. Current Log: [current OPTIMIZATION_LOG.md content]
Instructions:
1. Update Metrics Table: Calculate deltas. Use [+] (improvement) / [-] (regression) / [=] (neutral).
2. Append Iteration History:
- Optimization Pillar: (Offload, Reduce, Retrieve, Isolate, Cache)
- Analysis of Variance: Did quality/trust/scale improve? Quote specific metrics.
- Evidence: Extract 1-2 specific examples from the analysis.
- Conclusion: One sentence on the strategic pivot for the next step.Metric Types
Deterministic (auto-extracted from traces, same for all agents):
token_usage.*— total tokens, prompt tokens, estimated costlatency_metrics.*— total seconds, avg turn latency, first responsecache_efficiency.*— hit rate, cached vs fresh tokenstool_success_rate.*— success rate, failed callsthinking_metrics.*— reasoning ratio
LLM-as-Judge (configured per agent in metric_definitions.json):
- Scores defined by the user's metric templates
- Common ones:
trajectory_accuracy,tool_use_quality,general_quality,safety
Status Indicators
- [+] = Improvement (lower tokens/latency OR higher quality scores)
- [-] = Regression
- [=] = Neutral
Critical Reminders
- Always use Vertex AI, not API keys (evaluation won't work otherwise)
- Clear eval_history before each ADK User Sim run —
generate --mode simulate(orsimulate) does this automatically; if running manually:rm -rf <agent_module>/.adk/eval_history/* - Location is auto-configured — Gemini 3+ models use
globalautomatically viaget_location()in config.py. Override with--locationif needed app_namemust match the folder name containingagent.py, not the agent's display name- Both surfaces (local
evaluator.pyANDagent_engine.py) dispatch throughmetric_factory.build_metric(name, spec)— single source of truth for the canonical schema. Don't reintroduce inlinetypes.LLMMetric(prompt_template=template_string)or syntheticcriteria={"evaluation": template}cargo-cult constructions. If a metric kind isn't routing correctly, fixbuild_metric(and the schema incore/metric_schema.py), not the call sites. AGENT_EVAL_NO_PAUSES=1covers both_continuepauses and thegenerate/simulateRun ID prompt. Any new interactivePrompt.ask/questionary.*call must guard on_pauses_disabled()(or accept a non-interactive default) so CI runs don't deadlock.agent-engineauto-creates the destination GCS bucket in--locationif it doesn't exist (usesgoogle.cloud.storage.Client.create_bucket). Don't duplicate that logic elsewhere — and don't remove it; first runs depend on it.agent-enginefollows the docs'evaluation-agents-clientpattern —Client(..., http_options=HttpOptions(api_version="v1beta1")), builds anAgentInfofrom a locally-importedroot_agent(defaultapp.agent:root_agent, override via--agent-module), and passes it tocreate_evaluation_run._build_agent_infofalls back to manual construction with emptytool_declarationswhenAgentInfo.load_from_agenttrips on ADK'stool_context(a known SDK ↔ ADK schema bug). Don't replace this with the original "submit-only + parse-error" flow — withoutagent_infothe run lands inFAILEDwith empty event lists.- SDK pin:
google-cloud-aiplatform[evaluation,agent-engines]>=1.132.0,<1.140.0. Versions ≥1.140 changed theAgentInfoschema (dropsagent_resource_name, requiresagents/root_agent_idmap) AND tightenedAgentDatavalidation inrun_inferenceto reject ADK's rich event fields. Bumping past this needs theagent_engine.pyhelpers to be re-tested. - Local pipeline is the default; Agent Engine is purely additive.
initauto-detects what's available — localagent.pyenables the local pipeline (generate/simulate+grade/evaluate+analyze); a deployed Agent Engine adds the streamlinedagent-enginepass on top. They compose, they don't compete. UserSim works against any locally-importedagent.pyregardless of deployment status. Never reintroduce a "Path A vs Path B" chooser — it's a phantom choice. - One source of truth —
<project_root>/tests/eval/dataset.jsonl. Every command consumes this single file.generate --mode simulatefilters multi-turn rows;generate --mode liveandagent-enginefilter single-turn rows. ADK's required scenario files insideapp/are an ephemeral cache projected fromdataset.jsonlbygenerate --mode simulate, not a parallel data source. NEVER re-introduceeval/scenarios/oreval/eval_data/as user-edited locations. NEVER writetests/eval/inside the agent module dir — always at the project root viaagent_project_root(agent_dir)incore/path_resolver.py. - FLATTEN schema canonical column names:
prompt,response,reference,history(NOTconversation_history),instruction,intermediate_events,rubric_groups. Plus arbitrary extras asEvalCasepass-through. See~/.claude/projects/.../memory/vertex-eval-sdk-schema.md. The olddataset-mapping-constraint.md"only 3 columns" claim is superseded.
12b. metric_definitions.json schema is the canonical Vertex SDK schema — six kind values mirror the docs. See core/metric_schema.py (single source of truth) and the "Creating Custom Metrics" section above. The six kinds: managed, parametrized_managed, custom_llm_judge, computation, python_function, remote_code — all from docs/determine-eval. Custom LLM judges use instruction + criteria (dict) + rating_scores (dict, integer-as-string keys), built via types.MetricPromptBuilder. Default to binary rating_scores={"1":..., "0":...} for new custom metrics (consistent with the docs' static rubric managed metrics; better inter-rater reliability than multi-tier). The legacy is_managed / managed_metric_name / template / score_range fields are gone — metric_factory.build_metric rejects entries without kind.
13. Bucket location is decoupled from Vertex eval location. Gemini 3+ defaults the eval --location to global, which GCS rejects for STANDARD-class buckets. _resolve_bucket_location in agent_engine.py maps global → us-central1 (or whatever --bucket-location overrides to). NEVER pass vertex_location straight to storage.create_bucket(location=...) — that was the F5 demo failure.
14. The end-of-run banner reflects reality. If any phase failed or any metric is in failed_metrics, the banner reads Pipeline finished with errors with red border and per-phase pass/fail markers. NEVER print "Pipeline complete!" green when phases failed — that was the F4 demo lie. Same for the failure copy in the eval table — show the real exception class, never "API rate limits" without verifying.
15. "Shipped" = end-to-end smoke against a real ADK agent + pytest. Both, not either. Pytest didn't catch any of the eight 2026-04-23 demo failures. The smoke test at tests/test_rescue_smoke.py guards the request shape, the bucket location, the scaffold layout, and the unified-dataset filtering — anything claimed shipped must have a corresponding contract assertion or an end-to-end run. Hard rule in ~/.claude/projects/.../memory/shipped-means-end-to-end-not-pytest.md.
16. Path A / Path B are forbidden in user-facing strings. They're internal chosen_paths enum keys only. The vocabulary leaked through three iterations of "Phase 7" cleanup before B2 finally swept and added tools/check_no_path_ab.sh + a pytest guard at tests/test_no_path_ab_in_user_facing.py. CLAUDE.md / GEMINI.md / docs/tmp/ historical drafts are allow-listed; everything else trips the guard.
17. Always validate remote version before release & follow SemVer. Always verify the latest remote tags/branches and package version in pyproject.toml against upstream releases before publishing or creating release PRs. Follow semantic versioning strictly (patch for fixes, minor for additive features like OpenInference conversion or new metric kinds, major for breaking changes) as external developer and production adoption grows.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

