Files
ai-agent/internal/ai/runtime/readtools/graph_executor_test.go
T

27 lines
906 B
Go
Raw Normal View History

package readtools
import (
"context"
"testing"
aitooling "code.tczkiot.com/wlw/ai-agent/internal/ai/tooling"
"code.tczkiot.com/wlw/ai-agent/internal/models"
"code.tczkiot.com/wlw/ai-agent/internal/pkg/toolx"
)
func TestExecuteGraphToolRejectsDisallowedToolBeforeGraphExecution(t *testing.T) {
definition, _, err := ExecuteGraphTool(context.Background(), models.Conversation{}, toolx.GraphAnalyzeConversation.Code, map[string]any{
"observed_issue": "需要分析的问题",
}, aitooling.Policy{
AllowedToolCodes: []string{toolx.GraphTriageServiceRequest.Code},
AllowedRiskLevels: []string{aitooling.RiskLevelRead},
Confirmed: true,
})
if err == nil {
t.Fatal("expected policy guard to reject the graph tool")
}
if definition.Code != toolx.GraphAnalyzeConversation.Code {
t.Fatalf("definition code = %q, want %q", definition.Code, toolx.GraphAnalyzeConversation.Code)
}
}