Repository navigation
Bug: web_search_call items in conversation history crash when switching to Ollama/custom provider #24612
Description
What version of the Codex App are you using (From “About Codex” dialog)?
26.519.41501 (3044)
What subscription do you have?
Plus
What platform is your computer?
No response
What issue are you seeing?
Summary
When a thread uses an OpenAI model (e.g. GPT-5.5) that invokes the web search tool, the conversation history accumulates web_search_call input items. If you then switch to an Ollama/custom model provider in the same thread, Codex forwards the entire history — including those web_search_call items — to the new provider. The provider rejects the request with:
{"error":{"message":"input[14]: unknown input item type: \"web_search_call\"","type":"invalid_request_error","param":null,"code":null}}
Steps to Reproduce
- Start a Codex thread using an OpenAI model (e.g. GPT-5.5)
- Ask a question that triggers a web search (e.g. "search the web for today's news")
- Switch the model to an Ollama/custom provider (e.g.
glm-5.1:cloudvia Ollama) - Send another message in the same thread
- Request fails with
unknown input item type: "web_search_call"
Root Cause
Codex uses wire_api = "responses" for all providers (the "chat" wire API is no longer supported). When sending conversation history to a model provider, Codex does not strip or convert Responses API-specific input item types (web_search_call, web_search_call_output) that the target provider doesn't support.
The model catalog correctly marks supports_search_tool: false for Ollama models, but this flag only prevents Codex from initiating new web searches — it does not cause Codex to strip existing web search items from the history before forwarding.
Expected Behaviour
Codex should filter out web_search_call and web_search_call_output items from the conversation history when sending to a provider where supports_search_tool is false (or where the provider otherwise cannot handle those item types).
Workaround
Start a new conversation thread when switching from an OpenAI model to an Ollama/custom provider. A fresh thread has no web_search_call items in the history.
Environment
- Codex CLI v0.130.0
- macOS (Apple Silicon)
- Custom model provider: Ollama (
wire_api = "responses",base_url = "http://127.0.0.1:11434/v1/") - Model catalog includes
supports_search_tool: falseandsupports_parallel_tool_calls: false
Config Snippet
[profiles.ollama-launch-codex-app]
model = "glm-5.1:cloud"
openai_base_url = "http://127.0.0.1:11434/v1/"
model_provider = "ollama-launch-codex-app"
model_catalog_json = "/Users/username/.codex/ollama-launch-models.json"
[model_providers.ollama-launch-codex-app]
name = "Ollama"
base_url = "http://127.0.0.1:11434/v1/"
wire_api = "responses"What steps can reproduce the bug?
- Start a Codex thread using an OpenAI model (e.g. GPT-5.5)
- Ask a question that triggers a web search (e.g. "search the web for today's news")
- Switch the model to an Ollama/custom provider (e.g.
glm-5.1:cloudvia Ollama) - Send another message in the same thread
- Request fails with
unknown input item type: "web_search_call"
What is the expected behavior?
Codex should filter out web_search_call and web_search_call_output items from the conversation history when sending to a provider where supports_search_tool is false (or where the provider otherwise cannot handle those item types).
Additional information
No response
Activity
JunJieLiu51520 commentedon May 28, 2026
Root cause analysis
I traced the conversation history flow from assembly to sending to the model provider.
The gap in history normalization
The
for_promptmethod inContextManager(codex-rs/core/src/context_manager/history.rs, ~line 119) callsnormalize_history, which currently performs three normalizations:strip_images_when_unsupportedinnormalize.rs)There is no equivalent step to strip
WebSearchCall/WebSearchCallOutputitems when the target model doesn't support web search.Where
supports_search_toolis checked (tool spec only)supports_search_toolis only checked incodex-rs/core/src/tools/spec_plan.rs(~line 267), which controls whether the web search tool spec is offered to the model in new turns. It is never used to filter existing history items.Similarly,
ProviderCapabilities.web_search(codex-rs/model-provider/src/provider.rs, ~line 30) is only checked inspec_plan.rsfor tool spec generation, not for history filtering.The flow when the bug triggers
supports_search_tool: trueWebSearchCallitems that are recorded into history viarecord_conversation_itemssupports_search_tool: false)run_turncallssess.clone_history().await.for_prompt(...)normalize_historyonly strips images, not web search itemsWebSearchCallitems are sent to Ollama → provider rejectsProposed fix
Following the existing
strip_images_when_unsupportedpattern incodex-rs/core/src/context_manager/normalize.rs(~line 295-345), add astrip_web_search_when_unsupportedfunction:Then update
for_promptsignature to also acceptsupports_search_tool: booland call this new function innormalize_history. Call sites inturn.rs(~lines 234, 953),compact.rs,compact_remote.rs,compact_remote_v2.rs, andprompt_debug.rswould passturn_context.model_info.supports_search_tool.A more comprehensive approach would bundle
input_modalities,supports_search_tool, andimage_generationcapability into aModelCapabilitiesFilterstruct to avoid continuously expanding the function signature — and also coverImageGenerationCallfiltering for providers where image generation is unsupported.Happy to submit a PR if the team would like me to implement this fix.
docs: expand README with usage and configuration guide
refactor(responses): drop LiteLLM bridge, direct AIServices Responses…
radix commentedon Aug 21, 2026
FWIW I'm getting this even without starting on an OpenAI model. It happens even when I start a fresh codex thread on ollama and get it to do some web searches. When it hits "Optimized the conversation" I get this error:
docs: expand README with usage and configuration guide