在 ADK 里 评 测 实 时 语音 智能 体
Google 在 2026 年 8 月 24 日把实时语音评测放进 ADK。模拟用户把每轮说成音频,三个实时智能体依次核对接听人、校验生日并告知预约;同一套用例去掉 live_model_config 就退回文本模式。

本文目录
在 ADK 里评测实时语音智能体
Stephen Allen,解决方案架构师,AI Apps and Platforms。2026 年 8 月 24 日。
图 1:在 ADK 里评测实时智能体。
把实时智能体送进生产,不只是做出一个好看的演示。它要在一段口语对话里一轮一轮采取正确行动。时机和恢复,跟内容一样重要。昨天听起来完美的行为,可能在下一次改提示或换模型迭代时悄悄变掉。工具不再触发。上下文在轮次之间滑掉。插话被忽略。要有信心地发布,需要可重复的证据:智能体在真实用户实际会有的那些对话上站得住。
因此他们把原生的实时评测放进 ADK(Agent Development Kit,智能体开发工具包)。你现在可以用一个会把每一轮说成音频的模拟用户,去驱动一个实时、基于语音的智能体,给口语回复打分,并且这一切都在你已经用来跑文本智能体的同一条评测环里。这篇说明把一个实时智能体从「演示里能用」,带到「被测量、可信任」,而且不用离开 ADK。文档入口:http://adk.dev/live
评测你的第一个实时智能体
为了看到它怎么做,他们搭一条完整的实时评测环:创建智能体,编写评测用例,运行评测,再检查录下来的结果。
第 1 步:被测智能体
例子用的是基于图的工作流:三个各管一件事的实时智能体按顺序接在一起,每一段都跑在 gemini-live-2.5-flash-native-audio 上。
from google.adk.agents.llm_agent import Agent
from google.adk.tools.tool_context import ToolContext
from google.adk.workflow import START, Workflow
from pydantic import BaseModel, Field
LIVE_MODEL = "gemini-live-2.5-flash-native-audio"
def validate_date_of_birth(dob: str, tool_context: ToolContext) -> dict:
"""Validate a confirmed date of birth against records (mocked)."""
match = dob == "1985-07-12"
tool_context.state["dob_verified"] = match
return {"match": match}
greeter_agent = Agent(
model=LIVE_MODEL,
name="greeter_agent",
mode="task",
instruction="You are Sam, a friendly care-team assistant. Greet the caller "
"and confirm you're speaking with John Doe before sharing anything else. "
"Ask one question per turn, then complete your task with the confirmed name.",
)
dob_verifier_agent = Agent(
model=LIVE_MODEL,
name="dob_verifier_agent",
mode="task",
tools=[validate_date_of_birth],
instruction="Ask for the caller's date of birth, read it back to confirm, "
"then call validate_date_of_birth in YYYY-MM-DD format. Complete your task "
"with 'verified' or 'unverified'.",
)
goals_agent = Agent(
model=LIVE_MODEL,
name="goals_agent",
mode="task",
instruction="Identity is verified. Proactively share the upcoming "
"appointment on Tuesday, June 16th at 3 PM with Dr. Example, answer any "
'questions, then wrap up warmly and end with "Goodbye."',
)
root_agent = Workflow(
name="live_workflow",
edges=[
(START, greeter_agent),
(greeter_agent, dob_verifier_agent),
(dob_verifier_agent, goals_agent),
],
)每一段都是普通的实时智能体。工作流只负责编排它们,并把上一段的输出带到下一段。这条流程走三步,中间有一次工具调用,因此会生成一条值得打分的、内容较丰富的多轮轨迹(trajectory,按时间排开的发言和工具调用记录)。控制权在智能体之间移动时,用户察觉不到交接。音频流在整个交互期间保持打开。ADK 把已经积累的会话状态和对话历史往下带,让每个智能体在上下文里接着做,而不是从冷启动开始。
第 2 步:编写评测集
评测集(eval set,装测试用例的一份 JSON 文件)和用例怎么跑是分开的,所以你可以混用两种写法:对话场景,以及固定对话。
第一种是对话场景(conversation scenario):你描述目标和人物设定,用户模拟器(user simulator,由模型扮演用户、即兴说出下一句的程序)自己编每一轮。
{
"eval_id": "example_scenario_case",
"conversation_scenario": {
"starting_prompt": "Hello?",
"conversation_plan": "You are John Doe. Confirm your name when greeted. When asked for your date of birth, give July 12th, 1985, and confirm it when read back. Listen to the appointment details, ask what you should bring to the visit, then say you have no other questions and let the call wrap up.",
"user_persona": "NOVICE"
},
"session_input": {
"app_name": "live_workflow",
"user_id": "test_user_id",
"state": {}
}
}user_persona 决定模拟用户怎么说话。ADK 自带几种人物设定。NOVICE 让模拟器只分享高层目标,并等智能体来问具体细节,用来测智能体能不能把对话往前带。人物设定是提示驱动的,不是写死在代码里,所以你可以加自己的人物设定。conversation_plan 一旦满足,模拟器会自己结束场景。你写目标,由它决定电话何时打完。为了防止对话跑飞,max_allowed_invocations 给总轮数封顶,让每个动态用例都有可预期的上限。
你也可以写固定对话,把用户每一轮的原话逐字写下来。静态用例作为实时运行的输入,和模拟用户一样有效。
{
"eval_id": "example_fixed_case",
"conversation": [
{
"user_content": {
"role": "user",
"parts": [{ "text": "Hi, yes, this is John Doe." }]
}
},
{
"user_content": {
"role": "user",
"parts": [{ "text": "My date of birth is July 12th, 1985." }]
}
}
]
}第 3 步:打开实时和音频
在 test_config.json 里加上 live_model_config,并把 ADK 指到 llm_audio 用户模拟器。上面这些用例里的每一轮用户发言,都会用你选定的 Gemini TTS(text-to-speech,文字转语音)声音合成成语音,再流给实时智能体。TTS 文档:https://docs.cloud.google.com/text-to-speech/docs/gemini-tts
{
"criteria": {
"rubric_based_multi_turn_trajectory_quality_v1": {
"threshold": 0.7,
"judge_model_options": { "judge_model": "gemini-3.7-flash" },
"rubrics": [
{
"rubric_id": "verifies_identity_first",
"rubric_content": {
"text_property": "Across the call, the agent confirms the caller's name and validates their date of birth before disclosing any appointment details."
}
}
]
}
},
"live_model_config": {
"timeout_seconds": 300
},
"user_simulator_config": {
"type": "llm_audio",
"model": "gemini-3.7-flash",
"max_allowed_invocations": 10,
"audio_model": "gemini-3.1-flash-tts-preview",
"audio_model_configuration": {
"response_modalities": ["AUDIO"],
"speech_config": {
"voice_config": {
"prebuilt_voice_config": { "voice_name": "Kore" }
},
"language_code": "en-US"
}
}
}
}原文在评分量规数组里用注释标了「还有更多端到端量规」。上面只保留页面写出的那一条 verifies_identity_first。
有几处需要单独看:
live_model_config打开实时模式。省掉它,同一批测试用例会按标准文本模式跑。model和audio_model:model负责模拟用户的轮次推进逻辑,audio_model把这些轮次合成语音。改voice_name和language_code,用来测智能体对不同声音和口音的表现。criteria配置指标和通过/失败阈值。基于评分量规(rubric,用自然语言写下来的合格标准)的大模型评判,例如轨迹质量,是对整段对话做端到端评分,适合多智能体图。你也可以挂上逐轮指标,给单次回复或单次工具执行打分。
一句口语回复,用几百种不同措辞都可以是对的。自然语言量规按人类审阅者的方式判断意图。写一次,就自动用到套件里的每一段对话上。
第 4 步:运行
智能体、评测集和配置都准备好之后,从命令行跑评测:
uv run adk eval \
contributing/samples/live/live_workflow \
contributing/samples/live/live_workflow/live_workflow.evalset.json \
--config_file_path contributing/samples/live/live_workflow/test_config.json先装上评测附加依赖(uv pip install -e ".[eval]"),并为 Live API 和 Gemini TTS 配好 API 凭据。
同一条流水线也可以通过 AgentEvaluator 用程序调用,方便把实时语音评测放进 CI/CD(持续集成与持续交付,代码合并前自动跑检查的流水线),在发布前抓住回归。
第 5 步:在 ADK Web 里查看结果
做交互式调试时,ADK Web 现在原生支持实时评测。运行设置对话框里有 Standard | Live 模式开关。选 Live 之后,会出现输入模态选项(音频或文本),以及模拟用户的声音和语言设置。
图 2:运行设置里的实时模式、输入模态、声音和语言。
运行结束后,ADK 把实时音频流重建成一份干净的转写。每一轮画在单独的消息气泡里,带转写文本和一段可播放的音频,这样你可以评智能体听起来怎么样,而不只是它说了什么。
图 3:每轮转写和可播放音频。
开始用
要测你的实时智能体,克隆 live_workflow 示例,跑 adk eval,再在 ADK Web 里看结果。示例仓库:https://github.com/google/adk-python/tree/main/contributing/samples/live/live_workflow
更细的用户模拟、合成音频配置和自定义评测指标,见 ADK 文档:https://adk.dev/live/ 。语音智能体不必靠感觉发布,现在可以按测量结果发布。
出处:Stephen Allen,How to Evaluate Live & Voice Agents in ADK,2026-08-24,https://developers.googleblog.com/how-to-evaluate-live-voice-agents-in-adk ,CC BY 4.0。
觉得有用,转给同事
微信扫码
用微信扫一扫,在手机上打开后即可转发。