mirror of
https://gitcode.com/JianFeeeee/homeagent-sdk.git
synced 2026-09-20 00:48:12 +00:00
- Plugin.Start(sdk *PluginSDK) 接口签名改为指针 - 方法表重写: 移除 CallLLM/QueryKnowledge/SetMemory 等不存在方法 - IOInjector 参数顺序修正为 (source, channel, text) - 删除虚构 SDKConfig, 替换为实际 New() 构造函数签名 - .hmap 内容描述一致化 (plugin.so + plugin.dll + main.lua) - 添加 meta/ 包元数据文件
32 lines
1.0 KiB
Go
32 lines
1.0 KiB
Go
package main
|
|
|
|
import "testing"
|
|
|
|
func TestCleanToolCallLeakage(t *testing.T) {
|
|
tests := []struct {
|
|
name, input, want string
|
|
}{
|
|
{"empty", "", ""},
|
|
{"clean", "你好", "你好"},
|
|
{"tool_call", "a<tool_call>x</tool_call>b", "ab"},
|
|
{"invoke", "a<invoke>x</invoke>b", "ab"},
|
|
{"function", "a<function>x</function>b", "ab"},
|
|
{"xml_block", "a\n```xml\n<tool_call>x</tool_call>\n```\nb", "a\n\nb"},
|
|
{"json_block", "a\n```json\n<invoke>x</invoke>\n```\nb", "a\n\nb"},
|
|
{"bare_code", "```python\nprint(1)\n```", "```python\nprint(1)\n```"},
|
|
{"chinese_marker", "a【tool_call】x【/tool_call】b", "ab"},
|
|
{"tool_line", "cmd_run(\"ls\")\nok", "ok"},
|
|
{"prose_kept", "cmd_run 是一个工具", "cmd_run 是一个工具"},
|
|
{"multiline", "a\n<tool_call>\nx\n</tool_call>\nb", "a\n\nb"},
|
|
{"whitespace", "a\n\n\n\nb", "a\n\nb"},
|
|
}
|
|
for _, tt := range tests {
|
|
t.Run(tt.name, func(t *testing.T) {
|
|
got := cleanToolCallLeakage(tt.input)
|
|
if got != tt.want {
|
|
t.Errorf("got %q, want %q", got, tt.want)
|
|
}
|
|
})
|
|
}
|
|
}
|