[pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci
This commit is contained in:
pre-commit-ci[bot] 2026-05-31 05:32:41 +00:00
commit f1451fcb71
4 changed files with 14 additions and 10 deletions

View file

@ -317,7 +317,9 @@ def run_safetensors_tool_loop(
)
tc_key = tool_name + str(arguments)
is_disabled = bool(allowed_tool_names) and tool_name not in allowed_tool_names
is_disabled = (
bool(allowed_tool_names) and tool_name not in allowed_tool_names
)
already_ran_ok = any(
k == tc_key and not err for k, err in tool_call_history
)
@ -326,7 +328,9 @@ def run_safetensors_tool_loop(
# asking the user to approve it would be noise. Registering the
# approval slot *before* tool_start closes the race where the
# confirmation could arrive before the waiter exists.
needs_confirm = confirm_tool_calls and not is_disabled and not already_ran_ok
needs_confirm = (
confirm_tool_calls and not is_disabled and not already_ran_ok
)
approval_id = new_approval_id() if needs_confirm else ""
decision_slot = (
begin_tool_decision(session_id, approval_id) if needs_confirm else None

View file

@ -58,9 +58,7 @@ def begin_tool_decision(session_id, approval_id) -> dict:
return slot
def wait_tool_decision(
slot, approval_id, cancel_event = None, timeout = _DECISION_TIMEOUT
):
def wait_tool_decision(slot, approval_id, cancel_event = None, timeout = _DECISION_TIMEOUT):
"""Block on a slot from ``begin_tool_decision`` until the user decides.
Returns ``"allow"`` or ``"deny"``. Falls back to ``"deny"`` if the wait

View file

@ -52,9 +52,7 @@ class _Waiter:
kwargs = {"cancel_event": self.cancel_event}
if self.timeout is not None:
kwargs["timeout"] = self.timeout
self.result = request_tool_decision(
self.session_id, self.approval_id, **kwargs
)
self.result = request_tool_decision(self.session_id, self.approval_id, **kwargs)
def start(self):
self._thread.start()
@ -209,7 +207,9 @@ def test_concurrent_distinct_calls_route_their_own_decisions():
for i in range(n):
aid = new_approval_id()
waiters[aid] = _Waiter(f"s{i}", aid).start()
expected = {aid: ("allow" if i % 2 == 0 else "deny") for i, aid in enumerate(waiters)}
expected = {
aid: ("allow" if i % 2 == 0 else "deny") for i, aid in enumerate(waiters)
}
for aid, decision in expected.items():
assert resolve_tool_decision(aid, decision) is True
for aid, w in waiters.items():

View file

@ -36,7 +36,9 @@ class _FakeExecuteTool:
def __init__(self):
self.calls = []
def __call__(self, name, arguments, *, cancel_event = None, timeout = None, session_id = None):
def __call__(
self, name, arguments, *, cancel_event = None, timeout = None, session_id = None
):
self.calls.append((name, arguments))
return f"RESULT[{name}]"