style: collapse should_execute_tools docstring to one line

Made-with: Cursor
This commit is contained in:
Xubin Ren 2026-04-17 12:26:03 +00:00 committed by Xubin Ren
parent b8d327dc41
commit 9a569fdc6a

View File

@ -73,17 +73,7 @@ class LLMResponse:
@property @property
def should_execute_tools(self) -> bool: def should_execute_tools(self) -> bool:
"""Check if tool calls should be executed (guards against gateway injection). """True only if tool_calls present AND finish_reason is a known-good signal (``tool_calls`` or ``stop``); blocks gateway-injected calls under ``refusal`` / ``content_filter`` / ``error``."""
Executes only when ``has_tool_calls`` is true and ``finish_reason`` is one of
the known-good signals: ``"tool_calls"`` (explicit intent) or ``"stop"`` (some
compliant providers emit ``stop`` for legitimate tool calls; existing paths in
``openai_compat_provider`` already treat both as the tool-call terminal state).
Tool calls under any other ``finish_reason`` (e.g. ``refusal``, ``content_filter``,
``error``) are treated as anomalous typically injected by non-compliant API
gateways and are skipped.
"""
if not self.has_tool_calls: if not self.has_tool_calls:
return False return False
return self.finish_reason in ("tool_calls", "stop") return self.finish_reason in ("tool_calls", "stop")