Skip to content

Commit 6abbf5a

Browse files
lesebclaude
andcommitted
fix(api): default search_context_size to None to preserve recording compatibility
The search_context_size field defaulted to "medium", which caused the tool executor to always inject it into kwargs even when not explicitly set by the user. This changed the recording hash for web search tool calls, breaking all integration tests in replay mode with "Recording not found" errors surfaced as 500s. Change the default to None so search_context_size is only injected when the user explicitly provides it, preserving backward compatibility with existing integration test recordings. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Signed-off-by: Sébastien Han <seb@redhat.com>
1 parent 851aee3 commit 6abbf5a

8 files changed

Lines changed: 5 additions & 10 deletions

File tree

client-sdks/stainless/openapi.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6969,7 +6969,6 @@ components:
69696969
- medium
69706970
- high
69716971
- type: 'null'
6972-
default: medium
69736972
filters:
69746973
anyOf:
69756974
- $ref: '#/components/schemas/WebSearchFilters'

docs/static/deprecated-ogx-spec.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3159,7 +3159,6 @@ components:
31593159
- medium
31603160
- high
31613161
- type: 'null'
3162-
default: medium
31633162
filters:
31643163
anyOf:
31653164
- $ref: '#/components/schemas/WebSearchFilters'

docs/static/experimental-ogx-spec.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3604,7 +3604,6 @@ components:
36043604
- medium
36053605
- high
36063606
- type: 'null'
3607-
default: medium
36083607
filters:
36093608
anyOf:
36103609
- $ref: '#/components/schemas/WebSearchFilters'

docs/static/ogx-spec.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6522,7 +6522,6 @@ components:
65226522
- medium
65236523
- high
65246524
- type: 'null'
6525-
default: medium
65266525
filters:
65276526
anyOf:
65286527
- $ref: '#/components/schemas/WebSearchFilters'

docs/static/stainless-ogx-spec.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6969,7 +6969,6 @@ components:
69696969
- medium
69706970
- high
69716971
- type: 'null'
6972-
default: medium
69736972
filters:
69746973
anyOf:
69756974
- $ref: '#/components/schemas/WebSearchFilters'

src/ogx_api/openai_responses.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -573,7 +573,7 @@ class OpenAIResponseInputToolWebSearch(BaseModel):
573573
| Literal["web_search_preview_2025_03_11"]
574574
| Literal["web_search_2025_08_26"]
575575
) = "web_search"
576-
search_context_size: Literal["low", "medium", "high"] | None = "medium"
576+
search_context_size: Literal["low", "medium", "high"] | None = None
577577
filters: WebSearchFilters | None = None
578578
user_location: WebSearchUserLocation | None = None
579579

tests/unit/api/test_web_search_models.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ def test_web_search_tool_filters_none_by_default():
6767
tool = OpenAIResponseInputToolWebSearch(type="web_search")
6868
assert tool.filters is None
6969
assert tool.user_location is None
70-
assert tool.search_context_size == "medium"
70+
assert tool.search_context_size is None
7171

7272

7373
def test_web_search_tool_filters_with_empty_allowed_domains():

tests/unit/providers/responses/builtin/test_openai_responses_tools.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ async def test_create_openai_response_with_string_input_with_tools(openai_respon
9898
openai_responses_impl.tool_groups_api.get_tool.assert_called_once_with("web_search")
9999
openai_responses_impl.tool_runtime_api.invoke_tool.assert_called_once_with(
100100
tool_name="web_search",
101-
kwargs={"query": "What is the capital of Ireland?", "search_context_size": "medium"},
101+
kwargs={"query": "What is the capital of Ireland?"},
102102
)
103103

104104
openai_responses_impl.responses_store.upsert_response_object.assert_called()
@@ -972,7 +972,7 @@ async def test_web_search_with_filters_and_location(openai_responses_impl, mock_
972972

973973

974974
async def test_web_search_without_config_passes_only_query(openai_responses_impl, mock_inference_api):
975-
"""Test that web search without filters/location only passes query + default search_context_size."""
975+
"""Test that web search without filters/location only passes query."""
976976
_setup_web_search_mocks(openai_responses_impl, mock_inference_api)
977977
await openai_responses_impl.create_openai_response(
978978
input="What is the capital of Ireland?",
@@ -982,6 +982,6 @@ async def test_web_search_without_config_passes_only_query(openai_responses_impl
982982
)
983983
call_kwargs = openai_responses_impl.tool_runtime_api.invoke_tool.call_args.kwargs["kwargs"]
984984
assert call_kwargs["query"] == "What is the capital of Ireland?"
985-
assert call_kwargs["search_context_size"] == "medium"
985+
assert "search_context_size" not in call_kwargs
986986
assert "allowed_domains" not in call_kwargs
987987
assert "user_location" not in call_kwargs

0 commit comments

Comments
 (0)