npx skills add ...
npx skills add google/skills --skill agent-platform-eval-flywheel
Measures and improves the quality of AI models and agents on Google Cloud using the Eval Quality Flywheel methodology. Use when evaluating an agent or model, building an eval dataset, picking or writing evaluation metrics, analyzing failures, comparing results before and after a fix, or when guidance is needed on Agent Platform eval methodology — including dataset schema, LLM-as-judge scoring, and common failure causes. For fine-tuning, use agent-platform-tuning. For general production deployment, use agent-platform-deploy.
npx skills add google/skills --skill agent-platform-eval-flywheel
Help users evaluate and iteratively improve GenAI models and agents using the
Agent Platform GenAI Evaluation SDK (google.genai / agentplatform).
client.evals.evaluate()).endpoint_evaluation.py / maas_evaluation.py scripts.Before executing any commands or scripts on behalf of the user, you MUST adhere to the following safety tiers based on the action requested:
inspect_results.py, compare_results.py,
validate_dataset.py, parse_adk_traces.py, render_html_report.py)
client.evals.run_inference,
client.evals.evaluate, client.evals.generate_conversation_scenarios,
client.evals.generate_loss_clusters)
The scripts need vertexai (from google-cloud-aiplatform[evaluation]),
google-genai, pandas, and requests. Do not create a virtual
environment — it starts empty and hides packages the environment already
provides, forcing a redundant install. Probe, and install only what is missing:
The version specifiers must stay quoted: unquoted, bash reads >=1.154.0 as a
redirect and silently writes an empty file instead of constraining the install.
Need GOOGLE_CLOUD_PROJECT and GOOGLE_CLOUD_LOCATION. Check env vars first;
if missing, ask the user. Newer Gemini models often need location="global".
Two imports that look plausible and are not:
from agentplatform.types import evals -- ModuleNotFoundError. types is
a module, not a package; use from agentplatform import types.from vertexai.evaluation import PointwiseMetric, EvalTask -- the
superseded SDK. Its classes take different arguments (PointwiseMetric has
no system_instruction), so code written against it fails with TypeError
rather than an import error. Use agentplatform throughout.Five stages, run in order on the first pass, then loop 2 → 5 until quality targets are met.
| Shortcut | Why it fails |
|---|---|
| "I'll tune the metric threshold down | Hides real failures. Fix the agent, |
| : so it passes." : not the bar. : | |
| "This case is flaky, I'll skip it." | Flakiness reveals non-determinism in |
: : the agent. Fix with temperature=0 : | |
| : : or stricter instructions. : | |
| "I just need to fix the eval | If expected outputs keep moving, the |
| : dataset, not the agent." : agent has a behavior problem. : | |
| "I can tell from the trace it works | Self-grading doesn't generalize. |
: — skip Stage 3." : Always run evaluate() and read : | |
| : : scores. : | |
| "One iteration is enough." | Expect 5–10+ iterations. Stopping |
| : : early leaves regressions on other : | |
| : : metrics undetected. : |
Produce an EvaluationDataset. There are three input shapes, pick the one that
matches the data the user already has:
EvalCase list (single-turn or multi-turn):
Multi-turn agent traces wrap each conversation in AgentData →
ConversationTurn → AgentEvent. See
references/dataset_schema.md for the full
type hierarchy.
Pandas DataFrame (tabular sources — CSV, BigQuery, Sheets):
Column names must match the fields the chosen metrics expect (see references/dataset_schema.md for the per-metric requirements table).
Cold start (no data at all): synthesize scenarios server-side with
client.evals.generate_conversation_scenarios(agent=..., config=...) -- the
parameter is agent or agent_info, not agents, and config is
required. The config class is types.evals.UserScenarioGenerationConfig,
not types.UserScenarioGenerationConfig. Set its user_scenario_count
(1-100): it defaults to None, the client accepts that, and the server
rejects the call with 400 INVALID_ARGUMENT. count is a separate field
and does not substitute for it. Stage 2 plays the scenarios out.
Managed Agents (Gemini Agents API): evaluate agents created with the
Managed Agents API.
Use generate_conversation_scenarios to create test scenarios from the
agent's configuration, run_inference to execute the agent, and evaluate
to score the traces. These functions now accept managed agents and
interaction ids as input. You can also evaluate existing interactions
recorded via the Interactions API using InteractionsDataSource. See
references/sdk_patterns.md Pattern 8 for the
full code pattern.
For ADK session dumps, use scripts/parse_adk_traces.py instead of writing the
conversion by hand.
Populate responses/traces on the dataset. Skip this stage if traces are already complete (e.g., production logs or replay).
Pick metrics by what you want to measure. Full catalog in references/metric_registry.md.
Agent metrics (multi-turn, adaptive rubrics) — start here for agent eval.
| Goal | Metric |
|---|---|
| Did the agent achieve the user's goal? | multi_turn_task_success |
| Was the reasoning path logical and efficient? | multi_turn_trajectory_quality |
| Tool/function calling quality across turns | multi_turn_tool_use_quality |
| Overall conversational quality | multi_turn_general_quality |
| Final response quality (no reference needed) | final_response_quality |
| Final response vs. a golden reference | final_response_match |
| Single-turn tool use | tool_use_quality |
General quality metrics (single-turn, adaptive rubrics) — for model eval.
| Goal | Metric |
|---|---|
| Overall response quality (recommended starting point) | general_quality |
| Linguistic quality (fluency, coherence, grammar) | text_quality |
| Adherence to specific constraints / instructions | instruction_following |
Static rubric metrics (fixed criteria) — apply alongside the above.
| Goal | Metric |
|---|---|
| Catch hallucinated claims (RAG, factual answers) | hallucination |
| Factuality / consistency against provided context | grounding |
| Safety policy compliance | safety |
Domain-specific check no built-in covers: write a custom metric.
types.RubricMetric.<NAME> — server-side AutoRater, no
judge model needed.types.LLMMetric with prompt_template or
types.MetricPromptBuilder for structured rubrics. Always set
judge_model; it defaults to None and every case then fails with 400 INVALID_ARGUMENT: Error parsing JSON.types.CodeExecutionMetric with a custom_function string
containing def evaluate(instance: dict) for remote sandboxed execution; or
types.Metric with custom_function=<callable> for local execution.Always persist the result so Stage 4 and 5 can read it. Save both JSON (machine-readable, diffable) and HTML (human-readable, linkable):
Or after the fact: scripts/render_html_report.py --type evaluation or
scripts/inspect_results.py --save-html.
Read summary_metrics and eval_case_results — never fabricate scores. Use
scripts/inspect_results.py --failing-only to filter to failures.
For each failed metric, see references/failure_patterns.md for deeper diagnoses. The compact mapping:
| Failing metric | What to change |
|---|---|
multi_turn_task_success low | The agent isn't completing the goal — |
| : : fix orchestration, missing tool calls, : | |
| : : premature termination, wrong tool : | |
| : : selection. : | |
multi_turn_trajectory_quality low | The agent reaches the goal |
| : : inefficiently — refine planning : | |
| : : prompts, remove redundant tool calls. : | |
multi_turn_tool_use_quality low | Fix tool descriptions, parameter |
| : : docstrings, or agent instructions for : | |
| : : tool selection. : | |
final_response_quality low | Read auto-generated rubric verdicts; |
| : : refine instructions to address the : | |
| : : worst-scoring criterion. : | |
final_response_match low | The agent's final answer doesn't match |
| : : the golden reference — adjust response : | |
| : : format or update the reference. : | |
hallucination low | Tighten instructions to stay grounded |
| : : in tool output; verify the tool : | |
| : : actually returned the claimed data. : | |
grounding low | The response contradicts the provided |
| : : context — add explicit "cite only from : | |
| : : context" instructions. : | |
safety low | Add safety guardrails; review the |
| : : violating content category in the : | |
| : : rubric verdict. : | |
general_quality / text_quality | Adjust system instruction wording; the |
| : low : model's default phrasing is too : | |
| : : generic for the task. : | |
instruction_following low | The agent is ignoring constraints — |
| : : restate them in the system instruction : | |
| : : or use stricter wording. : | |
| Agent calls wrong tools | Fix tool descriptions, agent |
: : instructions, or tool_config. : | |
| Agent calls extra tools | Add explicit stop instructions, or |
| : : switch to : | |
: : multi_turn_tool_use_quality to : | |
| : : surface the extra calls in the rubric. : |
For 10+ failures on the same metric, use the Error Analysis service to cluster failures into themes (L1/L2 taxonomy categories) instead of reading every trace:
Save response.model_dump_json() and render with scripts/render_html_report.py --type loss-analysis.
Apply a fix targeting the failing metric. Re-run Stage 3. Compare with
scripts/compare_results.py --baseline <prev> --candidate <new> to confirm the
target improved AND no other metric regressed.
Track progress across iterations:
| Iteration | Metric A | Metric B | Change made |
|---|---|---|---|
| Baseline | 0.62 | 0.55 | — |
| v2 | 0.78 | 0.68 | Added grounding prompt |
| v3 | 0.81 | 0.72 | Fixed tool selection |
Expect 5–10+ iterations per failing case. Only after a case passes should you expand coverage with more eval cases.
Never claim eval results you didn't read from an actual result object.
summary_metrics table
(scripts/inspect_results.py).scripts/compare_results.py.If you can't produce the evidence (SDK call failed, result truncated, metric unsupported), say so explicitly. Don't paper over gaps.
<plan> block
detailing the steps you are about to take.import agentplatform,
from google.genai import types). Don't use internal import paths.See references/sdk_patterns.md for advanced
patterns: synthetic data generation, pairwise comparison, MetricPromptBuilder,
multi-agent evaluation.
| Script | When to use |
|---|---|
validate_dataset.py | Before Stage 3 — catch malformed EvaluationDataset JSON. |
parse_adk_traces.py | Stage 1 — convert ADK session dumps to the canonical dataset shape. |
inspect_results.py | Stages 3/4 — render summary + per-case scores. --save-html for a browsable report. |
compare_results.py | Stage 5 — diff baseline vs. candidate, detect regressions. |
render_html_report.py | Render HTML from a saved result JSON or loss-clusters JSON. |
endpoint_evaluation.py | Stages 2/3 against a deployed Agent Platform endpoint (BYOM). See references/deployment.md. |
maas_evaluation.py | Stages 2/3 against a Model-as-a-Service model by ID. See references/deployment.md. |