55 "testing"
66
77 "github.com/anthropics/anthropic-sdk-go"
8- "github.com/sashabaranov /go-openai /jsonschema"
8+ "github.com/modelcontextprotocol /go-sdk /jsonschema"
99 "github.com/stretchr/testify/assert"
1010 "github.com/stretchr/testify/require"
1111 "go.jetify.com/ai/api"
@@ -23,9 +23,9 @@ func TestEncodeFunctionTool(t *testing.T) {
2323 input : api.FunctionTool {
2424 Name : "test_function" ,
2525 Description : "A test function" ,
26- InputSchema : & jsonschema.Definition {
26+ InputSchema : & jsonschema.Schema {
2727 Type : "object" ,
28- Properties : map [string ]jsonschema.Definition {
28+ Properties : map [string ]* jsonschema.Schema {
2929 "param1" : {
3030 Type : "string" ,
3131 Description : "First parameter" ,
@@ -50,11 +50,39 @@ func TestEncodeFunctionTool(t *testing.T) {
5050 }
5151 }` ,
5252 },
53+ {
54+ name : "function tool with additionalProperties false" ,
55+ input : api.FunctionTool {
56+ Name : "test_function" ,
57+ Description : "A test function" ,
58+ InputSchema : & jsonschema.Schema {
59+ Type : "object" ,
60+ Properties : map [string ]* jsonschema.Schema {
61+ "param1" : {Type : "string" },
62+ },
63+ AdditionalProperties : api .FalseSchema (),
64+ },
65+ },
66+ want : `{
67+ "type": "tool",
68+ "name": "test_function",
69+ "description": "A test function",
70+ "input_schema": {
71+ "type": "object",
72+ "properties": {
73+ "param1": {
74+ "type": "string"
75+ }
76+ },
77+ "additionalProperties": false
78+ }
79+ }` ,
80+ },
5381 {
5482 name : "function tool with minimal fields" ,
5583 input : api.FunctionTool {
5684 Name : "minimal_function" ,
57- InputSchema : & jsonschema.Definition {
85+ InputSchema : & jsonschema.Schema {
5886 Type : "object" ,
5987 },
6088 },
@@ -538,9 +566,9 @@ func TestEncodeTools(t *testing.T) {
538566 functionTool := api.FunctionTool {
539567 Name : "test_function" ,
540568 Description : "A test function" ,
541- InputSchema : & jsonschema.Definition {
569+ InputSchema : & jsonschema.Schema {
542570 Type : "object" ,
543- Properties : map [string ]jsonschema.Definition {
571+ Properties : map [string ]* jsonschema.Schema {
544572 "param1" : {
545573 Type : "string" ,
546574 Description : "First parameter" ,
@@ -673,7 +701,7 @@ func TestEncodeTools(t *testing.T) {
673701 api.FunctionTool {
674702 Name : "test_tool" ,
675703 Description : "A test tool" ,
676- InputSchema : & jsonschema.Definition {Type : "object" },
704+ InputSchema : & jsonschema.Schema {Type : "object" },
677705 },
678706 },
679707 choice : & api.ToolChoice {Type : "tool" , ToolName : "test_tool" },
@@ -682,7 +710,7 @@ func TestEncodeTools(t *testing.T) {
682710 mustEncodeFunctionTool (api.FunctionTool {
683711 Name : "test_tool" ,
684712 Description : "A test tool" ,
685- InputSchema : & jsonschema.Definition {Type : "object" },
713+ InputSchema : & jsonschema.Schema {Type : "object" },
686714 }),
687715 },
688716 ToolChoice : specificChoice ("test_tool" ),
0 commit comments