| 1 | package responses |
| 2 | |
| 3 | import ( |
| 4 | "testing" |
| 5 | |
| 6 | "reasonix/internal/provider" |
| 7 | ) |
| 8 | |
| 9 | func TestNativeToolSearchRequiresFirstPartyResponsesAndKnownModel(t *testing.T) { |
| 10 | firstParty := New(Config{Name: "renamed-provider", BaseURL: "https://api.openai.com", Model: "gpt-5.5"}).(*client) |
| 11 | if !firstParty.NativeToolSearchAvailable() { |
| 12 | t.Fatal("first-party Responses client with a supported model should advertise tool search") |
| 13 | } |
| 14 | gateway := New(Config{Name: "openai", BaseURL: "https://gateway.example", Model: "gpt-5.5"}).(*client) |
| 15 | if gateway.NativeToolSearchAvailable() { |
| 16 | t.Fatal("provider name must not enable tool search on a compatible gateway") |
| 17 | } |
| 18 | oldModel := New(Config{Name: "openai", BaseURL: "https://api.openai.com", Model: "gpt-5.2"}).(*client) |
| 19 | if oldModel.NativeToolSearchAvailable() { |
| 20 | t.Fatal("unknown model capability must fail closed") |
| 21 | } |
| 22 | } |
| 23 | |
| 24 | func TestResponsesToolSearchWireIncludesSearchAndDeferredFunction(t *testing.T) { |
| 25 | c := New(Config{Name: "openai", BaseURL: "https://api.openai.com", Model: "gpt-5.5"}).(*client) |
| 26 | tools := encodeResponsesTools(c, provider.Request{ |
| 27 | ToolSearch: &provider.ToolSearch{Enabled: true}, |
| 28 | Tools: []provider.ToolSchema{{Name: "mcp__svc__search", Parameters: []byte(`{"type":"object"}`), Deferred: true}}, |
| 29 | }) |
| 30 | if len(tools) != 2 || tools[0]["type"] != "tool_search" || tools[1]["defer_loading"] != true { |
| 31 | t.Fatalf("encoded tools = %#v", tools) |
| 32 | } |
| 33 | if _, strict := tools[1]["strict"]; strict { |
| 34 | t.Fatal("third-party MCP schemas must rely on host validation unless explicitly strict-compatible") |
| 35 | } |
| 36 | } |
| 37 |