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
unsloth start dsh: warn when the loaded context leaves replies no room (#14352)
Daniel Han64814142defe
diff --git a/unsloth_cli/commands/start.py b/unsloth_cli/commands/start.pyindex 9a27aa37e1d..c6a0c4c8084 100644--- a/unsloth_cli/commands/start.py+++ b/unsloth_cli/commands/start.py@@ -82,6 +82,8 @@ _DSH_PACKAGE = "@deepseek-ai/dsh"# dsh picks its sandbox+approval preset from DSH_PERMISSION_MODE via ??, so omitting it would inherit a danger-full-access exported in the parent shell, and "" is not unset to ??. Pin the mode in both directions instead of only setting it for --yolo._DSH_SAFE_PERMISSION_MODE = "workspace-write"_DSH_YOLO_PERMISSION_MODE = "danger-full-access"+# dsh's pi-ai provider sends max_tokens = contextWindow - its prompt estimate - 4,096 (pi-ai CONTEXT_SAFETY_TOKENS), floored at 1, and dsh's own instructions and tools are about 6,500 tokens: at 8,192 every reply is cut after one token (#14315).+_DSH_MIN_CONTEXT = 16384_PI_PROVIDER = "unsloth"_SUBAGENT_NAME = "unsloth"_SUBAGENT_DESCRIPTION = (@@ -7576,6 +7578,16 @@ def dsh(launch = launch,server_options = server_options,)+ window = entry.get("context_length") or entry.get("max_context_length")+ if window and int(window) < _DSH_MIN_CONTEXT:+ typer.echo(+ f"Warning: {entry['id']} is loaded with {int(window):,} tokens of context, too few "+ "for DeepSeek Harness: its instructions and tools take about 6,500 and it keeps "+ "4,096 in reserve, so replies are cut short (at 8,192, after a single token). "+ f"Load it with --max-seq-length {_DSH_MIN_CONTEXT} or more (a smaller quant if "+ "that does not fit in memory) and re-run unsloth start dsh.",+ err = True,+ )with _session_config("dsh", launch, persist = persist) as home:patch = home / _DSH_PATCH_FILEwrite_dsh_patch(base, entry, patch, server_options.request_body())diff --git a/unsloth_cli/tests/test_start.py b/unsloth_cli/tests/test_start.pyindex 3b94077c913..517676a363e 100644--- a/unsloth_cli/tests/test_start.py+++ b/unsloth_cli/tests/test_start.py@@ -7532,6 +7532,16 @@ def test_connect_dsh_no_launch(fake_studio, tmp_path):assert not (home / "settings.yaml").exists()[email protected]("window, warned", [(8_192, True), (12_288, True), (16_384, False)])+def test_dsh_warns_when_the_context_leaves_replies_no_room(fake_studio, window, warned):+ # #14315: at 8,192 dsh sends max_tokens 1, so every reply is "The" and nothing else.+ fake_studio.state["models"] = [{**MODEL, "context_length": window}]+ result = CliRunner().invoke(start.start_app, ["dsh", "--no-launch"])+ assert result.exit_code == 0, result.output+ assert (f"loaded with {window:,} tokens of context, too few" in result.output) is warned+ assert ("--max-seq-length 16384" in result.output) is warned++def _vibe_settings(env: dict) -> tuple:return json.loads(env["VIBE_PROVIDERS"]), json.loads(env["VIBE_MODELS"])