Skip to content

Commit 0033c84

Browse files
committed
Studio: let Bypass Permissions suppress the confirm-tool-calls guards
The confirm-vs-bypass precedence (confirm and not bypass) was applied at the loop call sites but not at the earlier request guards, so a client sending confirm_tool_calls + bypass_permissions together was rejected (stream=true required / unsupported for external or Anthropic tools) before the precedence took effect. Gate all four confirm guards on not bypass_permissions so both flags together proceed with the gate suppressed, matching the documented rule.
1 parent 78db58a commit 0033c84

1 file changed

Lines changed: 21 additions & 4 deletions

File tree

studio/backend/routes/inference.py

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3505,7 +3505,9 @@ async def openai_chat_completions(
35053505
# ── External provider routing ────────────────────────────────
35063506
# encrypted_api_key is optional -- local providers (llama.cpp / vLLM / Ollama) may run without auth.
35073507
if payload.provider_id or payload.provider_type:
3508-
if payload.confirm_tool_calls and (
3508+
# Bypass Permissions suppresses the confirm gate, so do not reject a
3509+
# request that sets both flags (effective confirm is then False).
3510+
if payload.confirm_tool_calls and not payload.bypass_permissions and (
35093511
payload.enable_tools is True
35103512
or bool(payload.enabled_tools)
35113513
or bool(payload.tools)
@@ -3892,7 +3894,13 @@ async def audio_input_stream():
38923894
use_tools = False
38933895

38943896
if use_tools:
3895-
if payload.confirm_tool_calls and not payload.stream:
3897+
# Bypass Permissions suppresses confirm, so the stream requirement
3898+
# (the gate needs streaming to prompt) no longer applies.
3899+
if (
3900+
payload.confirm_tool_calls
3901+
and not payload.bypass_permissions
3902+
and not payload.stream
3903+
):
38963904
raise HTTPException(
38973905
status_code = 400,
38983906
detail = openai_error_body(
@@ -4441,7 +4449,13 @@ async def gguf_stream_chunks():
44414449
_sf_use_tools = False
44424450

44434451
if _sf_use_tools:
4444-
if payload.confirm_tool_calls and not payload.stream:
4452+
# Bypass Permissions suppresses confirm, so the stream requirement
4453+
# (the gate needs streaming to prompt) no longer applies.
4454+
if (
4455+
payload.confirm_tool_calls
4456+
and not payload.bypass_permissions
4457+
and not payload.stream
4458+
):
44454459
raise HTTPException(
44464460
status_code = 400,
44474461
detail = openai_error_body(
@@ -6868,7 +6882,10 @@ async def anthropic_messages(
68686882
)
68696883

68706884
if server_tools:
6871-
if bool(getattr(payload, "confirm_tool_calls", False)):
6885+
# Bypass Permissions suppresses confirm, so both flags together is fine.
6886+
if bool(getattr(payload, "confirm_tool_calls", False)) and not bool(
6887+
getattr(payload, "bypass_permissions", False)
6888+
):
68726889
raise HTTPException(
68736890
status_code = 400,
68746891
detail = anthropic_error_body(

0 commit comments

Comments
 (0)