fix(core): use dedicated types for responsesapi web search tool config (#14136)

This changes the web_search tool spec in codex-core to use dedicated
Responses-API payload structs instead of shared config types and custom
serializers.

Previously, `ToolSpec::WebSearch` stored `WebSearchFilters` and
`WebSearchUserLocation` directly and relied on hand-written serializers
to shape the outgoing JSON. This worked, but it mixed config/schema
types with the OpenAI Responses payload contract and created an easy
place for drift if those shared types changed later.

### Why
This keeps the boundary clearer:
- app-server/config/schema types stay focused on config
- Responses tool payload types stay focused on the OpenAI wire format

It also makes the serialization behavior obvious from the structs
themselves, instead of hiding it in custom serializer functions.
This commit is contained in:
Owen Lin
2026-03-09 14:58:33 -07:00
committed by GitHub
parent d241dc598c
commit d309c102ef
2 changed files with 44 additions and 67 deletions

View File

@@ -2017,11 +2017,11 @@ pub(crate) fn build_specs(
filters: config
.web_search_config
.as_ref()
.and_then(|cfg| cfg.filters.clone()),
.and_then(|cfg| cfg.filters.clone().map(Into::into)),
user_location: config
.web_search_config
.as_ref()
.and_then(|cfg| cfg.user_location.clone()),
.and_then(|cfg| cfg.user_location.clone().map(Into::into)),
search_context_size: config
.web_search_config
.as_ref()
@@ -2766,8 +2766,12 @@ mod tests {
tool.spec,
ToolSpec::WebSearch {
external_web_access: Some(true),
filters: web_search_config.filters,
user_location: web_search_config.user_location,
filters: web_search_config
.filters
.map(crate::client_common::tools::ResponsesApiWebSearchFilters::from),
user_location: web_search_config
.user_location
.map(crate::client_common::tools::ResponsesApiWebSearchUserLocation::from),
search_context_size: web_search_config.search_context_size,
search_content_types: None,
}