Skip to content

Commit e9eb080

Browse files
committed
refactor(providers): remove WithoutWebSearchSources
The opt-out was added because vercel/ai#18507 reported that Bedrock Mantle rejects web_search_call.action.sources. Mantle now accepts the include in us-east-1 and us-west-2. The one other host found to reject it, vLLM, cannot run a web_search tool, so turning web search off loses nothing there. Nothing calls the option.
1 parent 8659cf6 commit e9eb080

6 files changed

Lines changed: 14 additions & 169 deletions

File tree

‎providers/openai/openai.go‎

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ type options struct {
3838
sdkOptions []option.RequestOption
3939
objectMode fantasy.ObjectMode
4040
languageModelOptions []LanguageModelOption
41-
skipWebSearchSources bool
4241
}
4342

4443
// Option defines a function that configures OpenAI provider options.
@@ -137,16 +136,6 @@ func WithUseResponsesAPI() Option {
137136
}
138137
}
139138

140-
// WithoutWebSearchSources stops Responses requests with a web search tool
141-
// from automatically including web_search_call.action.sources. Use it for
142-
// Responses-compatible backends that reject that include, such as Bedrock
143-
// Mantle. A caller can still request it through ResponsesProviderOptions.Include.
144-
func WithoutWebSearchSources() Option {
145-
return func(o *options) {
146-
o.skipWebSearchSources = true
147-
}
148-
}
149-
150139
// WithResponsesAPIFunc sets a custom filter for which models use the Responses API.
151140
// When set, this function is called instead of the default IsResponsesModel().
152141
func WithResponsesAPIFunc(fn func(modelID string) bool) Option {
@@ -215,7 +204,7 @@ func (o *provider) LanguageModel(_ context.Context, modelID string) (fantasy.Lan
215204
if objectMode == fantasy.ObjectModeJSON {
216205
objectMode = fantasy.ObjectModeAuto
217206
}
218-
return newResponsesLanguageModel(modelID, o.options.name, client, objectMode, o.options.reasoningModelFunc, o.options.skipWebSearchSources), nil
207+
return newResponsesLanguageModel(modelID, o.options.name, client, objectMode, o.options.reasoningModelFunc), nil
219208
}
220209

221210
languageModelOptions := append([]LanguageModelOption{}, o.options.languageModelOptions...)

‎providers/openai/responses_language_model.go‎

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -24,23 +24,21 @@ import (
2424
const topLogprobsMax = 20
2525

2626
type responsesLanguageModel struct {
27-
provider string
28-
modelID string
29-
client openai.Client
30-
objectMode fantasy.ObjectMode
31-
reasoningModelFunc func(modelID string) bool
32-
skipWebSearchSources bool
27+
provider string
28+
modelID string
29+
client openai.Client
30+
objectMode fantasy.ObjectMode
31+
reasoningModelFunc func(modelID string) bool
3332
}
3433

3534
// newResponsesLanguageModel implements a responses api model.
36-
func newResponsesLanguageModel(modelID string, provider string, client openai.Client, objectMode fantasy.ObjectMode, reasoningModelFunc func(modelID string) bool, skipWebSearchSources bool) responsesLanguageModel {
35+
func newResponsesLanguageModel(modelID string, provider string, client openai.Client, objectMode fantasy.ObjectMode, reasoningModelFunc func(modelID string) bool) responsesLanguageModel {
3736
return responsesLanguageModel{
38-
modelID: modelID,
39-
provider: provider,
40-
client: client,
41-
objectMode: objectMode,
42-
reasoningModelFunc: reasoningModelFunc,
43-
skipWebSearchSources: skipWebSearchSources,
37+
modelID: modelID,
38+
provider: provider,
39+
client: client,
40+
objectMode: objectMode,
41+
reasoningModelFunc: reasoningModelFunc,
4442
}
4543
}
4644

@@ -366,7 +364,7 @@ func (o responsesLanguageModel) prepareParams(call fantasy.Call) (*responses.Res
366364
params.ToolChoice = toolChoice
367365
}
368366

369-
if !o.skipWebSearchSources && hasResponsesWebSearchTool(tools) && !slices.Contains(include, IncludeWebSearchCallActionSources) {
367+
if hasResponsesWebSearchTool(tools) && !slices.Contains(include, IncludeWebSearchCallActionSources) {
370368
include = append(include, IncludeWebSearchCallActionSources)
371369
}
372370

‎providers/openai/responses_options.go‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -174,8 +174,7 @@ const (
174174
IncludeMessageOutputTextLogprobs IncludeType = "message.output_text.logprobs"
175175
// IncludeWebSearchCallActionSources includes the pages a web search
176176
// found in web_search_call action.sources. Requests with a web
177-
// search tool add it automatically unless the provider was created with
178-
// WithoutWebSearchSources.
177+
// search tool add it automatically.
179178
IncludeWebSearchCallActionSources IncludeType = "web_search_call.action.sources"
180179
)
181180

‎providers/openai/responses_web_search_test.go‎

Lines changed: 0 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -448,59 +448,4 @@ func TestResponsesWebSearchSourcesInclude(t *testing.T) {
448448
requireWebSearchSourcesInclude(t, server.calls[0].body)
449449
require.Contains(t, server.calls[0].body["include"], string(IncludeReasoningEncryptedContent))
450450
})
451-
452-
newOptedOutModel := func(t *testing.T, serverURL string) fantasy.LanguageModel {
453-
t.Helper()
454-
provider, err := New(
455-
WithAPIKey("test-api-key"),
456-
WithBaseURL(serverURL),
457-
WithUseResponsesAPI(),
458-
WithoutWebSearchSources(),
459-
)
460-
require.NoError(t, err)
461-
model, err := provider.LanguageModel(context.Background(), "gpt-4.1")
462-
require.NoError(t, err)
463-
return model
464-
}
465-
466-
t.Run("NotRequestedWhenProviderOptsOut", func(t *testing.T) {
467-
t.Parallel()
468-
469-
server := newMockServer()
470-
defer server.close()
471-
server.response = mockResponsesWebSearchResponse()
472-
473-
model := newOptedOutModel(t, server.server.URL)
474-
_, err := model.Generate(context.Background(), fantasy.Call{
475-
Prompt: testPrompt,
476-
Tools: []fantasy.Tool{WebSearchTool(nil)},
477-
})
478-
require.NoError(t, err)
479-
require.Len(t, server.calls, 1)
480-
481-
include, _ := server.calls[0].body["include"].([]any)
482-
require.NotContains(t, include, string(IncludeWebSearchCallActionSources))
483-
})
484-
485-
t.Run("CallerIncludeSentWhenProviderOptsOut", func(t *testing.T) {
486-
t.Parallel()
487-
488-
server := newMockServer()
489-
defer server.close()
490-
server.response = mockResponsesWebSearchResponse()
491-
492-
model := newOptedOutModel(t, server.server.URL)
493-
_, err := model.Generate(context.Background(), fantasy.Call{
494-
Prompt: testPrompt,
495-
Tools: []fantasy.Tool{WebSearchTool(nil)},
496-
ProviderOptions: fantasy.ProviderOptions{
497-
Name: &ResponsesProviderOptions{
498-
Include: []IncludeType{IncludeWebSearchCallActionSources},
499-
},
500-
},
501-
})
502-
require.NoError(t, err)
503-
require.Len(t, server.calls, 1)
504-
requireWebSearchSourcesInclude(t, server.calls[0].body)
505-
})
506451
}

‎providers/openaicompat/openaicompat.go‎

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -123,15 +123,6 @@ func WithUseResponsesAPI() Option {
123123
}
124124
}
125125

126-
// WithoutWebSearchSources stops Responses requests with a web search tool
127-
// from automatically including web_search_call.action.sources, which some
128-
// compatible backends, such as Bedrock Mantle, reject.
129-
func WithoutWebSearchSources() Option {
130-
return func(o *options) {
131-
o.openaiOptions = append(o.openaiOptions, openai.WithoutWebSearchSources())
132-
}
133-
}
134-
135126
// WithResponsesAPIFunc sets a custom filter for which models use the Responses API.
136127
func WithResponsesAPIFunc(fn func(modelID string) bool) Option {
137128
return func(o *options) {

‎providers/openaicompat/web_search_sources_test.go‎

Lines changed: 0 additions & 77 deletions
This file was deleted.

0 commit comments

Comments
 (0)