From f20b00e1359d8313615b103138197a0aa76cce7c Mon Sep 17 00:00:00 2001 From: qin-ptr <222410531+qin-ptr@users.noreply.github.com> Date: Thu, 15 Oct 2026 21:32:10 +0800 Subject: [PATCH] fix(vlm): default affected GPT tool calls to no reasoning Avoid invalid Chat Completions requests by selecting none for affected models when tools are present. Preserve explicit settings and Codex defaults. Co-authored-by: qin-ctx --- openviking/models/vlm/backends/openai_vlm.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/openviking/models/vlm/backends/openai_vlm.py b/openviking/models/vlm/backends/openai_vlm.py index fec0d336f4..b6686a8509 100644 --- a/openviking/models/vlm/backends/openai_vlm.py +++ b/openviking/models/vlm/backends/openai_vlm.py @@ -189,6 +189,9 @@ def _apply_completion_params( max_tokens_param = "max_tokens" kwargs["temperature"] = self.temperature + if kwargs.get("tools") and self.provider != "openai-codex": + if re.match(r"gpt-(?:5\.[456]|6-(?:sol|luna))(?:-|$)", kwargs["model"].lower()): + kwargs["reasoning_effort"] = "none" effective_max_tokens = max_tokens if max_tokens is not None else self.max_tokens if effective_max_tokens is not None: kwargs[max_tokens_param] = effective_max_tokens @@ -288,10 +291,10 @@ def _build_text_kwargs( "model": model, "messages": kwargs_messages, } - self._apply_completion_params(kwargs, effective_thinking, max_tokens=max_tokens) if tools: kwargs["tools"] = tools kwargs["tool_choice"] = tool_choice or "auto" + self._apply_completion_params(kwargs, effective_thinking, max_tokens=max_tokens) return kwargs def _build_vision_kwargs( @@ -319,10 +322,10 @@ def _build_vision_kwargs( "model": model, "messages": kwargs_messages, } - self._apply_completion_params(kwargs, effective_thinking) if tools: kwargs["tools"] = tools kwargs["tool_choice"] = tool_choice or "auto" + self._apply_completion_params(kwargs, effective_thinking) return kwargs def _extract_completion_content(self, response, elapsed: float) -> str: