{"record":{"id":"1f0f5eaa52e2850c","repo":"unslothai/unsloth","slug":"llama-server-flag-flag-is-managed-by-unsloth-s","errorCode":null,"errorMessage":"llama-server flag '{flag}' is managed by Unsloth Studio and cannot be passed as an extra arg","messagePattern":"llama-server flag '(.+?)' is managed by Unsloth Studio and cannot be passed as an extra arg","errorType":"validation","errorClass":"ValueError","httpStatus":400,"severity":"error","filePath":"studio/backend/core/inference/llama_server_args.py","lineNumber":274,"sourceCode":"        # subprocess.Popen raise while it encodes argv, long after the load has begun\n        # switching models. Refused at the boundary, where it is still a 400.\n        try:\n            encoded = token.encode(\"utf-8\")\n        except UnicodeEncodeError as error:\n            raise ValueError(\n                \"extra llama-server args cannot contain unpaired surrogate characters\"\n            ) from error\n        total_bytes += len(encoded)\n        limit = max_extra_args_bytes()\n        if total_bytes > limit:\n            raise ValueError(f\"extra llama-server args are too large (limit {limit} bytes)\")\n        # execve rejects a NUL outright; the rest would reach the child's parser as\n        # invisible characters and be blamed on the flag they are attached to.\n        if _has_control_characters(token):\n            raise ValueError(\"extra llama-server args cannot contain control characters\")\n        flag = _flag_name(token)\n        if flag is not None and flag in _DENYLIST:\n            raise ValueError(\n                f\"llama-server flag '{flag}' is managed by Unsloth Studio \"\n                f\"and cannot be passed as an extra arg\"\n            )\n        if flag is None:\n            # A token belonging to no flag. Today's llama-server answers \"invalid\n            # argument\" and refuses to start, which is a failed load rather than a\n            # 400, and a build that did accept a positional would read it as the\n            # model path: that is the one thing the -m / --model denial exists to\n            # prevent, and it would sidestep the native-path lease as well.\n            if pending_values <= 0:\n                raise ValueError(\n                    \"extra llama-server args cannot contain a bare value \"\n                    f\"('{token[:64]}'); every value must follow its flag\"\n                )\n            pending_values -= 1\n            if pending_two_value > 0:\n                pending_two_value -= 1\n        elif token != token.strip():","sourceCodeStart":256,"sourceCodeEnd":292,"githubUrl":"https://github.com/unslothai/unsloth/blob/203007d19051dcd2ae33876786d117c99f6b0368/studio/backend/core/inference/llama_server_args.py#L256-L292","documentation":"ValueError from llama_server_args.py:274 — a flag-shaped token whose name (after _flag_name normalization) is in _DENYLIST. Unsloth Studio manages certain llama-server flags itself (--model/-m, context/cache/GPU-layer controls, etc.); letting the user override them would break model switching, sidestep the native-path lease, or fight the studio's own lifecycle. The denial message names the exact flag.","triggerScenarios":"Including a managed flag in extra args: -m/--model (would redirect the model path and bypass the path lease), or flags the studio sets itself such as context-size, cache, split-mode overrides (the same families parse_ctx_override/parse_cache_override/parse_split_mode/parse_gpu_layers_override handle).","commonSituations":"Copy-pasting a full llama-server launch line into the extra-args field; trying to force --ctx-size or -ngl through extra args because a UI control exists for it already; underscore/case spellings (--ctx_size) that _flag_name normalizes to the denied name.","solutions":["Remove the denied flag from extra args and set the equivalent through the studio's own UI/API fields (context size, GPU layers, cache type all have first-class controls).","Check the message for the exact flag name; watch for alternate spellings (-m vs --model, underscores vs dashes) that normalize to the same denied flag.","If you genuinely need a managed parameter changed, look for the dedicated config key rather than the raw flag.","Use drop_managed_flags() to split stored args into what still loads vs what was removed when migrating old configs."],"exampleFix":"# before\nextra_args = [\"--model\", \"/other/model.gguf\", \"--top-k\", \"40\"]\n\n# after\nextra_args = [\"--top-k\", \"40\"]\n# set the model through the studio's model-selection API instead","handlingStrategy":"validation","validationCode":"from core.inference.llama_server_args import drop_managed_flags\nkept, removed = drop_managed_args = drop_managed_flags(extra_args)\nif removed:\n    warn(f\"removed studio-managed flags: {removed}\")","typeGuard":"def is_managed_flag(token) -> bool:\n    name = _flag_name(token)\n    return name is not None and name in _DENYLIST","tryCatchPattern":"try:\n    validate_extra_args(args)\nexcept ValueError as e:\n    if \"managed by Unsloth Studio\" in str(e):\n        raise HTTPException(400, \"set model/ctx via studio settings, not extra args\")\n    raise","preventionTips":["Never paste a full llama-server launch line into extra args; only pass knobs the studio does not own.","Set model path, context size, cache type, GPU layers through their dedicated studio settings.","Run drop_managed_flags() on imported/stored configs to clean them once.","Remember underscore/dash and -m/--model spellings normalize to the same denied flag."],"tags":["llama-server","denylist","managed-flags","validation","configuration"],"backgroundTag":null,"analyzedSha":"203007d19051dcd2ae33876786d117c99f6b0368","analyzedAt":"2026-08-15T02:48:39.846Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}