docs/testing/ai-automation/test-scenarios/normal-flow/12-advanced-context-optimization-and-testing.md
在“高级模式”下,将变量(全局+上下文覆盖)、上下文消息(system/user)与工具(function tools)一起参与优化与测试,验证端到端链路:
AI执行指导:
name = GlobalNamescene = 全局场景预期结果:
name、scene验证点:
AI执行指导:
你是一个专业助手,称谓={{name}},角色={{role}}请在 {{scene}} 下完成 {{task}},并提供步骤name = Alice(使其覆盖全局值 GlobalName)role = 系统助手task = 高级流程验证预期结果:
name 使用上下文覆盖(Alice)而非全局(GlobalName)验证点:
name/role/scene/task 均有来源:scene 来自全局){{…}} 残留AI执行指导:
{
"type": "function",
"function": {
"name": "get_weather",
"description": "Get current weather for a location",
"parameters": {
"type": "object",
"properties": {
"location": { "type": "string" },
"unit": { "type": "string", "enum": ["celsius", "fahrenheit"], "default": "celsius" }
},
"required": ["location"]
}
}
}
预期结果:
get_weather验证点:
AI执行指导:
browser_console_messages 抓取日志关键字:
[App] Optimizing with advanced context: 或[usePromptOptimizer] Starting optimization with advanced context:预期结果:
验证点:
AI执行指导:
test tool call received,或面板中出现“工具调用”列表(ToolCallDisplay)预期结果:
验证点:
[App] original/optimized test completed)test tool call received 日志AI执行指导:
name 应为 Alice(上下文覆盖优先)scene 应来自全局(GlobalName 未被用于场景)currentPrompt)预期结果:
final = global ∪ contextOverrides,且剔除预定义名验证点:
AI执行指导:
messages 为数组metadata.variables 含 name/role/task/scenetools[0].function.name === 'get_weather'预期结果:
验证点:
messages.length >= 2metadata.variables 包含本次配置tools 数组存在且含 get_weather