@@ -812,10 +812,34 @@ func TestToolForSchemas(t *testing.T) {
812812
813813 var (
814814 falseSchema = & schema {Not : & schema {}}
815- inSchema = & schema {Type : "object" , AdditionalProperties : falseSchema , Properties : map [string ]* schema {"p" : {Type : "integer" }}}
816- inSchema2 = & schema {Type : "object" , AdditionalProperties : falseSchema , Properties : map [string ]* schema {"p" : {Type : "string" }}}
817- outSchema = & schema {Type : "object" , AdditionalProperties : falseSchema , Properties : map [string ]* schema {"b" : {Type : "boolean" }}}
818- outSchema2 = & schema {Type : "object" , AdditionalProperties : falseSchema , Properties : map [string ]* schema {"b" : {Type : "integer" }}}
815+ inSchema = & schema {
816+ Type : "object" ,
817+ AdditionalProperties : falseSchema ,
818+ Properties : map [string ]* schema {"p" : {Type : "integer" }},
819+ PropertyOrder : []string {"p" },
820+ }
821+ inSchema2 = & schema {
822+ Type : "object" ,
823+ AdditionalProperties : falseSchema ,
824+ Properties : map [string ]* schema {"p" : {Type : "string" }},
825+ }
826+ inSchema3 = & schema {
827+ Type : "object" ,
828+ AdditionalProperties : falseSchema ,
829+ Properties : map [string ]* schema {}, // empty map is preserved
830+ }
831+ outSchema = & schema {
832+ Type : "object" ,
833+ AdditionalProperties : falseSchema ,
834+ Properties : map [string ]* schema {"b" : {Type : "boolean" }},
835+ PropertyOrder : []string {"b" },
836+ }
837+ outSchema2 = & schema {
838+ Type : "object" ,
839+ AdditionalProperties : falseSchema ,
840+ Properties : map [string ]* schema {"b" : {Type : "integer" }},
841+ PropertyOrder : []string {"b" },
842+ }
819843 )
820844
821845 // Infer both schemas.
@@ -829,6 +853,8 @@ func TestToolForSchemas(t *testing.T) {
829853 testToolForSchema [in , any ](t , & Tool {}, `{"p":"x"}` , 0 , inSchema , nil , `want "integer"` )
830854 // Tool sets input schema: that is what's used.
831855 testToolForSchema [in , any ](t , & Tool {InputSchema : inSchema2 }, `{"p":3}` , 0 , inSchema2 , nil , `want "string"` )
856+ // Tool sets input schema, empty properties map.
857+ testToolForSchema [in , any ](t , & Tool {InputSchema : inSchema3 }, `{}` , 0 , inSchema3 , nil , "" )
832858 // Tool sets output schema: that is what's used, and validation happens.
833859 testToolForSchema [in , any ](t , & Tool {OutputSchema : outSchema2 }, `{"p":3}` , out {true },
834860 inSchema , outSchema2 , `want "integer"` )
@@ -850,6 +876,7 @@ func TestToolForSchemas(t *testing.T) {
850876 "AsOf" : {Type : "string" },
851877 "Source" : {Type : "string" },
852878 },
879+ PropertyOrder : []string {"Summary" , "AsOf" , "Source" },
853880 },
854881 "" )
855882}
0 commit comments