diff --git a/studio/backend/core/inference/llama_cpp.py b/studio/backend/core/inference/llama_cpp.py index 8c9f67b188..fb410f558c 100644 --- a/studio/backend/core/inference/llama_cpp.py +++ b/studio/backend/core/inference/llama_cpp.py @@ -5090,9 +5090,11 @@ class LlamaCppBackend: # so insertion order is deterministic (Python 3.7+). _tc_key = tool_name + str(arguments) _prev = _tool_call_history[-1] if _tool_call_history else None - _denied = confirm_tool_calls and request_tool_decision( - session_id, cancel_event=cancel_event - ) == "deny" + _denied = ( + confirm_tool_calls + and request_tool_decision(session_id, cancel_event = cancel_event) + == "deny" + ) if _denied: result = TOOL_REJECTED_MESSAGE elif _prev and _prev[0] == _tc_key and not _prev[1]: diff --git a/studio/backend/core/inference/safetensors_agentic.py b/studio/backend/core/inference/safetensors_agentic.py index 157061e34e..7f1a2273fc 100644 --- a/studio/backend/core/inference/safetensors_agentic.py +++ b/studio/backend/core/inference/safetensors_agentic.py @@ -320,9 +320,11 @@ def run_safetensors_tool_loop( } tc_key = tool_name + str(arguments) - denied = confirm_tool_calls and request_tool_decision( - session_id, cancel_event=cancel_event - ) == "deny" + denied = ( + confirm_tool_calls + and request_tool_decision(session_id, cancel_event = cancel_event) + == "deny" + ) if denied: result = TOOL_REJECTED_MESSAGE elif allowed_tool_names and tool_name not in allowed_tool_names: diff --git a/studio/backend/state/tool_approvals.py b/studio/backend/state/tool_approvals.py index f187e630b9..cd376be24d 100644 --- a/studio/backend/state/tool_approvals.py +++ b/studio/backend/state/tool_approvals.py @@ -33,7 +33,7 @@ def _key(session_id: Optional[str]) -> str: return session_id or "" -def request_tool_decision(session_id, cancel_event=None, timeout=_DECISION_TIMEOUT): +def request_tool_decision(session_id, cancel_event = None, timeout = _DECISION_TIMEOUT): """Block until the user allows/denies the pending tool call. Returns ``"allow"`` or ``"deny"``. Falls back to ``"deny"`` if the wait @@ -45,7 +45,7 @@ def request_tool_decision(session_id, cancel_event=None, timeout=_DECISION_TIMEO _pending[key] = {"event": event, "decision": None} try: waited = 0.0 - while not event.wait(timeout=0.5): + while not event.wait(timeout = 0.5): if cancel_event is not None and cancel_event.is_set(): return "deny" waited += 0.5