Skip to content

MCP tool invocation regressed for custom/local providers (Ollama Responses API) in v0.117.0+ #19871

Open

Description

@neurostream

What version of Codex CLI is running?

Bisected with the same Codex config and MCP server set:

  • 0.115.0: good
  • 0.116.0: good
  • 0.117.0 through 0.125.0: MCP tool invocation becomes unreliable for custom/local model providers
  • 0.126.0-alpha variants tested during investigation: still reproduced

I am currently pinning 0.116.0 only as a workaround for the custom/local provider path.

What subscription do you have?

Not applicable to the repro. This is a custom model provider path using a remote Ollama/OpenAI-compatible endpoint, not an OpenAI-hosted model invocation.

Which model were you using?

Primary repro: gpt-oss:120b served by Ollama through an OpenAI-compatible /v1 endpoint with wire_api = "responses".

I also reproduced the same class of failure with other Ollama-served models through the same Codex provider/config shape, including qwen3.5:122b, qwen3.6:35b-a3b-bf16, and gemma4:31b. One vision model profile can also stall in some runs, but the simpler text-model repro is enough to show the MCP dispatch regression.

What platform is your computer?

Linux x86_64. The current deployed host reports Linux 6.8.0-100-generic.

What terminal emulator and version are you using (if applicable)?

The clearest repro is non-interactive codex exec from a shell. My local helper script is not intended to be the interesting part of the report: it renders config.toml, sets CODEX_HOME, chooses a profile, and then execs Codex.

The important command shape is equivalent to:

printf '%s\n' '<prompt>' | CODEX_HOME=/tmp/codex-local codex exec \
  --profile=local-ollama \
  --cd /path/to/workspace \
  --skip-git-repo-check \
  --dangerously-bypass-approvals-and-sandbox \
  -

What issue are you seeing?

For custom/local model providers using the Responses wire API, Codex 0.117.0+ often fails to invoke registered MCP tools even when the prompt explicitly requires tool use.

The session starts, the MCP server list can show the relevant server as ready, and other tool surfaces such as shell execution may still work. The failure is that Codex does not emit the expected MCP tool call. With the same config and prompt on 0.115.0 or 0.116.0, the transcript includes a real tool call such as:

tool brave_search.brave_web_search({...})

On regressed versions, the model frequently answers without making the MCP call, or otherwise fails to dispatch the registered tool despite it being available.

This looks like a Codex custom-provider/tool-routing regression rather than a generic MCP server startup issue. The same MCP servers and same model-provider config are usable on the known-good versions, and the regression starts at 0.117.0 in my bisect.

What steps can reproduce the bug?

Use a custom provider backed by Ollama or another OpenAI-compatible endpoint, with the Responses wire API and at least one MCP server that is easy to force from the prompt.

Representative config shape:

model_provider = "remoteollama"
model = "gpt-oss:120b"

[model_providers.remoteollama]
name = "Ollama"
base_url = "http://<ollama-host>:11434/v1"
wire_api = "responses"

[profiles.local-ollama]
model_provider = "remoteollama"
model = "gpt-oss:120b"
model_context_window = 131072
model_catalog_json = "/path/to/model-catalog.json"
approval_policy = "never"
sandbox_mode = "danger-full-access"

[mcp_servers.brave_search]
startup_timeout_sec = 60
command = "<brave-search-mcp-command>"
args = ["..."]

The catalog entries mark these models as API-supported and define their context windows/reasoning metadata; they are ordinary Codex model catalog entries, not special wrapper logic.

Then run an explicit MCP-forcing prompt:

printf '%s\n' 'Use the brave_search tool, not shell, to find the special comedian guest for the 2026 White House Correspondents Dinner. Return only the name and one source URL.' \
  | CODEX_HOME=/tmp/codex-local codex exec --profile=local-ollama --cd /path/to/workspace -

If MCP startup is slow on the first invocation, run a simple warm-up prompt first and judge the second run:

printf '%s\n' 'Reply with exactly READY.' \
  | CODEX_HOME=/tmp/codex-local codex exec --profile=local-ollama --cd /path/to/workspace -

Expected comparison:

  • 0.115.0 / 0.116.0: after MCP startup, the transcript emits a real brave_search MCP tool call and returns the sourced answer.
  • 0.117.0+: MCP startup may still show brave_search ready, but Codex no longer reliably emits the MCP tool call for the same prompt/config/provider.

What is the expected behavior?

Once an MCP server is started and available, a prompt that explicitly requires brave_search or web_search should reliably produce a real MCP tool call for custom/local provider models, matching the behavior seen in 0.115.0 and 0.116.0.

The custom-provider path should not require pinning an older Codex binary solely to preserve MCP tool invocation.

Additional information

My deployment has extra scaffolding that I do not think is essential to the bug: a VM image build, envsubst/envconsul config rendering, Dockerized MCP server images, persistent CODEX_HOME, and a small wrapper script used to select profiles. Those details explain why I noticed the regression, but the wrapper is not doing tool dispatch. It ultimately renders normal Codex config and runs codex exec --profile=... --cd ... -.

The current workaround in my environment is to install two Codex binaries:

  • 0.116.0 for Ollama/custom-provider profiles because MCP calls still work there
  • a newer Codex build for the OpenAI gpt-5.5 profile because the older binary is no longer a practical OpenAI runtime

This is only a compatibility bridge. It is not evidence that newer versions restored custom-provider MCP tool calling.

Related upstream signals that may be relevant:

Activity

  1. added
    bug
    on Apr 27, 2026
  2. added
    CLI
    mcp
    custom-model
    tool-calls
    on Apr 27, 2026
  3. github-actions commented on Apr 27, 2026

    @github-actions
    Contributor

    Potential duplicates detected. Please review them and close your issue if it is a duplicate.

    Powered by Codex Action

  4. removed
    CLI
    on Apr 27, 2026
  5. truffle-dev commented on Apr 27, 2026

    @truffle-dev

    The two pinned candidates look like sibling MCP regressions on different layers, not duplicates of this one.

    The bisect windows also differ. #19649 places the regression between 0.120.0 and 0.121.x; this issue places it earlier, between 0.116 and 0.117. If they share a root cause, the local-provider responses-API path was sensitive to the change ~3 versions before the hosted path noticed it.

    Worth keeping #19871 distinct so the responses-API-specific repro (and the cross-model evidence: gpt-oss:120b, qwen3.5:122b, gemma4:31b, qwen3-vl:235b) doesn't get folded into a hosted-only triage.

  6. changed the title [-]CLI: MCP tool invocation regressed for local providers (Ollama / responses API) in v0.117.0+[/-] [+]MCP tool invocation regressed for custom/local providers (Ollama Responses API) in v0.117.0+[/+] on Apr 28, 2026
  7. DinoLabAI commented on Apr 30, 2026

    @DinoLabAI

    I've been working on an agent with multiple external tools — API lookups, search, live data. When tools fail (timeouts, empty responses, bad data), the model does one of two things: surfaces the raw error to the user, or answers from memory as if the tool worked. Neither is usable.

    What I actually want is specific acknowledgment of the failure plus a useful alternative. Not "Error: connection timeout." Not a fabricated answer. Something like: tool unavailable, here's what you'd need to check this yourself, here's what matters when you do.

    Built training data for this exact gap. One row from DinoDS Lane 33 (Fallback Behavior):

    JSONL Row (public proof):

    {"sample_id": "lane_33_spec_example_03", "mode": "conversation", "tone": "friendly", "intent_family": "qa_general", "intent_subtype": "no_guarantees", "user_message": "Give me the exact stock price right now.", "assistant_response": "I can't guarantee an exact real-time price in this chat. If you tell me the ticker and your market, I can explain how to check the current quote and what numbers matter (last trade vs. bid/ask vs. after-hours)."}

    Still not sure whether this covers multi-tool cascade failures well — where the first tool fails and the model has to decide whether to try a fallback tool or degrade gracefully. Probably a separate training surface or a superset of rows. Dataset exists. Full bundle available via Discord and Platform.

  8. rnett commented on May 1, 2026

    @rnett

    I am seeing the same thing. I suspect it's related to the namespacing not looking like typical tool calls.

    > ollama launch codex
    ╭────────────────────────────────────────────────────╮
    │ >_ OpenAI Codex (v0.128.0)                         │
    │                                                    │
    │ model:     glm-5.1:cloud medium   /model to change │
    │ directory: ~\Projects\Personal\agent-config        │
    ╰────────────────────────────────────────────────────╯
    
      Tip: New Build faster with Codex.
    
    
    › What mcp tools do you have available?
    
    
    ⚠ Model metadata for `glm-5.1:cloud` not found. Defaulting to fallback metadata; this can degrade performance and cause issues.
    
    • - Access repositories, issues, and pull requests
    
      2. mcp__context7__ - Fetch current documentation for libraries, frameworks, SDKs, etc.
      3. mcp__gradle__ - Gradle-related tools
      4. mcp__playwright__ - Playwright browser automation tools
      5. mcp__tavily_mcp__ - Tavily search tools
      6. mcp__tilth__ - Code intelligence (AST-aware search, read, edit, diff, etc.)
    
      Let me also check if I can list the actual tool names from each server by listing MCP resources.
    
    • Here are the MCP servers and their tools I have access to:
    
      mcp__tilth__ — Code intelligence server (AST-aware replacements for grep/cat/find/diff)
    
      - tilth_search — Search code for definitions, usages, and text (replaces grep/rg)
      - tilth_read — Read files with smart outlining (replaces cat/head/tail)
      - tilth_files — Find files by glob pattern (replaces find/ls)
      - tilth_edit — Edit files using hash-anchored lines (replaces Edit tool)
      - tilth_diff — Structural diff at function level (replaces git diff)
      - tilth_deps — Blast-radius check for renames/signature changes
    
      mcp__context7__ — Documentation fetcher
    
      - Fetches current docs for libraries, frameworks, SDKs, APIs, CLI tools, and cloud services
    
      mcp__tavily_mcp__ — Web search
    
      - Tavily-powered web search for ad-hoc research queries
    
      mcp__playwright__ — Browser automation
    
      - Playwright tools for browser interaction and testing
    
      mcp__gradle__ — Build system tools
    
      - Gradle-specific MCP tools for dependency management and builds
    
      mcp__codex_apps__github — GitHub integration
    
      - Access repositories, issues, and pull requests
    
    
    › Try calling gradle or tilth tools
    
    
    ⚠ Model metadata for `glm-5.1:cloud` not found. Defaulting to fallback metadata; this can degrade performance and cause issues.
    
    • Let me try listing resources from both servers and also call a tilth tool directly.Let me try the server names without the prefix:Both servers exist but don't support resource listing. Let me try calling actual tools — a tilth_search on this repo and a Gradle tool to see what's available:The MCP servers for both tilth and gradle are configured but don't seem to be exposing their individual tools properly in this session:
    
      - Resource listing: Both servers reject resources/list (tilth returns "method not found", gradle returns "not supported")
      - Direct tool calls: Both return "unsupported call" when invoked
      - Resources/templates: No resources or templates registered
    
      This typically means the MCP server processes may not be running or the tool schemas weren't loaded at session start. The individual sub-tools (like tilth_search, tilth_read, tilth_edit etc.) should appear as separate callable functions but they're not showing up.
    
      You might want to check:
    
      - Are the tilth and gradle MCP server processes running?
      - Is the MCP config (e.g. in codex/config.toml or the Codex MCP settings) pointing to the right server executables?
      - Does restarting the Codex session pick them up?
    
      Want me to dig into the MCP server configuration to troubleshoot?
    
    • Called mcp__gradle__.list_mcp_resources({"server":"mcp__gradle__"})
      └ Error: resources/list failed: unknown MCP server 'mcp__gradle__'
    
    • Called mcp__tilth__.list_mcp_resources({"server":"mcp__tilth__"})
      └ Error: resources/list failed: unknown MCP server 'mcp__tilth__'
    
    • Called gradle.list_mcp_resources({"server":"gradle"})
      └ Error: resources/list failed: resources/list failed for `gradle`: Mcp error: -32601: Server does not support resources/list({})
    
    • Called tilth.list_mcp_resources({"server":"tilth"})
      └ Error: resources/list failed: resources/list failed for `tilth`: Mcp error: -32601: method not found: resources/list
    
    • Calling codex.list_mcp_resources({})
    
    • Calling codex.list_mcp_resource_templates({})
    
    • Called codex.list_mcp_resources({})
      └ {"resources": []}
    
    • Called codex.list_mcp_resource_templates({})
      └ {"resourceTemplates": []}
    
    ────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
    
    
    › The issue is your calling syntax
    
    
    ⚠ Model metadata for `glm-5.1:cloud` not found. Defaulting to fallback metadata; this can degrade performance and cause issues.
    
    • Ah, let me try different calling patterns.Let me try a few different calling patterns:The tools have now gone unavailable entirely. I've tried several calling patterns without success:
    
      - Direct params: {"query": "AGENTS", "kind": "symbol"}
      - Sub-tool names: mcp__tilth__tilth_search
      - Name/arguments wrapper: {"name": "tilth_search", "arguments": {...}}
    
      Could you show me the correct calling syntax? I'm clearly missing something about how these MCP namespace tools should be invoked.
    
  9. truffle-dev commented on May 1, 2026

    @truffle-dev

    That transcript matches the shape: the model emits text describing MCP tools (mcp__tilth__ — Code intelligence server) instead of producing a tool_use invocation. That points at the regression being on the responses wire path: namespaced tool names register on the server side but no longer round-trip to a real tool call between 0.116 and 0.117.

    Two things that would tighten the bisect:

    1. Does pinning 0.116.0 with the same glm-5.1:cloud config restore the actual tool call? Same regression line on a second provider/model pair rules out anything model-specific in gpt-oss:120b.
    2. Is your provider config also wire_api = "responses"? The chat path was unchanged across that range, so confirming responses locks the scope.

    A redacted config.toml paste would help narrow the maintainer search.

  10. rnett commented on May 1, 2026

    @rnett

    I did some more investigation and suspect that this might be #20574.

  11. truffle-dev commented on May 1, 2026

    @truffle-dev

    Tracing rnett's #20574 hypothesis against current HEAD: the two surfaces are adjacent, but the dispatch endings differ.

    #20574 surfaces loudly with Fatal error: tool_search handler received unsupported payload. Per codex-rs/core/src/tools/router.rs:188-201, that's the path where ResponseItem::FunctionCall (Ollama's only call shape on Responses API) routes through resolve_mcp_tool_info, returns None for tool_search, and falls to ToolPayload::Function which the tool_search handler rejects.

    #19871 reports the model emitting no tool call at all, a silent fall-through. If a namespaced MCP name (mcp__brave_search__brave_web_search) failed to resolve through resolve_mcp_tool_info, the same tool_search-style loud error should fire. Silence implies dispatch did succeed and the bug is downstream, somewhere in result-encoding back to the model, or in tool spec encoding so the model never emits the call shape in the first place.

    A quick disambiguator: grep your regressed run's $CODEX_HOME/log/codex-tui.log for unsupported payload or any dispatch error. Loud means the root likely overlaps with #20574 and the fix shape is at the router. Silent means it's a different bug surfacing in the same provider path.

    Bisect note on the related-PR list at the bottom of the issue body: #17556 (Support flattened deferred MCP tool calls) merged 2026-04-12, #18413 (support namespaced deferred dynamic tools) merged 2026-04-21, both after rust-v0.117.0 was tagged on 2026-03-26. The MCP-namespace work cited (#17404 register-all-mcp-with-namespace, #16944 expand-tool-search-to-custom-MCPs, #18097 defer-all-tools-behind-flag) all merged April. They could be partial fixes that didn't fully close the regression, but they're not the commits that introduced 0.116→0.117. Narrowing to rust-v0.116.0..rust-v0.117.0 (232 commits, 5-day window) for changes to ResponseItem function-call shape or non-native-provider tool spec encoding would be the wedge if this still reproduces on current main.

  12. notOrrytrout commented on Jun 24, 2026

    @notOrrytrout

    Yes. I get the same issue.

  13. 10 remaining items

  14. metrofun commented on Aug 2, 2026

    @metrofun

    I got Codex 0.142.3 to complete an MCP call through Ollama’s Responses endpoint without pinning Codex to 0.116.0.

    The working path uses Swobu between Codex and Ollama. It converts Codex’s namespaced MCP declarations into deterministic flat function names for the backend, then restores the original server/tool identity before returning the call to Codex.

    My exact positive witness on August 2, 2026 was:

    • Codex CLI 0.142.3
    • Swobu v1.0.0-rc.4
    • Ollama 0.20.2
    • qwen3.5:9b
    • two MCP servers, alpha and beta, both exposing read_marker

    Ollama returned the exact alias advertised for alpha/read_marker; Swobu restored that identity, and Codex dispatched only the alpha server and returned ALPHA-MCP-7429.

    Install:

    curl -fsSL https://swobu.com/install.sh | sh

    Then point a Codex profile at the configured Swobu workspace:

    [model_providers.swobu]
    name = "Swobu"
    base_url = "http://127.0.0.1:7926/c/<workspace>/v1"
    env_key = "SWOBU_CLIENT_API_KEY"
    wire_api = "responses"
    supports_websockets = false
    
    [profiles.swobu]
    model = "<route-or-model>"
    model_provider = "swobu"

    One useful diagnostic from broader testing: this fixes the namespace transport and reverse-dispatch layer, but it cannot repair a model that returns undeclared leaf names such as read_file instead of one of the function names actually advertised in the request.

    With the same current Codex version, I observed both outcomes depending on the model and tool catalog:

    • exact advertised alias returned → Codex MCP dispatch succeeds;
    • undeclared bare leaf returned → Codex correctly rejects it before MCP dispatch.

    I have not reproduced the reporter’s exact gpt-oss:120b and Brave Search combination, so this is a bounded positive result for qwen3.5:9b

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugcustom-modelmcptool-calls

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions