chore(llm): drop AIA_DEEPSEEK_STRICT_TOOL_MODE legacy knob

Only AIA_TOOL_FUNCTION_STRICT=0 disables function.strict injection.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
oliver 2026-05-13 15:04:14 +08:00
parent 81163371bd
commit 1d7282a0a2
2 changed files with 6 additions and 46 deletions

View file

@ -115,17 +115,11 @@ def _openai_tool_function_strict_enabled() -> bool:
Default **on** for every provider/model: many gateways ignore unknown ``function`` keys; some
reject them—use ``AIA_TOOL_FUNCTION_STRICT=0`` to disable.
``AIA_DEEPSEEK_STRICT_TOOL_MODE=0`` is still honored as a legacy global opt-out when
``AIA_TOOL_FUNCTION_STRICT`` is unset. DeepSeek strict mode details:
DeepSeek documents ``function.strict`` in strict (Beta) tool mode:
https://api-docs.deepseek.com/zh-cn/guides/tool_calls
"""
primary = str(os.getenv("AIA_TOOL_FUNCTION_STRICT") or "").strip().lower()
if primary in ("0", "false", "no", "off"):
return False
if primary in ("1", "true", "yes", "on"):
return True
legacy = str(os.getenv("AIA_DEEPSEEK_STRICT_TOOL_MODE") or "").strip().lower()
if legacy in ("0", "false", "no", "off"):
raw = str(os.getenv("AIA_TOOL_FUNCTION_STRICT") or "").strip().lower()
if raw in ("0", "false", "no", "off"):
return False
return True

View file

@ -13,15 +13,12 @@ from svc.llm.transports.openai_chat_completions import (
class OpenAIToolFunctionStrictTests(unittest.TestCase):
def test_enabled_by_default(self) -> None:
prev_t = os.environ.pop("AIA_TOOL_FUNCTION_STRICT", None)
prev_d = os.environ.pop("AIA_DEEPSEEK_STRICT_TOOL_MODE", None)
prev = os.environ.pop("AIA_TOOL_FUNCTION_STRICT", None)
try:
self.assertTrue(_openai_tool_function_strict_enabled())
finally:
if prev_t is not None:
os.environ["AIA_TOOL_FUNCTION_STRICT"] = prev_t
if prev_d is not None:
os.environ["AIA_DEEPSEEK_STRICT_TOOL_MODE"] = prev_d
if prev is not None:
os.environ["AIA_TOOL_FUNCTION_STRICT"] = prev
def test_disabled_when_tool_function_strict_off(self) -> None:
prev = os.environ.get("AIA_TOOL_FUNCTION_STRICT")
@ -34,37 +31,6 @@ class OpenAIToolFunctionStrictTests(unittest.TestCase):
else:
os.environ["AIA_TOOL_FUNCTION_STRICT"] = prev
def test_disabled_legacy_deepseek_env_when_primary_unset(self) -> None:
prev_t = os.environ.pop("AIA_TOOL_FUNCTION_STRICT", None)
prev_d = os.environ.get("AIA_DEEPSEEK_STRICT_TOOL_MODE")
try:
os.environ["AIA_DEEPSEEK_STRICT_TOOL_MODE"] = "0"
self.assertFalse(_openai_tool_function_strict_enabled())
finally:
if prev_t is not None:
os.environ["AIA_TOOL_FUNCTION_STRICT"] = prev_t
if prev_d is None:
os.environ.pop("AIA_DEEPSEEK_STRICT_TOOL_MODE", None)
else:
os.environ["AIA_DEEPSEEK_STRICT_TOOL_MODE"] = prev_d
def test_primary_env_overrides_legacy_off(self) -> None:
prev_t = os.environ.get("AIA_TOOL_FUNCTION_STRICT")
prev_d = os.environ.get("AIA_DEEPSEEK_STRICT_TOOL_MODE")
try:
os.environ["AIA_DEEPSEEK_STRICT_TOOL_MODE"] = "0"
os.environ["AIA_TOOL_FUNCTION_STRICT"] = "1"
self.assertTrue(_openai_tool_function_strict_enabled())
finally:
if prev_t is None:
os.environ.pop("AIA_TOOL_FUNCTION_STRICT", None)
else:
os.environ["AIA_TOOL_FUNCTION_STRICT"] = prev_t
if prev_d is None:
os.environ.pop("AIA_DEEPSEEK_STRICT_TOOL_MODE", None)
else:
os.environ["AIA_DEEPSEEK_STRICT_TOOL_MODE"] = prev_d
def test_apply_sets_strict_on_function_tools(self) -> None:
tools = [
{"type": "function", "function": {"name": "get_weather", "parameters": {"type": "object", "properties": {}}}},