fix(agent): keep gpt-oss on text tool mode

Treat gpt-oss local OpenAI-compatible models as text/fenced-tool models unless the endpoint explicitly declares native tool support.
This commit is contained in:
Dividesbyzer0
2026-06-15 02:11:52 -04:00
committed by GitHub
parent 056d1fb960
commit 7f571c8f7e
2 changed files with 16 additions and 0 deletions
+4
View File
@@ -1948,6 +1948,10 @@ async def stream_agent_loop(
# and can override this list for users who know their setup. # and can override this list for users who know their setup.
_model_no_tools = any(kw in _model_lc for kw in ( _model_no_tools = any(kw in _model_lc for kw in (
"deepseek-r1", "deepseek-r1",
# Open-weight GPT-OSS models are commonly served through llama.cpp /
# llama-cpp-python. Their names contain "gpt-o", but they do not use
# OpenAI's native tool-call channel unless the endpoint opts in.
"gpt-oss",
)) ))
# Native Ollama endpoints (/api/chat) handle tool schemas differently from # Native Ollama endpoints (/api/chat) handle tool schemas differently from
# the OpenAI-compat path. Models like gemma4, qwen3.5, ministral respond to # the OpenAI-compat path. Models like gemma4, qwen3.5, ministral respond to
+12
View File
@@ -25,6 +25,7 @@ def _compute_is_api_model(model: str, endpoint_url: str, endpoint_supports=None)
)) ))
model_no_tools = any(kw in model_lc for kw in ( model_no_tools = any(kw in model_lc for kw in (
"deepseek-r1", "deepseek-r1",
"gpt-oss",
)) ))
if endpoint_supports is True: if endpoint_supports is True:
@@ -72,6 +73,11 @@ class TestDeepSeekToolSupport:
"gemma4:e4b", "http://host.docker.internal:11434/v1" "gemma4:e4b", "http://host.docker.internal:11434/v1"
) is False ) is False
def test_gpt_oss_local_openai_compat_defaults_to_fenced_tools(self):
assert _compute_is_api_model(
"gpt-oss-20b", "http://localhost:8000/v1"
) is False
def test_qwen_native_ollama_defaults_to_fenced_tools(self): def test_qwen_native_ollama_defaults_to_fenced_tools(self):
assert _compute_is_api_model( assert _compute_is_api_model(
"qwen3.5:4b", "http://localhost:11434/api/chat" "qwen3.5:4b", "http://localhost:11434/api/chat"
@@ -117,6 +123,12 @@ class TestDeepSeekToolSupport:
) )
assert result is True assert result is True
def test_endpoint_supports_true_overrides_gpt_oss_default(self):
result = _compute_is_api_model(
"gpt-oss-20b", "http://localhost:8000/v1", endpoint_supports=True
)
assert result is True
def test_endpoint_supports_false_overrides_cloud(self): def test_endpoint_supports_false_overrides_cloud(self):
"""supports_tools=False on an endpoint gates even cloud APIs.""" """supports_tools=False on an endpoint gates even cloud APIs."""
result = _compute_is_api_model( result = _compute_is_api_model(