Skip to content

Respect tool_choice none when MCP is configured#1597

Open
lvsijian8 wants to merge 1 commit into
jundot:mainfrom
lvsijian8:fix/mcp-tool-choice-none
Open

Respect tool_choice none when MCP is configured#1597
lvsijian8 wants to merge 1 commit into
jundot:mainfrom
lvsijian8:fix/mcp-tool-choice-none

Conversation

@lvsijian8
Copy link
Copy Markdown
Contributor

Problem

When a global MCP manager is configured, chat completions always merge MCP tools into the effective tool list. Requests with tool_choice: "none" still receive tools in the chat template, so OpenAI-compatible clients cannot opt out of tool use per request.

Fix

  • Treat tool_choice: "none" as a request-level tool disable switch.
  • Skip MCP tool merging and pass no tools to the chat template for that request.
  • Keep MCP tool injection for requests that omit tool_choice or set it to "auto".
  • Cover the tool_choice: "none" case with and without request-provided tools.

Tests

  • .venv/bin/pytest tests/integration/test_server_endpoints.py::TestChatCompletionEndpoint::test_chat_completion_tool_choice_controls_mcp_tools -q
  • .venv/bin/pytest tests/integration/test_server_endpoints.py::TestChatCompletionEndpoint -q
  • .venv/bin/pytest tests/integration/test_server_endpoints.py -q
  • git diff --check

Fixes #1583

Skip MCP tool merging for chat completions when the request explicitly sets tool_choice to none, so per-request opt-out prevents tools from being injected into the chat template.

Add integration coverage for default, auto, none, and none with request tools.
@lvsijian8 lvsijian8 force-pushed the fix/mcp-tool-choice-none branch from f3d6038 to e2a443d Compare June 2, 2026 04:02
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.

OpenAI-compatible chat completions ignore tool_choice: "none" when MCP is configured

1 participant