@@ -71,8 +71,7 @@ func TestRequestPlanUsesFunctionToolShape(t *testing.T) {
7171 t .Fatalf ("expected request host %s to match server host %s" , requestHost , parsedURL .Host )
7272 }
7373
74- // Validate Responses API function tool shape (nested function entry)
75- // tools should be: [{ "type": "function", "function": { name, description, parameters } }]
74+ // Validate Responses API function tool shape (flat function entry)
7675 tools , ok := captured ["tools" ].([]any )
7776 if ! ok || len (tools ) != 1 {
7877 t .Fatalf ("expected tools to contain one entry, got %T (len=%d)" , captured ["tools" ], len (tools ))
@@ -84,35 +83,19 @@ func TestRequestPlanUsesFunctionToolShape(t *testing.T) {
8483 if t0 ["type" ] != "function" {
8584 t .Fatalf ("expected tools[0].type=function, got %v" , t0 ["type" ])
8685 }
87- fn , ok := t0 ["function" ].(map [string ]any )
88- if ! ok || fn == nil {
89- t .Fatalf ("expected tools[0].function to be an object, got %T" , t0 ["function" ])
86+ if t0 ["name" ] != schema .ToolName {
87+ t .Fatalf ("expected tools[0].name=%s, got %v" , schema .ToolName , t0 ["name" ])
9088 }
91- if fn ["name" ] != schema .ToolName {
92- t .Fatalf ("expected tools[0].function.name=%s, got %v" , schema .ToolName , fn ["name" ])
93- }
94- params , ok := fn ["parameters" ].(map [string ]any )
89+ params , ok := t0 ["parameters" ].(map [string ]any )
9590 if ! ok {
96- t .Fatalf ("expected tools[0].function. parameters to be an object" )
91+ t .Fatalf ("expected tools[0].parameters to be an object" )
9792 }
9893 if _ , ok := params ["type" ].(string ); ! ok {
9994 t .Fatalf ("expected parameters schema to include a type field" )
10095 }
10196
102- // Validate tool_choice object selecting our function
103- // tool_choice should be: { "type": "function", "function": { "name": ToolName } }
104- tc , ok := captured ["tool_choice" ].(map [string ]any )
105- if ! ok {
106- t .Fatalf ("expected tool_choice to be an object, got %T" , captured ["tool_choice" ])
107- }
108- if tc ["type" ] != "function" {
109- t .Fatalf ("expected tool_choice.type=function, got %v" , tc ["type" ])
110- }
111- tcf , ok := tc ["function" ].(map [string ]any )
112- if ! ok || tcf == nil {
113- t .Fatalf ("expected tool_choice.function to be an object, got %T" , tc ["function" ])
114- }
115- if tcf ["name" ] != schema .ToolName {
116- t .Fatalf ("expected tool_choice.function.name=%s, got %v" , schema .ToolName , tcf ["name" ])
97+ // Validate tool_choice required
98+ if captured ["tool_choice" ] != "required" {
99+ t .Fatalf ("expected tool_choice=required, got %v" , captured ["tool_choice" ])
117100 }
118101}
0 commit comments