Fully autonomous AI Agents system capable of performing complex penetration testing tasks
Go ai-agentsai-security-toolanthropicautonomous-agentsgolanggptgraphqlmulti-agent-systemoffensive-securityopen-sourceopenaipenetration-testingpenetration-testing-toolsreactsecurity-automationsecurity-testingsecurity-toolsself-hosted
test(cast): add new test for dropping multiple nil function call tool calls
Dmitry Ng21338d858f9f
diff --git a/backend/pkg/cast/chain_ast_test.go b/backend/pkg/cast/chain_ast_test.goindex 31b9bc34..ab05ce78 100644--- a/backend/pkg/cast/chain_ast_test.go+++ b/backend/pkg/cast/chain_ast_test.go@@ -3213,3 +3213,23 @@ func TestSanitizeToolCallArguments(t *testing.T) {})}}++func TestNewBodyPair_DropsMultipleNilFunctionCallToolCalls(t *testing.T) {+ aiMsg := &llms.MessageContent{+ Role: llms.ChatMessageTypeAI,+ Parts: []llms.ContentPart{+ llms.ToolCall{ID: "a", Type: "function", FunctionCall: nil},+ llms.ToolCall{ID: "b", Type: "function", FunctionCall: nil},+ llms.TextContent{Text: "keep me"},+ },+ }++ NewBodyPair(aiMsg, nil)++ assert.Len(t, aiMsg.Parts, 1, "both nil-FunctionCall tool calls should be removed, text kept")+ if assert.Len(t, aiMsg.Parts, 1) {+ txt, ok := aiMsg.Parts[0].(llms.TextContent)+ assert.True(t, ok, "surviving part should be the TextContent, got %T", aiMsg.Parts[0])+ assert.Equal(t, "keep me", txt.Text)+ }+}diff --git a/backend/pkg/cast/newbodypair_reg_test.go b/backend/pkg/cast/newbodypair_reg_test.godeleted file mode 100644index d1ebe564..00000000--- a/backend/pkg/cast/newbodypair_reg_test.go+++ /dev/null@@ -1,28 +0,0 @@-package cast--import (- "testing"-- "github.com/stretchr/testify/assert"- "github.com/vxcontrol/langchaingo/llms"-)--func TestNewBodyPair_DropsMultipleNilFunctionCallToolCalls(t *testing.T) {- aiMsg := &llms.MessageContent{- Role: llms.ChatMessageTypeAI,- Parts: []llms.ContentPart{- llms.ToolCall{ID: "a", Type: "function", FunctionCall: nil},- llms.ToolCall{ID: "b", Type: "function", FunctionCall: nil},- llms.TextContent{Text: "keep me"},- },- }-- NewBodyPair(aiMsg, nil)-- assert.Len(t, aiMsg.Parts, 1, "both nil-FunctionCall tool calls should be removed, text kept")- if assert.Len(t, aiMsg.Parts, 1) {- txt, ok := aiMsg.Parts[0].(llms.TextContent)- assert.True(t, ok, "surviving part should be the TextContent, got %T", aiMsg.Parts[0])- assert.Equal(t, "keep me", txt.Text)- }-}