Local UI to run and train LLMs and diffusion models. Supports GGUF, MLX, Qwen3.8, DeepSeek-V4.1, MiniMax-H3, Gemma 4, FLUX and more.
Python agentaichatgptdeepseekfine-tuninggemmaimage-generationllamallmllmsopenaipythonqwenreinforcement-learningself-hostedstable-diffusiontext-to-speechttsuiunsloth
Studio: never ask for approval to run search_conversation (#12175)
Daniel Han269b67b82355
diff --git a/studio/backend/core/inference/llama_cpp.py b/studio/backend/core/inference/llama_cpp.pyindex ce67819f73f..758134eeeed 100644--- a/studio/backend/core/inference/llama_cpp.py+++ b/studio/backend/core/inference/llama_cpp.py@@ -35285,6 +35285,7 @@ class LlamaCppBackend:has_text_only_provisional_card,is_always_safe_tool,is_high_risk_tool_call,+ never_needs_approval,)# "full" and bypass_permissions are the same switch, whichever arrives@@ -37506,6 +37507,7 @@ class LlamaCppBackend:bool(confirm_tool_calls)and not bypass_permissionsand permission_mode != "off"+ and not never_needs_approval(decision.tool_name))if needs_confirm and permission_mode == "auto":needs_confirm = is_high_risk_tool_call(diff --git a/studio/backend/core/inference/safetensors_agentic.py b/studio/backend/core/inference/safetensors_agentic.pyindex e7e54b05883..e79fcb6bb6b 100644--- a/studio/backend/core/inference/safetensors_agentic.py+++ b/studio/backend/core/inference/safetensors_agentic.py@@ -1437,8 +1437,13 @@ def run_safetensors_tool_loop(# Bypass wins here too, so a direct internal caller with both flags# never prompts. "auto" pauses only high-risk calls; "off" never# prompts (sandbox stays on).+ from core.inference.tools import never_needs_approval+needs_confirm = (- bool(confirm_tool_calls) and not bypass_permissions and permission_mode != "off"+ bool(confirm_tool_calls)+ and not bypass_permissions+ and permission_mode != "off"+ and not never_needs_approval(decision.tool_name))if needs_confirm and permission_mode == "auto":from core.inference.tools import is_high_risk_tool_calldiff --git a/studio/backend/core/inference/studio_tool_loop.py b/studio/backend/core/inference/studio_tool_loop.pyindex 03aea307589..07e5e4be23f 100644--- a/studio/backend/core/inference/studio_tool_loop.py+++ b/studio/backend/core/inference/studio_tool_loop.py@@ -95,7 +95,12 @@ from core.inference.tool_stream_exec import (search_images_kwargs,stream_tool_execution,)-from core.inference.tools import build_rag_autoinject, execute_tool, is_high_risk_tool_call+from core.inference.tools import (+ build_rag_autoinject,+ execute_tool,+ is_high_risk_tool_call,+ never_needs_approval,+)from state.tool_approvals import (DECISION_EXPIRED,TOOL_APPROVAL_EXPIRED_MESSAGE,@@ -1668,7 +1673,10 @@ async def stream_with_studio_tools(# Same id for a call the provider named; for one it did not, the card answers to the id the client mintedcard_id = decision.card_idneeds_confirmation = (- confirm_tool_calls and not bypass_permissions and permission_mode != "off"+ confirm_tool_calls+ and not bypass_permissions+ and permission_mode != "off"+ and not never_needs_approval(name))if needs_confirmation and permission_mode == "auto":needs_confirmation = is_high_risk_tool_call(name, arguments)diff --git a/studio/backend/core/inference/tools.py b/studio/backend/core/inference/tools.pyindex 8902e48e021..5d3ea03ee18 100644--- a/studio/backend/core/inference/tools.py+++ b/studio/backend/core/inference/tools.py@@ -6822,6 +6822,11 @@ _ALWAYS_SAFE_TOOLS = frozenset()+def never_needs_approval(name: str) -> bool:+ """search_conversation only reads this chat's own compacted turns (#11671)."""+ return name == "search_conversation"++def is_always_safe_tool(name: str) -> bool:"""True for tools that never need an auto-mode prompt on any arguments, so a caller (e.g. thestreaming provisional card) can allow them before the full arguments are known. render_htmldiff --git a/studio/backend/tests/test_permission_mode.py b/studio/backend/tests/test_permission_mode.pyindex 66c4c29929b..d07d2cc061a 100644--- a/studio/backend/tests/test_permission_mode.py+++ b/studio/backend/tests/test_permission_mode.py@@ -2832,6 +2832,27 @@ def test_ask_mode_gates_even_safe_calls():assert starts and starts[0]["awaiting_confirmation"] is True[email protected](("name", "gated"), [("search_conversation", False), ("web_search", True)])+def test_ask_mode_never_gates_conversation_recall(name, gated):+ """Every other tool, read-only ones included, still asks."""+ session = f"{_SESSION}-{uuid.uuid4().hex}"+ events = []+ for ev in run_safetensors_tool_loop(+ single_turn = _multi_turn([_tool_call(name, '{"query": "the rust code"}'), "final"]),+ messages = [{"role": "user", "content": "hi"}],+ tools = [{"type": "function", "function": {"name": name}}],+ execute_tool = _FakeExecuteTool(),+ session_id = session,+ confirm_tool_calls = True,+ permission_mode = "ask",+ ):+ events.append(ev)+ if ev["type"] == "tool_start" and ev.get("awaiting_confirmation"):+ resolve_tool_decision(ev["approval_id"], "allow", session_id = session)+ starts = _tool_starts(events)+ assert starts and starts[0]["awaiting_confirmation"] is gated++def test_unset_mode_behaves_as_auto():# Unset permission_mode is the product default "auto", so a safe call runs# without a prompt (the old "unset behaves as ask" gated even print(1)).