Loading...
Loading...
Compare original and translation side by side
Scaffolded project? If you used, you already have/adk-scaffold,make eval, andtests/eval/evalsets/. Start withtests/eval/eval_config.jsonand iterate from there.make evalNon-scaffolded? Usedirectly — see Running Evaluations below.adk eval
使用脚手架搭建的项目? 如果您使用了,那么您已经拥有/adk-scaffold命令、make eval目录以及tests/eval/evalsets/配置文件。从运行tests/eval/eval_config.json开始,然后逐步迭代优化。make eval非脚手架项目? 直接使用命令——请查看下方的【运行评估】章节。adk eval
| File | Contents |
|---|---|
| Complete metrics reference — all 8 criteria, match types, custom metrics, judge model config |
| Dynamic conversation testing — ConversationScenario, user simulator config, compatible metrics |
| google_search and model-internal tools — trajectory behavior, metric compatibility |
| Multimodal inputs — evalset schema, built-in metric limitations, custom evaluator pattern |
| 文件 | 内容 |
|---|---|
| 完整的指标参考——包含全部8项评估标准、匹配类型、自定义指标、评判模型配置 |
| 动态对话测试——ConversationScenario、用户模拟器配置、兼容的评估指标 |
| google_search和模型内置工具——轨迹行为、指标兼容性 |
| 多模态输入——评估集schema、内置指标局限性、自定义评估器模式 |
make evaladk evalmake evaladk eval| Failure | What to change |
|---|---|
| Fix agent instructions (tool ordering), update evalset |
| Adjust agent instruction wording, or relax the expected response |
| Refine agent instructions, or adjust expected response — this is semantic, not lexical |
| Refine agent instructions to address the specific rubric that failed |
| Tighten agent instructions to stay grounded in tool output |
| Agent calls wrong tools | Fix tool descriptions, agent instructions, or tool_config |
| Agent calls extra tools | Use |
| 失败类型 | 需要调整的内容 |
|---|---|
| 修复Agent指令(工具调用顺序)、更新评估集的 |
| 调整Agent指令措辞,或放宽预期响应的匹配要求 |
| 优化Agent指令,或调整预期响应——该指标是语义层面的匹配,而非字面匹配 |
| 优化Agent指令,以解决未通过的具体评估准则 |
| 收紧Agent指令,使其严格基于工具输出内容生成响应 |
| Agent调用了错误的工具 | 修复工具描述、Agent指令或tool_config配置 |
| Agent调用了额外的工具 | 使用 |
| Goal | Recommended Metric |
|---|---|
| Regression testing / CI/CD (fast, deterministic) | |
| Semantic response correctness (flexible phrasing OK) | |
| Response quality without reference answer | |
| Validate tool usage reasoning | |
| Detect hallucinated claims | |
| Safety compliance | |
| Dynamic multi-turn conversations | User simulation + |
| Multimodal input (image, audio, file) | |
references/criteria-guide.md| 目标 | 推荐指标 |
|---|---|
| 回归测试/CI/CD(快速、确定性) | |
| 语义层面的响应正确性(允许灵活措辞) | |
| 无参考答案时的响应质量评估 | |
| 验证工具调用的推理逻辑 | |
| 检测幻觉内容 | |
| 安全合规性 | |
| 动态多轮对话 | 用户模拟 + |
| 多模态输入(图片、音频、文件) | |
references/criteria-guide.mdundefinedundefined
**CLI options:** `--config_file_path`, `--print_detailed_results`, `--eval_storage_uri`, `--log_level`
**Eval set management:**
```bash
adk eval_set create <agent_path> <eval_set_id>
adk eval_set add_eval_case <agent_path> <eval_set_id> --scenarios_file <path> --session_input_file <path>
**CLI选项:** `--config_file_path`, `--print_detailed_results`, `--eval_storage_uri`, `--log_level`
**评估集管理:**
```bash
adk eval_set create <agent_path> <eval_set_id>
adk eval_set add_eval_case <agent_path> <eval_set_id> --scenarios_file <path> --session_input_file <path>eval_config.jsoneval_config.json{
"criteria": {
"tool_trajectory_avg_score": {
"threshold": 1.0,
"match_type": "IN_ORDER"
},
"final_response_match_v2": {
"threshold": 0.8,
"judge_model_options": {
"judge_model": "gemini-2.5-flash",
"num_samples": 5
}
},
"rubric_based_final_response_quality_v1": {
"threshold": 0.8,
"rubrics": [
{
"rubric_id": "professionalism",
"rubric_content": { "text_property": "The response must be professional and helpful." }
},
{
"rubric_id": "safety",
"rubric_content": { "text_property": "The agent must NEVER book without asking for confirmation." }
}
]
}
}
}"response_match_score": 0.8judge_model_optionsuser_simulator_configreferences/criteria-guide.md{
"criteria": {
"tool_trajectory_avg_score": {
"threshold": 1.0,
"match_type": "IN_ORDER"
},
"final_response_match_v2": {
"threshold": 0.8,
"judge_model_options": {
"judge_model": "gemini-2.5-flash",
"num_samples": 5
}
},
"rubric_based_final_response_quality_v1": {
"threshold": 0.8,
"rubrics": [
{
"rubric_id": "professionalism",
"rubric_content": { "text_property": "The response must be professional and helpful." }
},
{
"rubric_id": "safety",
"rubric_content": { "text_property": "The agent must NEVER book without asking for confirmation." }
}
]
}
}
}"response_match_score": 0.8judge_model_optionsuser_simulator_configreferences/criteria-guide.mdevalset.jsonevalset.json{
"eval_set_id": "my_eval_set",
"name": "My Eval Set",
"description": "Tests core capabilities",
"eval_cases": [
{
"eval_id": "search_test",
"conversation": [
{
"invocation_id": "inv_1",
"user_content": { "parts": [{ "text": "Find a flight to NYC" }] },
"final_response": {
"role": "model",
"parts": [{ "text": "I found a flight for $500. Want to book?" }]
},
"intermediate_data": {
"tool_uses": [
{ "name": "search_flights", "args": { "destination": "NYC" } }
],
"intermediate_responses": [
["sub_agent_name", [{ "text": "Found 3 flights to NYC." }]]
]
}
}
],
"session_input": { "app_name": "my_app", "user_id": "user_1", "state": {} }
}
]
}intermediate_data.tool_usesintermediate_data.intermediate_responsessession_input.stateconversation_scenarioconversationreferences/user-simulation.md{
"eval_set_id": "my_eval_set",
"name": "My Eval Set",
"description": "Tests core capabilities",
"eval_cases": [
{
"eval_id": "search_test",
"conversation": [
{
"invocation_id": "inv_1",
"user_content": { "parts": [{ "text": "Find a flight to NYC" }] },
"final_response": {
"role": "model",
"parts": [{ "text": "I found a flight for $500. Want to book?" }]
},
"intermediate_data": {
"tool_uses": [
{ "name": "search_flights", "args": { "destination": "NYC" } }
],
"intermediate_responses": [
["sub_agent_name", [{ "text": "Found 3 flights to NYC." }]]
]
}
}
],
"session_input": { "app_name": "my_app", "user_id": "user_1", "state": {} }
}
]
}intermediate_data.tool_usesintermediate_data.intermediate_responsessession_input.stateconversation_scenarioconversationreferences/user-simulation.mdgoogle_searchsave_preferencestool_trajectory_avg_scoreEXACTIN_ORDERANY_ORDERrubric_based_tool_use_quality_v1save_preferencesgoogle_searchEXACTtool_trajectory_avg_scoreIN_ORDERANY_ORDERrubric_based_tool_use_quality_v1tool_trajectory_avg_score{
"conversation": [
{
"invocation_id": "inv_1",
"user_content": { "parts": [{"text": "Find me a flight from NYC to London"}] },
"intermediate_data": {
"tool_uses": [
{ "name": "search_flights", "args": {"origin": "NYC", "destination": "LON"} }
]
}
},
{
"invocation_id": "inv_2",
"user_content": { "parts": [{"text": "Book the first option"}] },
"final_response": { "role": "model", "parts": [{"text": "Booking confirmed!"}] },
"intermediate_data": {
"tool_uses": [
{ "name": "book_flight", "args": {"flight_id": "1"} }
]
}
}
]
}tool_trajectory_avg_score{
"conversation": [
{
"invocation_id": "inv_1",
"user_content": { "parts": [{"text": "Find me a flight from NYC to London"}] },
"intermediate_data": {
"tool_uses": [
{ "name": "search_flights", "args": {"origin": "NYC", "destination": "LON"} }
]
}
},
{
"invocation_id": "inv_2",
"user_content": { "parts": [{"text": "Book the first option"}] },
"final_response": { "role": "model", "parts": [{"text": "Booking confirmed!"}] },
"intermediate_data": {
"tool_uses": [
{ "name": "book_flight", "args": {"flight_id": "1"} }
]
}
}
]
}AppnameundefinedAppnameundefinedundefinedundefinedbefore_agent_callbackbefore_agent_callbackKeyErrorasync def initialize_state(callback_context: CallbackContext) -> None:
state = callback_context.state
if "user_preferences" not in state:
state["user_preferences"] = {}
root_agent = Agent(
name="my_agent",
before_agent_callback=initialize_state,
instruction="Based on preferences: {user_preferences}...",
)KeyErrorasync def initialize_state(callback_context: CallbackContext) -> None:
state = callback_context.state
if "user_preferences" not in state:
state["user_preferences"] = {}
root_agent = Agent(
name="my_agent",
before_agent_callback=initialize_state,
instruction="Based on preferences: {user_preferences}...",
)session_input.state// WRONG — initializes feedback_history as a string, breaks .append()
"state": { "feedback_history": "" }
// CORRECT — matches the Python type (list)
"state": { "feedback_history": [] }
// NOTE: Remove these // comments before using — JSON does not support comments.session_input.state// 错误写法——将feedback_history初始化为字符串,会导致.append()方法调用失败
"state": { "feedback_history": "" }
// 正确写法——与Python中的类型一致(列表)
"state": { "feedback_history": [] }
// 注意:使用前请删除这些//注释——JSON不支持注释。tool_configmode="ANY"tool_configmode="ANY"| Symptom | Cause | Fix |
|---|---|---|
Missing | Trajectory expects match per invocation | Add expected tool calls to all turns |
| Agent mentions data not in tool output | Hallucination | Tighten agent instructions; add |
| "Session not found" error | App name mismatch | Ensure App |
| Score fluctuates between runs | Non-deterministic model | Set |
| Agent uses | Remove trajectory metric; see |
| Trajectory fails but tools are correct | Extra tools called | Switch to |
| LLM judge ignores image/audio in eval | | Use custom metric with vision-capable judge (see |
| 症状 | 原因 | 修复方案 |
|---|---|---|
中间轮次缺少 | 轨迹评估要求每一轮调用都匹配 | 为所有轮次添加预期的工具调用 |
| Agent提及了工具输出中不存在的数据 | 幻觉 | 收紧Agent指令;添加 |
| 出现"Session not found"错误 | 应用名称不匹配 | 确保App的 |
| 评分在多次运行之间波动 | 模型具有非确定性 | 设置 |
| Agent使用了 | 移除轨迹评估指标;详见 |
| 轨迹评估失败但工具调用正确 | Agent调用了额外的工具 | 切换为 |
| LLM评判模型在评估中忽略了图片/音频 | | 使用支持视觉的评判模型和自定义指标(详见 |
https://google.github.io/adk-docs/evaluate/index.mdhttps://google.github.io/adk-docs/evaluate/criteria/index.mdhttps://google.github.io/adk-docs/evaluate/user-sim/index.mdhttps://google.github.io/adk-docs/evaluate/index.mdhttps://google.github.io/adk-docs/evaluate/criteria/index.mdhttps://google.github.io/adk-docs/evaluate/user-sim/index.mdgoogle_searchreferences/builtin-tools-eval.mdEXACTIN_ORDERtool_usesgoogle_searchreferences/builtin-tools-eval.mdEXACTIN_ORDERtool_uses