@@ -958,3 +958,59 @@ func TestTransformToolsToResponses_StrictModeFalse(t *testing.T) {
958958 jsonData , _ := json .MarshalIndent (tool , "" , " " )
959959 t .Logf ("Generated tool JSON:\n %s" , string (jsonData ))
960960}
961+
962+ func TestTransformToolsToResponses_AdditionalPropertiesFalse (t * testing.T ) {
963+ // Test that tools are created with additionalProperties: false
964+ // OpenAI Responses API REQUIRES this field even when strict: false is set.
965+ // Without it, you get: "Invalid schema for function '...': 'additionalProperties'
966+ // is required to be supplied and to be false"
967+ tools := []models.AnthropicTool {
968+ {
969+ Name : "Task" ,
970+ Description : "Launch a task agent" ,
971+ InputSchema : map [string ]interface {}{
972+ "type" : "object" ,
973+ "properties" : map [string ]interface {}{
974+ "description" : map [string ]interface {}{
975+ "type" : "string" ,
976+ "description" : "Task description" ,
977+ },
978+ "prompt" : map [string ]interface {}{
979+ "type" : "string" ,
980+ "description" : "The task for the agent to perform" ,
981+ },
982+ "subagent_type" : map [string ]interface {}{
983+ "type" : "string" ,
984+ "description" : "Type of specialized agent" ,
985+ },
986+ },
987+ "required" : []interface {}{"description" , "prompt" , "subagent_type" },
988+ },
989+ },
990+ }
991+
992+ result := transformToolsToResponses (tools )
993+
994+ if len (result ) != 1 {
995+ t .Fatalf ("Expected 1 tool, got %d" , len (result ))
996+ }
997+
998+ tool := result [0 ]
999+
1000+ // Verify additionalProperties is false at top level
1001+ params , ok := tool .Parameters .(map [string ]interface {})
1002+ if ! ok {
1003+ t .Fatal ("Tool.Parameters should be a map" )
1004+ }
1005+
1006+ additionalProps , hasAdditional := params ["additionalProperties" ]
1007+ if ! hasAdditional {
1008+ t .Error ("Tool.Parameters should have additionalProperties field (required by OpenAI Responses API)" )
1009+ } else if additionalProps != false {
1010+ t .Errorf ("Tool.Parameters.additionalProperties should be false, got %v" , additionalProps )
1011+ }
1012+
1013+ // Log for debugging
1014+ jsonData , _ := json .MarshalIndent (tool , "" , " " )
1015+ t .Logf ("Generated tool JSON with additionalProperties:\n %s" , string (jsonData ))
1016+ }
0 commit comments