Skip to content

fix(responses-bridge): drop Codex tool_search/local_shell tools for chat-only providers - #33783

Open
devin-ai-integration[bot] wants to merge 1 commit into
litellm_internal_stagingfrom
litellm_fix_codex_namespace_tool_search_nvidia_nim
Open

fix(responses-bridge): drop Codex tool_search/local_shell tools for chat-only providers#33783
devin-ai-integration[bot] wants to merge 1 commit into
litellm_internal_stagingfrom
litellm_fix_codex_namespace_tool_search_nvidia_nim

Conversation

@devin-ai-integration

Copy link
Copy Markdown
Contributor

Relevant issues

Fixes #33779

Linear ticket

Pre-Submission checklist

  • I have added meaningful tests
  • My PR passes all CI/CD checks (e.g., lint, format, unit tests)
  • My PR's scope is as isolated as possible; it only solves 1 specific problem
  • I have received a Greptile Confidence Score of at least 4/5 before requesting a maintainer review

Screenshots / Proof of Fix

Codex CLI (latest) only speaks the Responses API wire, so a request to a chat-only provider (Nvidia NIM in the issue) goes through the /responses -> chat completion bridge. #32258 already dropped the namespace tool there, but Codex also emits a tool_search tool (and OpenAI Responses can emit local_shell), which the bridge still forwarded verbatim, so the provider rejected the whole request the same way NIM did with unknown variant 'namespace', expected 'function'

Reproduced end-to-end against a live proxy using a chat-only provider (Fireworks) that exercises the exact same bridge path NIM uses. Both runs at commit 6c7c577; the base run reverted only this file to its parent (6c7c577~1, i.e. the state after #32258)

Request body (Codex-style tools; namespace already dropped by #32258, so tools[1] is tool_search):

{
  "model": "nemotron-repro",
  "input": "Say hi in 3 words.",
  "tools": [
    {"type": "function", "name": "shell", "description": "run a shell command", "parameters": {"type": "object", "properties": {}}},
    {"type": "namespace", "name": "mcp__server", "description": "grouped tools", "tools": [
      {"type": "function", "name": "do_thing", "description": "d", "strict": false, "parameters": {"type": "object", "properties": {}}}
    ]},
    {"type": "tool_search", "execution": "client", "description": "search available tools", "parameters": {"type": "object", "properties": {}}}
  ]
}

BEFORE (parent of this commit, tool_search leaks):

$ curl -s -X POST http://localhost:4000/v1/responses -H "Authorization: Bearer sk-1234" -d @codex_req.json
{"error":{"message":"litellm.BadRequestError: Fireworks_aiException - {\"error\":{\"type\":\"invalid_request_error\",\"message\":\"4 request validation errors: Input should be 'function', 'web_search_preview' or 'code_interpreter', field: 'tools[1].type', value: 'tool_search'; ...\"}}. Received Model Group=nemotron-repro","code":"400"}}

AFTER (this commit):

$ curl -s -X POST http://localhost:4000/v1/responses -H "Authorization: Bearer sk-1234" -d @codex_req.json
{
  "object": "response",
  "status": "completed",
  "output": [ ... {"type":"message","role":"assistant","content":[{"type":"output_text","text":"Hey there, friend."}]} ],
  "tools": [],
  "usage": {"input_tokens":123,"output_tokens":122,"total_tokens":245}
}

Proxy log confirms both codex-only tool types are dropped before the upstream call:

LiteLLM:WARNING transformation.py - Dropping Responses API tool of type 'namespace': it has no Chat Completions equivalent and the target provider would reject the request.
LiteLLM:WARNING transformation.py - Dropping Responses API tool of type 'tool_search': it has no Chat Completions equivalent and the target provider would reject the request.

Type

🐛 Bug Fix

Changes

transform_responses_api_tools_to_chat_completion_tools keeps an explicit drop-list of Responses-API-only tool types that have no Chat Completions equivalent, since forwarding them verbatim makes providers reject the request. Added tool_search and local_shell to that list

-if _tool_type in ("computer_use", "image_generation", "namespace", "shell"):
+if _tool_type in (
+    "computer_use",
+    "image_generation",
+    "local_shell",
+    "namespace",
+    "shell",
+    "tool_search",
+):

The match is exact, so it only affects Codex's bare type: "tool_search"; Anthropic's versioned tool_search_tool_*_20251119 tools and LiteLLM's own name-based tool-search entries (no type field) still pass through unchanged

QA runbook

Not editing tests/e2e; the added test lives under tests/test_litellm

Final Attestation

  • The tests check the right things, including the edge cases, and regressions in the respective real-world customer use-cases are not possible after this PR

Link to Devin session: https://app.devin.ai/sessions/13a8b09a4c3446eb8a1bb7c16b6acd06

@devin-ai-integration

Copy link
Copy Markdown
Contributor Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment, CI, and merge conflict monitoring

@CLAassistant

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@greptile-apps

greptile-apps Bot commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR fixes a bug where the Responses-API-to-chat-completion bridge forwarded Codex-specific tool types (tool_search, local_shell) verbatim to chat-only providers, causing them to reject the entire request. A previous PR (#32258) already dropped namespace; this extends the same drop-list with the two remaining offenders.

  • Core fix (transformation.py): adds tool_search and local_shell to the existing tuple of Responses-API-only tool types that are silently dropped (with a warning log) before the upstream call.
  • Test (test_litellm_completion_responses.py): a new mock-only unit test reproduces the exact Codex CLI request shape from issue [Bug]: Exception when Using Codex CLI connect to Nvidia NIM Model nemotron-3-ultra-550b-a55b #33779, verifying that function tools survive while all three non-chat types (namespace, tool_search, local_shell) are stripped.

Confidence Score: 5/5

Safe to merge — the change touches only the tool-type drop-list in the Responses-to-chat bridge and introduces no new code paths.

The fix is a two-item addition to an existing allowlist tuple. The code path it affects (the else branch of the tool-type dispatch loop) is well-understood and already tested by several neighboring tests. The new test accurately mirrors the real-world Codex CLI request shape that triggered the bug, and all assertions are meaningful. No existing tests were weakened or removed.

No files require special attention.

Important Files Changed

Filename Overview
litellm/responses/litellm_completion_transformation/transformation.py Adds tool_search and local_shell to the explicit drop-list of Responses-API-only tool types that have no Chat Completions equivalent; the change is minimal, clearly scoped, and logically correct.
tests/test_litellm/responses/litellm_completion_transformation/test_litellm_completion_responses.py Adds a new mock-only unit test that exercises the exact Codex-CLI request shape from the issue report; assertions confirm function tools are preserved while namespace, tool_search, and local_shell are all dropped.

Reviews (1): Last reviewed commit: "fix(responses-bridge): drop Codex tool_s..." | Re-trigger Greptile

@codecov

codecov Bot commented Jul 17, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@codspeed-hq

codspeed-hq Bot commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

Merging this PR will not alter performance

✅ 31 untouched benchmarks


Comparing litellm_fix_codex_namespace_tool_search_nvidia_nim (6c7c577) with litellm_internal_staging (c5b4456)

Open in CodSpeed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Exception when Using Codex CLI connect to Nvidia NIM Model nemotron-3-ultra-550b-a55b

1 participant