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: add a run setting to turn off tool-call deduplication (#11685)
frostyautumnleaff5aff5827bd5
diff --git a/studio/backend/core/inference/inference.py b/studio/backend/core/inference/inference.pyindex 52b7e9a1d13..cdc17ebcf0b 100644--- a/studio/backend/core/inference/inference.py+++ b/studio/backend/core/inference/inference.py@@ -1221,6 +1221,7 @@ class InferenceBackend:rag_scope: Optional[dict] = None,presence_penalty: float = 0.0,reasoning_prefilled: bool = False,+ deduplicate_tool_calls: bool = True,):"""Run an agentic tool loop on top of ``generate_chat_response``.@@ -1308,6 +1309,7 @@ class InferenceBackend:execute_tool = execute_tool,cancel_event = cancel_event,auto_heal_tool_calls = auto_heal_tool_calls,+ deduplicate_tool_calls = deduplicate_tool_calls,nudge_tool_calls = nudge_tool_calls,max_tool_iterations = max_tool_iterations,tool_call_timeout = tool_call_timeout,diff --git a/studio/backend/core/inference/llama_cpp.py b/studio/backend/core/inference/llama_cpp.pyindex d64d2dea36c..779463eea31 100644--- a/studio/backend/core/inference/llama_cpp.py+++ b/studio/backend/core/inference/llama_cpp.py@@ -36724,6 +36724,7 @@ class LlamaCppBackend:on_decode_slot: Optional[Callable[[str, int], None]] = None,thinking_budget_tokens: Optional[int] = None,mcp_image = None,+ deduplicate_tool_calls: bool = True,instruction_anchor_ids = None,sandbox_level: Optional[str] = None,) -> Generator[dict, None, None]:@@ -37045,6 +37046,7 @@ class LlamaCppBackend:tool_controller = ToolLoopController(tools = controller_tools,auto_heal_tool_calls = auto_heal_tool_calls,+ deduplicate_tool_calls = deduplicate_tool_calls,session_id = session_id,thread_id = thread_id,)@@ -38901,7 +38903,10 @@ class LlamaCppBackend:_novel_kept = 0_novel_at_last_keep: dict = {}_deduped: list = []- for _tc in tool_calls:+ if not deduplicate_tool_calls:+ _deduped = tool_calls[:_MAX_TOOL_CALLS_PER_TURN]+ _over_cap = tool_calls[_MAX_TOOL_CALLS_PER_TURN:]+ for _tc in tool_calls if deduplicate_tool_calls else ():_fn = _tc.get("function", {}) or {}_key = (_fn.get("name", ""), str(_fn.get("arguments", "")))if _fn.get("name") in _WORKSPACE_TOOLS:diff --git a/studio/backend/core/inference/openai_codex_tool_loop.py b/studio/backend/core/inference/openai_codex_tool_loop.pyindex e586ae8ce51..d76560f44d1 100644--- a/studio/backend/core/inference/openai_codex_tool_loop.py+++ b/studio/backend/core/inference/openai_codex_tool_loop.py@@ -50,6 +50,7 @@ class CodexToolPolicy:bypass_permissions: boolrag_scope: dict[str, Any] | Nonenudge_tool_calls: bool | None = None+ deduplicate_tool_calls: bool | None = Nonesandbox_level: str = "high"@@ -123,6 +124,7 @@ def stream_codex_with_studio_tools(rag_scope = policy.rag_scope,auto_heal = False,nudge_tool_calls = policy.nudge_tool_calls,+ deduplicate_tool_calls = policy.deduplicate_tool_calls,sandbox_level = policy.sandbox_level,),cancel_event = cancel_event,diff --git a/studio/backend/core/inference/orchestrator.py b/studio/backend/core/inference/orchestrator.pyindex 894ec5f3777..769d1d65064 100644--- a/studio/backend/core/inference/orchestrator.py+++ b/studio/backend/core/inference/orchestrator.py@@ -3098,6 +3098,7 @@ class InferenceOrchestrator:seed: Optional[int] = None,caller_image_indexes: "tuple[int, ...]" = (),mcp_image = None,+ deduplicate_tool_calls: bool = True,context_overflow: Optional[str] = None,context_policy: Optional[str] = None,compaction_headroom_ratio: Optional[float] = None,@@ -3280,6 +3281,7 @@ class InferenceOrchestrator:execute_tool = execute_tool,cancel_event = cancel_event,auto_heal_tool_calls = auto_heal_tool_calls,+ deduplicate_tool_calls = deduplicate_tool_calls,nudge_tool_calls = nudge_tool_calls,max_tool_iterations = max_tool_iterations,tool_call_timeout = tool_call_timeout,diff --git a/studio/backend/core/inference/safetensors_agentic.py b/studio/backend/core/inference/safetensors_agentic.pyindex e665f76b96e..481d1463e9b 100644--- a/studio/backend/core/inference/safetensors_agentic.py+++ b/studio/backend/core/inference/safetensors_agentic.py@@ -621,6 +621,7 @@ def run_safetensors_tool_loop(execute_tool: Callable[..., str],cancel_event: Optional[threading.Event] = None,auto_heal_tool_calls: bool = True,+ deduplicate_tool_calls: bool = True,nudge_tool_calls: Optional[bool] = None,max_tool_iterations: int = 25,tool_call_timeout: int = 300,@@ -771,6 +772,7 @@ def run_safetensors_tool_loop(tool_controller = ToolLoopController(tools = (None if unrestricted_tools else _authorized),auto_heal_tool_calls = auto_heal_tool_calls,+ deduplicate_tool_calls = deduplicate_tool_calls,session_id = session_id,thread_id = thread_id,)@@ -1421,7 +1423,10 @@ def run_safetensors_tool_loop(novel_kept = 0novel_at_last_keep: dict = {}deduped: list = []- for _tc in tool_calls:+ if not deduplicate_tool_calls:+ deduped = tool_calls[:_MAX_TOOL_CALLS_PER_TURN]+ over_cap = tool_calls[_MAX_TOOL_CALLS_PER_TURN:]+ for _tc in tool_calls if deduplicate_tool_calls else ():_fn = _tc.get("function", {}) or {}_key = (_fn.get("name", ""), str(_fn.get("arguments", "")))if _fn.get("name") in _WORKSPACE_TOOLS:diff --git a/studio/backend/core/inference/studio_tool_loop.py b/studio/backend/core/inference/studio_tool_loop.pyindex 67ce6fa4dc8..0613c095f66 100644--- a/studio/backend/core/inference/studio_tool_loop.py+++ b/studio/backend/core/inference/studio_tool_loop.py@@ -407,6 +407,8 @@ class ToolLoopPolicy:# Called when a provider turn ends, however it ended. Headerless only: clears the stripper's withheld-call flag,# which the wire cannot always close because a turn may end on [DONE] alone.on_provider_turn_end: Callable[[], None] | None = None+ # None keeps the request default (on); explicit booleans win.+ deduplicate_tool_calls: bool | None = Nonesandbox_level: str = "high"@@ -1486,6 +1488,7 @@ async def stream_with_studio_tools(controller = ToolLoopController(tools = tools,auto_heal_tool_calls = policy.auto_heal is not False,+ deduplicate_tool_calls = policy.deduplicate_tool_calls is not False,session_id = session_id,thread_id = thread_id,)diff --git a/studio/backend/core/inference/tool_loop_controller.py b/studio/backend/core/inference/tool_loop_controller.pyindex 07a95186b61..5210e8675c6 100644--- a/studio/backend/core/inference/tool_loop_controller.py+++ b/studio/backend/core/inference/tool_loop_controller.py@@ -1159,6 +1159,7 @@ class ToolLoopController:*,tools: Sequence[Mapping[str, Any]] | None,auto_heal_tool_calls: bool = True,+ deduplicate_tool_calls: bool = True,one_shot_tools: frozenset[str] = _ONE_SHOT_TOOLS,duplicate_noop_limit: int = 2,session_id: str | None = None,@@ -1172,6 +1173,7 @@ class ToolLoopController:name for name in (_tool_name_from_schema(tool) for tool in self._tools) if name}self._auto_heal_tool_calls = auto_heal_tool_calls+ self._deduplicate_tool_calls = deduplicate_tool_callsself._one_shot_tools = one_shot_toolsself._completed_one_shot_tools: set[str] = set()self._successful_keys: set[str] = set()@@ -1247,7 +1249,7 @@ class ToolLoopController:elif self._restrict_to_allowed and tool_name not in self._allowed_tool_names:action = "disabled"noop = _noop_result("disabled", tool_name)- elif key in self._successful_keys:+ elif self._deduplicate_tool_calls and key in self._successful_keys:action = "duplicate"noop = _noop_result("duplicate", tool_name)diff --git a/studio/backend/models/inference.py b/studio/backend/models/inference.pyindex 57b130cab47..7c3ec4c945c 100644--- a/studio/backend/models/inference.py+++ b/studio/backend/models/inference.py@@ -2858,6 +2858,14 @@ class ChatCompletionRequest(BaseModel):"UNSLOTH_TOOL_CALL_NUDGE=1 flips the process default."),)+ deduplicate_tool_calls: Optional[bool] = Field(+ True,+ description = (+ "[x-unsloth] When false, a tool call identical to one that already "+ "succeeded in this response runs again instead of being answered "+ "with a duplicate notice. Default on."+ ),+ )context_overflow: Optional[Literal["error", "truncate_middle", "truncate_oldest"]] = Field(None,description = (diff --git a/studio/backend/routes/chat_history.py b/studio/backend/routes/chat_history.pyindex 3c17c3fe167..885256008e7 100644--- a/studio/backend/routes/chat_history.py+++ b/studio/backend/routes/chat_history.py@@ -497,6 +497,7 @@ class ChatSettingsPayload(BaseModel):searchImages: Optional[bool] = NoneautoHealToolCalls: Optional[bool] = NonenudgeToolCalls: Optional[bool] = None+ deduplicateToolCalls: Optional[bool] = NonemaxToolCallsPerMessage: Optional[int] = Field(default = None, ge = 0)toolCallTimeout: Optional[int] = Field(default = None, ge = 1)diff --git a/studio/backend/routes/inference.py b/studio/backend/routes/inference.pyindex 73447d78f26..9b59515f6c7 100644--- a/studio/backend/routes/inference.py+++ b/studio/backend/routes/inference.py@@ -28678,6 +28678,7 @@ async def _proxy_to_external_provider(bypass_permissions = bool(payload.bypass_permissions),rag_scope = payload.rag_scope,nudge_tool_calls = payload.nudge_tool_calls,+ deduplicate_tool_calls = payload.deduplicate_tool_calls,)if studio_tool_payloadselse None@@ -29172,6 +29173,7 @@ async def _proxy_to_external_provider(rag_scope = payload.rag_scope,auto_heal = payload.auto_heal_tool_calls,nudge_tool_calls = payload.nudge_tool_calls,+ deduplicate_tool_calls = payload.deduplicate_tool_calls,# Matches the strip below: only a headerless caller has its calls# withheld, so only it needs a healed one the wire never carried flagged.on_withheld_tool_call = (None if _ui_events else _tool_call_stripper.arm),@@ -31664,6 +31666,7 @@ async def produce_openai_chat_completions(preserve_thinking = payload.preserve_thinking,continue_final_message = _continue_final_message(payload, thought = True),auto_heal_tool_calls = _gguf_auto_heal_tool_calls,+ deduplicate_tool_calls = payload.deduplicate_tool_calls is not False,nudge_tool_calls = payload.nudge_tool_calls,tool_choice = payload.tool_choice,max_tool_iterations = payload.max_tool_calls_per_message@@ -33795,6 +33798,7 @@ async def produce_openai_chat_completions(preserve_thinking = payload.preserve_thinking,continue_final_message = _sf_continue,auto_heal_tool_calls = _sf_auto_heal_tool_calls,+ deduplicate_tool_calls = payload.deduplicate_tool_calls is not False,nudge_tool_calls = payload.nudge_tool_calls,max_tool_iterations = _sf_tool_budget,tool_call_timeout = payload.tool_call_timeoutdiff --git a/studio/backend/routes/managed_engine_chat.py b/studio/backend/routes/managed_engine_chat.pyindex a6de6230056..82dd680c2c0 100644--- a/studio/backend/routes/managed_engine_chat.py+++ b/studio/backend/routes/managed_engine_chat.py@@ -234,6 +234,7 @@ async def managed_tool_chat(rag_scope = payload.rag_scope,auto_heal = payload.auto_heal_tool_calls,nudge_tool_calls = payload.nudge_tool_calls,+ deduplicate_tool_calls = payload.deduplicate_tool_calls,on_withheld_tool_call = None if ui_events else stripper.arm,on_provider_turn_end = None if ui_events else stripper.end_turn,),diff --git a/studio/backend/tests/test_llama_cpp_tool_loop.py b/studio/backend/tests/test_llama_cpp_tool_loop.pyindex 567a76ede62..44c251c6091 100644--- a/studio/backend/tests/test_llama_cpp_tool_loop.py+++ b/studio/backend/tests/test_llama_cpp_tool_loop.py@@ -1704,6 +1704,31 @@ def test_duplicate_web_search_noop_allows_distinct_followup_tool(monkeypatch):assert len(duplicate_nudges) == 1[email protected]("deduplicate", [True, False])+def test_rebuild_without_an_edit_runs_again_only_when_deduplication_is_off(+ monkeypatch, deduplicate+):+ # #10379: a second identical build command after no file edit is a duplicate by default.+ build = {"command": "./gradlew build"}+ streams = [+ [_tool_call_sse("terminal", build, "call_build_1"), _done()],+ [_tool_call_sse("terminal", build, "call_build_2"), _done()],+ [_sse({"content": "Built."}), _done()],+ ]+ backend = _make_backend(monkeypatch, streams, [])+ calls = _record_tool_calls(monkeypatch, lambda name: "BUILD SUCCESSFUL")++ _run_tool_loop(+ backend,+ [{"role": "user", "content": "build it twice"}],+ [{"type": "function", "function": {"name": "terminal"}}],+ max_tool_iterations = 3,+ deduplicate_tool_calls = deduplicate,+ )++ assert calls == [("terminal", build)] * (1 if deduplicate else 2)++def test_repeated_duplicate_noop_transitions_to_final_pass(monkeypatch):first_search = [_tool_call_sse("web_search", {"query": "gpu prices 2026"}, "call_search_1"),@@ -5226,6 +5251,33 @@ def test_gguf_textual_fallback_collapses_duplicate_tool_calls(monkeypatch):assert len(calls) == 1, [c[0] for c in calls][email protected]("deduplicate", [True, False])+def test_gguf_textual_fallback_keeps_identical_calls_when_deduplication_is_off(+ monkeypatch, deduplicate+):+ blocks = '<tool_call>{"name":"web_search","arguments":{"query":"cats"}}</tool_call>' * 3+ first_stream = [_sse({"content": blocks}), _done()]+ final_stream = [_sse({"content": "done"}), _done()]+ backend, _payloads = _backend_and_payloads(monkeypatch, [first_stream, final_stream])++ calls: list[tuple[str, dict]] = []+ monkeypatch.setattr(+ "core.inference.tools.execute_tool",+ lambda name, arguments, **_k: calls.append((name, arguments)) or "OK",+ )++ list(+ backend.generate_chat_completion_with_tools(+ messages = [{"role": "user", "content": "cats"}],+ tools = [{"type": "function", "function": {"name": "web_search"}}],+ max_tool_iterations = 1,+ deduplicate_tool_calls = deduplicate,+ )+ )++ assert len(calls) == (1 if deduplicate else 3), [c[0] for c in calls]++def test_gguf_drain_truncated_enabled_name_json_preserved_when_auto_heal_disabled(monkeypatch):"""Auto-Heal OFF keeps a truncated enabled-name fragment visible; ON suppresses it (strip gated on auto_heal_tool_calls)."""diff --git a/studio/backend/tests/test_managed_engine_tools.py b/studio/backend/tests/test_managed_engine_tools.pyindex 7f0addc1fb5..b287eeb1532 100644--- a/studio/backend/tests/test_managed_engine_tools.py+++ b/studio/backend/tests/test_managed_engine_tools.py@@ -289,6 +289,33 @@ def test_run_automatically_streams_arm_the_no_sandbox_gate(native, monkeypatch):assert seen == [True][email protected]("dedup", [None, False, True])+def test_deduplicate_tool_calls_reaches_the_managed_loop(native, monkeypatch, dedup):+ from core.inference import studio_tool_loop+ from routes import managed_engine_chat++ seen = []+ original = managed_engine_chat.stream_with_studio_tools++ def capture(*args, **kwargs):+ seen.append(kwargs["policy"].deduplicate_tool_calls is not False)+ return original(*args, **kwargs)++ monkeypatch.setattr(managed_engine_chat, "stream_with_studio_tools", capture)+ monkeypatch.setattr(studio_tool_loop, "execute_tool", lambda *a, **k: "3973")+ extra = {} if dedup is None else {"deduplicate_tool_calls": dedup}+ run(+ route_test._request(+ enable_tools = True,+ enabled_tools = ["python"],+ permission_mode = "off",+ max_tool_calls_per_message = 1,+ **extra,+ )+ )+ assert seen == [dedup is not False]++@pytest.mark.parametrize("choice", ["auto", "required", "none", {"type": "function", "function": {"name": "lookup"}}])diff --git a/studio/backend/tests/test_safetensors_tool_loop.py b/studio/backend/tests/test_safetensors_tool_loop.pyindex 9dba6d99f1c..38c929328e7 100644--- a/studio/backend/tests/test_safetensors_tool_loop.py+++ b/studio/backend/tests/test_safetensors_tool_loop.py@@ -2795,6 +2795,31 @@ class TestLoopBehaviour:)assert "previous tool request" not in after[1]["content"].lower()+ @pytest.mark.parametrize("deduplicate", [True, False])+ def test_identical_calls_in_one_turn_run_when_deduplication_is_off(self, deduplicate):+ call = '<tool_call>{"name":"python","arguments":{"code":"print(1)"}}</tool_call>'+ turns = iter([[call * 2], ["final"]])++ def fake_single_turn(messages, active_tools = None):+ acc = ""+ for chunk in next(turns):+ acc += chunk+ yield acc++ exec_fn = FakeExecuteTool(["1", "1"])+ _collect_events(+ run_safetensors_tool_loop(+ single_turn = fake_single_turn,+ messages = [{"role": "user", "content": "run it twice"}],+ tools = [{"type": "function", "function": {"name": "python"}}],+ execute_tool = exec_fn,+ max_tool_iterations = 4,+ deduplicate_tool_calls = deduplicate,+ )+ )++ assert exec_fn.calls == [("python", {"code": "print(1)"})] * (1 if deduplicate else 2)+def test_duplicate_tool_call_internal_noop_allows_distinct_followup_tool(self):captured_messages: list[list[dict]] = []captured_tool_names: list[list[str]] = []diff --git a/studio/backend/tests/test_tool_loop_controller.py b/studio/backend/tests/test_tool_loop_controller.pyindex 6f61834470b..792dbb1a1eb 100644--- a/studio/backend/tests/test_tool_loop_controller.py+++ b/studio/backend/tests/test_tool_loop_controller.py@@ -264,6 +264,22 @@ def test_repeated_successful_duplicate_becomes_terminal_after_one_recovery_nudgeassert controller.active_tools() == []+def test_deduplication_can_be_disabled():+ controller = ToolLoopController(+ tools = [_tool("web_search"), _tool("python")],+ deduplicate_tool_calls = False,+ )+ first = controller.prepare_call(_call("web_search", {"query": "gpu prices"}, "call_a"))+ controller.record_result(first, "ok")++ repeat = controller.prepare_call(_call("web_search", {"query": "gpu prices"}, "call_b"))+ assert repeat.action == "execute"+ assert repeat.should_execute+ controller.record_result(repeat, "ok")+ assert not controller.force_final_answer+ _shared_setup_1(controller)++def test_command_can_run_again_after_a_file_edit():controller = ToolLoopController(tools = [_tool("terminal"), _tool("edit_file"), _tool("web_search")]diff --git a/studio/frontend/src/features/chat/api/chat-adapter.ts b/studio/frontend/src/features/chat/api/chat-adapter.tsindex aacb4b30ae5..f0a417c9ef9 100644--- a/studio/frontend/src/features/chat/api/chat-adapter.ts+++ b/studio/frontend/src/features/chat/api/chat-adapter.ts@@ -6778,6 +6778,7 @@ export function createOpenAIStreamAdapter(// false, not omitted: omission follows UNSLOTH_TOOL_CALL_NUDGE, which the// launchers set to 1 when unset, so this loop would keep nudging (#9686, #9125).nudge_tool_calls: false,+ deduplicate_tool_calls: runtime.deduplicateToolCalls,// This branch runs the tools here, so say so by name: enabled_tools ["web_search"] is// byte-identical to an older bundle's hosted search.run_tools_locally: true,@@ -7019,6 +7020,7 @@ export function createOpenAIStreamAdapter(: {}),auto_heal_tool_calls: runtime.autoHealToolCalls,nudge_tool_calls: runtime.nudgeToolCalls,+ deduplicate_tool_calls: runtime.deduplicateToolCalls,max_tool_calls_per_message: runtime.maxToolCallsPerMessage,tool_call_timeout: (() => {const mins = runtime.toolCallTimeout;diff --git a/studio/frontend/src/features/chat/api/chat-settings-api.ts b/studio/frontend/src/features/chat/api/chat-settings-api.tsindex f5723b9d946..d547722c7c0 100644--- a/studio/frontend/src/features/chat/api/chat-settings-api.ts+++ b/studio/frontend/src/features/chat/api/chat-settings-api.ts@@ -49,6 +49,7 @@ export interface PersistedChatSettings {searchImages?: boolean;autoHealToolCalls?: boolean;nudgeToolCalls?: boolean;+ deduplicateToolCalls?: boolean;maxToolCallsPerMessage?: number;toolCallTimeout?: number;reasoningEnabled?: boolean;diff --git a/studio/frontend/src/features/chat/chat-settings-sheet.tsx b/studio/frontend/src/features/chat/chat-settings-sheet.tsxindex 45b50113f17..48840e7e355 100644--- a/studio/frontend/src/features/chat/chat-settings-sheet.tsx+++ b/studio/frontend/src/features/chat/chat-settings-sheet.tsx@@ -1702,6 +1702,7 @@ export function ChatSettingsPanel({<div className="flex flex-col gap-5"><AutoHealToolCallsToggle /><NudgeToolCallsToggle />+ <DeduplicateToolCallsToggle /><ConfirmToolCallsToggle /><BypassPermissionsToggle /><MaxToolCallsSlider />@@ -2040,6 +2041,35 @@ function NudgeToolCallsToggle() {);}+function DeduplicateToolCallsToggle() {+ const deduplicateToolCalls = useChatRuntimeStore(+ (s) => s.deduplicateToolCalls,+ );+ const setDeduplicateToolCalls = useChatRuntimeStore(+ (s) => s.setDeduplicateToolCalls,+ );++ return (+ <div className="flex min-h-8 items-center justify-between gap-3">+ <div className="flex min-w-0 items-center gap-1.5">+ <span className="min-w-0 text-ui-13 font-medium leading-[1.25] tracking-nav text-nav-fg">+ Deduplicate Tool Calls+ </span>+ <InfoHint>+ Skips a tool call identical to one that already succeeded in this+ response and tells the model it was a duplicate. Turn off to let a+ repeated call run again.+ </InfoHint>+ </div>+ <Switch+ className="panel-switch shrink-0"+ checked={deduplicateToolCalls}+ onCheckedChange={setDeduplicateToolCalls}+ />+ </div>+ );+}+function ConfirmToolCallsToggle() {const setConfirmToolCalls = useChatRuntimeStore((s) => s.setConfirmToolCalls);const setPermissionMode = useChatRuntimeStore((s) => s.setPermissionMode);diff --git a/studio/frontend/src/features/chat/stores/chat-runtime-store.ts b/studio/frontend/src/features/chat/stores/chat-runtime-store.tsindex 06a3d99e575..395d5affecf 100644--- a/studio/frontend/src/features/chat/stores/chat-runtime-store.ts+++ b/studio/frontend/src/features/chat/stores/chat-runtime-store.ts@@ -2444,6 +2444,7 @@ type ChatRuntimeStore = {generatingStatus: string | null;autoHealToolCalls: boolean;nudgeToolCalls: boolean;+ deduplicateToolCalls: boolean;autoCompactEnabled: boolean;maxToolCallsPerMessage: number;toolCallTimeout: number;@@ -2741,6 +2742,7 @@ type ChatRuntimeStore = {clearActiveDiffusionCanvasForThread: (threadId: string | null) => void;setAutoHealToolCalls: (enabled: boolean) => void;setNudgeToolCalls: (enabled: boolean) => void;+ setDeduplicateToolCalls: (enabled: boolean) => void;setAutoCompactEnabled: (enabled: boolean) => void;setMaxToolCallsPerMessage: (value: number) => void;setToolCallTimeout: (value: number) => void;@@ -2786,6 +2788,7 @@ type ScalarSettingKey =| "searchImages"| "autoHealToolCalls"| "nudgeToolCalls"+ | "deduplicateToolCalls"| "autoCompactEnabled"| "maxToolCallsPerMessage"| "toolCallTimeout"@@ -2837,6 +2840,7 @@ const SCALAR_SETTING_KEYS = ["searchImages","autoHealToolCalls","nudgeToolCalls",+ "deduplicateToolCalls","autoCompactEnabled","maxToolCallsPerMessage","toolCallTimeout",@@ -4235,6 +4239,7 @@ export const useChatRuntimeStore = create<ChatRuntimeStore>((set, get) => ({activeDiffusionCanvasByThreadId: {},autoHealToolCalls: true,nudgeToolCalls: true,+ deduplicateToolCalls: true,autoCompactEnabled: DEFAULT_AUTO_COMPACT_ENABLED,maxToolCallsPerMessage: 25,toolCallTimeout: 5,@@ -5876,6 +5881,18 @@ export const useChatRuntimeStore = create<ChatRuntimeStore>((set, get) => ({queuedSettingsEpoch: state.queuedSettingsEpoch + 1,};}),+ setDeduplicateToolCalls: (deduplicateToolCalls) =>+ set((state) => {+ setScalarSettingVersion(+ "deduplicateToolCalls",+ deduplicateToolCalls,+ state.deduplicateToolCalls,+ );+ return {+ deduplicateToolCalls,+ queuedSettingsEpoch: state.queuedSettingsEpoch + 1,+ };+ }),setAutoCompactEnabled: (autoCompactEnabled) =>set((state) => {setScalarSettingVersion(diff --git a/studio/frontend/src/features/chat/types/api.ts b/studio/frontend/src/features/chat/types/api.tsindex 0e30f98736a..7e2d05800eb 100644--- a/studio/frontend/src/features/chat/types/api.ts+++ b/studio/frontend/src/features/chat/types/api.ts@@ -735,6 +735,7 @@ export interface OpenAIChatCompletionsRequest {/** Run the selected tools here rather than as the provider's hosted builtins. */run_tools_locally?: boolean;nudge_tool_calls?: boolean;+ deduplicate_tool_calls?: boolean;/** Local GGUF overflow policy. Rolling mode preserves the transcript but omits oldest turns. */context_overflow?: "error" | "truncate_middle" | "truncate_oldest";/** Override UNSLOTH_CONTEXT_POLICY for this local GGUF request. */diff --git a/studio/frontend/src/features/chat/utils/chat-settings-storage.ts b/studio/frontend/src/features/chat/utils/chat-settings-storage.tsindex 713717412af..a7ab63cf135 100644--- a/studio/frontend/src/features/chat/utils/chat-settings-storage.ts+++ b/studio/frontend/src/features/chat/utils/chat-settings-storage.ts@@ -298,6 +298,7 @@ export function sanitizeChatSettings(value: unknown): PersistedChatSettings {);const autoHealToolCalls = sanitizeBool(value.autoHealToolCalls);const nudgeToolCalls = sanitizeBool(value.nudgeToolCalls);+ const deduplicateToolCalls = sanitizeBool(value.deduplicateToolCalls);const autoCompactEnabled = sanitizeBool(value.autoCompactEnabled);const maxToolCallsPerMessage = sanitizeInt(value.maxToolCallsPerMessage, 0);const toolCallTimeout = sanitizeInt(value.toolCallTimeout, 1);@@ -330,6 +331,9 @@ export function sanitizeChatSettings(value: unknown): PersistedChatSettings {if (nudgeToolCalls !== undefined) {settings.nudgeToolCalls = nudgeToolCalls;}+ if (deduplicateToolCalls !== undefined) {+ settings.deduplicateToolCalls = deduplicateToolCalls;+ }if (autoCompactEnabled !== undefined) {settings.autoCompactEnabled = autoCompactEnabled;}@@ -397,6 +401,7 @@ export function isEmptyChatSettings(settings: PersistedChatSettings): boolean {settings.allowArtifactNetworkAccess === undefined &&settings.autoHealToolCalls === undefined &&settings.nudgeToolCalls === undefined &&+ settings.deduplicateToolCalls === undefined &&settings.autoCompactEnabled === undefined &&settings.maxToolCallsPerMessage === undefined &&settings.toolCallTimeout === undefined &&diff --git a/studio/frontend/src/features/chat/utils/queued-chat-run-settings.ts b/studio/frontend/src/features/chat/utils/queued-chat-run-settings.tsindex 7f33397c174..68a7ff4793c 100644--- a/studio/frontend/src/features/chat/utils/queued-chat-run-settings.ts+++ b/studio/frontend/src/features/chat/utils/queued-chat-run-settings.ts@@ -44,6 +44,7 @@ const QUEUED_SETTING_KEYS = ["loadedIsMlx","autoHealToolCalls","nudgeToolCalls",+ "deduplicateToolCalls","maxToolCallsPerMessage","toolCallTimeout","autoCompactEnabled",