mirror of
https://github.com/YspCoder/clawgo.git
synced 2026-04-28 09:57:29 +08:00
add query/history window filters and subagent summary controls
This commit is contained in:
52
pkg/tools/sessions_tool_test.go
Normal file
52
pkg/tools/sessions_tool_test.go
Normal file
@@ -0,0 +1,52 @@
|
||||
package tools
|
||||
|
||||
import (
|
||||
"context"
|
||||
"strings"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"clawgo/pkg/providers"
|
||||
)
|
||||
|
||||
func TestSessionsToolListWithKindsAndQuery(t *testing.T) {
|
||||
tool := NewSessionsTool(func(limit int) []SessionInfo {
|
||||
return []SessionInfo{
|
||||
{Key: "telegram:1", Kind: "main", Summary: "project alpha", UpdatedAt: time.Now()},
|
||||
{Key: "cron:1", Kind: "cron", Summary: "nightly sync", UpdatedAt: time.Now()},
|
||||
}
|
||||
}, nil)
|
||||
|
||||
out, err := tool.Execute(context.Background(), map[string]interface{}{
|
||||
"action": "list",
|
||||
"kinds": []interface{}{"main"},
|
||||
"query": "alpha",
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if !strings.Contains(out, "telegram:1") || strings.Contains(out, "cron:1") {
|
||||
t.Fatalf("unexpected output: %s", out)
|
||||
}
|
||||
}
|
||||
|
||||
func TestSessionsToolHistoryWithoutTools(t *testing.T) {
|
||||
tool := NewSessionsTool(nil, func(key string, limit int) []providers.Message {
|
||||
return []providers.Message{
|
||||
{Role: "user", Content: "hello"},
|
||||
{Role: "tool", Content: "tool output"},
|
||||
{Role: "assistant", Content: "ok"},
|
||||
}
|
||||
})
|
||||
|
||||
out, err := tool.Execute(context.Background(), map[string]interface{}{
|
||||
"action": "history",
|
||||
"key": "telegram:1",
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if strings.Contains(strings.ToLower(out), "tool output") {
|
||||
t.Fatalf("tool message should be filtered: %s", out)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user