From 3849f5d80d5b904cf745fe723da4b5a3439f8733 Mon Sep 17 00:00:00 2001 From: Daniel Han Date: Wed, 18 Mar 2026 15:42:26 +0000 Subject: [PATCH 1/2] Fix TypeScript build errors in studio frontend - tool-ui-python.tsx: use explicit tuple type instead of `as const` to match the mutable `[BundledTheme, BundledTheme]` expected by Streamdown - chat-adapter.ts: add missing `argsText` field required by ToolCallMessagePart and fix `args` type to use ReadonlyJSONObject --- .../src/components/assistant-ui/tool-ui-python.tsx | 2 +- studio/frontend/src/features/chat/api/chat-adapter.ts | 8 +++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/studio/frontend/src/components/assistant-ui/tool-ui-python.tsx b/studio/frontend/src/components/assistant-ui/tool-ui-python.tsx index 760efc8db4..28468a10ad 100644 --- a/studio/frontend/src/components/assistant-ui/tool-ui-python.tsx +++ b/studio/frontend/src/components/assistant-ui/tool-ui-python.tsx @@ -17,7 +17,7 @@ import { const MAX_DISPLAY = 10_000; const COPY_RESET_MS = 2000; -const SHIKI_THEME = ["github-light", "github-dark"] as const; +const SHIKI_THEME = ["github-light", "github-dark"] as ["github-light", "github-dark"]; function truncate(text: string): string { return text.length <= MAX_DISPLAY diff --git a/studio/frontend/src/features/chat/api/chat-adapter.ts b/studio/frontend/src/features/chat/api/chat-adapter.ts index 0d25db2997..13ba64a5a8 100644 --- a/studio/frontend/src/features/chat/api/chat-adapter.ts +++ b/studio/frontend/src/features/chat/api/chat-adapter.ts @@ -2,7 +2,7 @@ // Copyright 2026-present the Unsloth AI Inc. team. All rights reserved. See /studio/LICENSE.AGPL-3.0 import type { ChatModelAdapter } from "@assistant-ui/react"; -import type { MessageTiming } from "@assistant-ui/core"; +import type { MessageTiming, ToolCallMessagePart } from "@assistant-ui/core"; import { toast } from "sonner"; import { generateAudio, @@ -527,7 +527,7 @@ export function createOpenAIStreamAdapter(): ChatModelAdapter { let reasoningDuration = 0; // Tool call content parts — accumulated and yielded cumulatively. // result is set directly on the tool-call part when tool_end arrives. - const toolCallParts: { type: "tool-call"; toolCallId: string; toolName: string; args: Record; result?: unknown }[] = []; + const toolCallParts: ToolCallMessagePart[] = []; try { const { supportsReasoning, reasoningEnabled } = runtime; @@ -582,11 +582,13 @@ export function createOpenAIStreamAdapter(): ChatModelAdapter { if (toolEvent !== undefined) { if (toolEvent.type === "tool_start") { const id = (toolEvent.tool_call_id as string) || `${toolEvent.tool_name}_${Date.now()}`; + const toolArgs = (toolEvent.arguments ?? {}) as ToolCallMessagePart["args"]; toolCallParts.push({ type: "tool-call" as const, toolCallId: id, toolName: toolEvent.tool_name as string, - args: (toolEvent.arguments as Record) ?? {}, + argsText: JSON.stringify(toolArgs), + args: toolArgs, }); } else if (toolEvent.type === "tool_end") { const id = (toolEvent.tool_call_id as string) || From 973532786a8d4bb67fe4e28b9f77e567ff1ddffe Mon Sep 17 00:00:00 2001 From: Daniel Han Date: Wed, 18 Mar 2026 15:58:00 +0000 Subject: [PATCH 2/2] Fix studio crash on Mac by deferring unsloth_zoo import Move `from unsloth_zoo.rl_environments import check_signal_escape_patterns` from module-level to inside `_check_code_safety()` and wrap it in a try/except for NotImplementedError. The top-level import triggers `unsloth_zoo.__init__` which calls `get_device_type()` at module scope, raising NotImplementedError on Apple Silicon. On Mac the safety check gracefully skips since unsloth_zoo is unavailable, while GGUF inference via llama.cpp continues to work. --- studio/backend/core/inference/tools.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/studio/backend/core/inference/tools.py b/studio/backend/core/inference/tools.py index 159facabe9..90c0933dc0 100644 --- a/studio/backend/core/inference/tools.py +++ b/studio/backend/core/inference/tools.py @@ -17,7 +17,6 @@ import tempfile import threading from loggers import get_logger -from unsloth_zoo.rl_environments import check_signal_escape_patterns logger = get_logger(__name__) @@ -171,6 +170,11 @@ def _check_code_safety(code: str) -> str | None: Returns an error message string if the code is unsafe, or None if OK. """ # Check for signal/timeout escape patterns + try: + from unsloth_zoo.rl_environments import check_signal_escape_patterns + except (ImportError, NotImplementedError): + # unsloth_zoo may not be available or may fail on non-GPU platforms (e.g. Mac) + return None safe, info = check_signal_escape_patterns(code) if not safe: reasons = [