fix: sanitize provider tool names

This commit is contained in:
zyl
2026-03-30 03:11:43 +08:00
parent 5db25b513e
commit dbb18a094c
5 changed files with 182 additions and 15 deletions

View File

@@ -1290,7 +1290,7 @@ fn compat_runtime_allows_read_skill_under_compact_mode_policy() {
assert!(tool_names.contains(&"browser_action".to_string()));
assert!(tool_names.contains(&"superrpa_browser".to_string()));
assert!(tool_names.contains(&"read_skill".to_string()));
assert!(tool_names.contains(&"zhihu-hotlist.extract_hotlist".to_string()));
assert!(!tool_names.contains(&"zhihu-hotlist_extract_hotlist".to_string()));
}
#[test]
@@ -1368,7 +1368,7 @@ top_n = "How many hotlist rows to extract."
assert!(tool_names.contains(&"browser_action".to_string()));
assert!(tool_names.contains(&"superrpa_browser".to_string()));
assert!(tool_names.contains(&"read_skill".to_string()));
assert!(tool_names.contains(&"workspace-zhihu-skill.extract_hotlist".to_string()));
assert!(tool_names.contains(&"workspace-zhihu-skill_extract_hotlist".to_string()));
}
#[test]
@@ -1383,7 +1383,7 @@ fn compat_runtime_executes_browser_script_skill_via_eval_without_gettext_probing
"id": "call_1",
"type": "function",
"function": {
"name": "workspace-zhihu-skill.extract_hotlist",
"name": "workspace-zhihu-skill_extract_hotlist",
"arguments": serde_json::to_string(&json!({
"expected_domain": "www.zhihu.com",
"top_n": "10"
@@ -1481,7 +1481,7 @@ return {
let tool_names = request_tool_names(&request_bodies[0]);
assert_eq!(summary, "已执行 browser_script skill");
assert!(tool_names.contains(&"workspace-zhihu-skill.extract_hotlist".to_string()));
assert!(tool_names.contains(&"workspace-zhihu-skill_extract_hotlist".to_string()));
assert!(sent.iter().any(|message| {
matches!(message, AgentMessage::LogEntry { level, message }
if level == "info" && message == "call workspace-zhihu-skill.extract_hotlist")
@@ -1544,7 +1544,7 @@ fn zhihu_hotlist_browser_skill_flow_does_not_expose_shell_or_glob_tools() {
assert!(tool_names.contains(&"superrpa_browser".to_string()));
assert!(tool_names.contains(&"browser_action".to_string()));
assert!(tool_names.contains(&"read_skill".to_string()));
assert!(tool_names.contains(&"zhihu-hotlist.extract_hotlist".to_string()));
assert!(tool_names.contains(&"zhihu-hotlist_extract_hotlist".to_string()));
assert!(!tool_names.contains(&"shell".to_string()));
assert!(!tool_names.contains(&"glob_search".to_string()));
}
@@ -1649,7 +1649,7 @@ fn browser_attached_export_flow_exposes_browser_and_office_tools_only() {
assert!(tool_names.contains(&"superrpa_browser".to_string()));
assert!(tool_names.contains(&"browser_action".to_string()));
assert!(tool_names.contains(&"read_skill".to_string()));
assert!(tool_names.contains(&"zhihu-hotlist.extract_hotlist".to_string()));
assert!(tool_names.contains(&"zhihu-hotlist_extract_hotlist".to_string()));
assert!(tool_names.contains(&"openxml_office".to_string()));
assert!(!tool_names.contains(&"shell".to_string()));
assert!(!tool_names.contains(&"glob_search".to_string()));
@@ -1704,7 +1704,7 @@ fn compat_runtime_allows_zhihu_hotlist_screen_export_tool_in_browser_profile() {
assert!(tool_names.contains(&"superrpa_browser".to_string()));
assert!(tool_names.contains(&"browser_action".to_string()));
assert!(tool_names.contains(&"read_skill".to_string()));
assert!(tool_names.contains(&"zhihu-hotlist.extract_hotlist".to_string()));
assert!(tool_names.contains(&"zhihu-hotlist_extract_hotlist".to_string()));
assert!(tool_names.contains(&"screen_html_export".to_string()));
assert!(!tool_names.contains(&"shell".to_string()));
assert!(!tool_names.contains(&"glob_search".to_string()));
@@ -1931,7 +1931,7 @@ fn handle_browser_message_executes_real_zhihu_hotlist_skill_flow() {
"id": "call_1",
"type": "function",
"function": {
"name": "zhihu-hotlist.extract_hotlist",
"name": "zhihu-hotlist_extract_hotlist",
"arguments": serde_json::to_string(&json!({
"expected_domain": "www.zhihu.com",
"top_n": "10"
@@ -2040,7 +2040,7 @@ fn handle_browser_message_chains_hotlist_skill_into_office_export_tool() {
"id": "call_1",
"type": "function",
"function": {
"name": "zhihu-hotlist.extract_hotlist",
"name": "zhihu-hotlist_extract_hotlist",
"arguments": serde_json::to_string(&json!({
"expected_domain": "www.zhihu.com",
"top_n": "10"