Respect tool_choice none when MCP is configured#1597
Open
lvsijian8 wants to merge 1 commit into
Open
Conversation
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.
f3d6038 to
e2a443d
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
tool_choice: "none"as a request-level tool disable switch.tool_choiceor set it to"auto".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 -qgit diff --checkFixes #1583