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: accept skills whose description has an unquoted colon (#14537)
Nilay57f4e859e287
diff --git a/studio/backend/core/inference/skills.py b/studio/backend/core/inference/skills.pyindex fd43a73c305..a948da1ee06 100644--- a/studio/backend/core/inference/skills.py+++ b/studio/backend/core/inference/skills.py@@ -7,6 +7,7 @@ import errnoimport jsonimport loggingimport os+import reimport shutilimport statimport tempfile@@ -50,6 +51,9 @@ _WINDOWS_RESERVED_STEMS = frozenset(| {f"lpt{index}" for index in "¹²³"})_WINDOWS_INVALID_CHARS = frozenset('<>:"|?*')+# Only plain scalars are repaired; a rejected quoted, block, flow, anchored or tagged value is broken.+_FRONTMATTER_KEY = re.compile(r"([a-zA-Z_-]+):[ \t]+(?=[^\s\"'|>&!\[{])(?![-?:]\s)")+MAX_FRONTMATTER_REPAIRS = 16class SkillError(ValueError):@@ -284,6 +288,49 @@ def _read_limited(return raw+def _quote_frontmatter_value(text: str, line: int) -> Optional[tuple[str, str, str]]:+ lines = text.splitlines(keepends = True)+ match = _FRONTMATTER_KEY.match(lines[line]) if line < len(lines) else None+ if match is None:+ return None+ rest = lines[line][match.end() :]+ value = rest.splitlines()[0]+ ending = rest[len(value) :]+ value = re.sub(r"[ \t]+#.*", "", value).rstrip()+ if not re.search(r":[ \t]", value):+ return None+ quoted = value.replace("\\", "\\\\").replace('"', '\\"')+ lines[line] = f'{lines[line][: match.end()]}"{quoted}"{ending}'+ return "".join(lines), match.group(1), value+++def _load_frontmatter(text: str):+ repaired = []+ for _ in range(MAX_FRONTMATTER_REPAIRS):+ try:+ frontmatter = yaml.safe_load(text)+ break+ except (yaml.scanner.ScannerError, yaml.composer.ComposerError) as exc:+ # Agent skill loaders accept unquoted values such as `description: Use when: ...`.+ # Parser errors are structural, such as a colon inside a flow collection.+ repair = (+ _quote_frontmatter_value(text, exc.problem_mark.line) if exc.problem_mark else None+ )+ if repair is None:+ raise+ text, key, value = repair+ repaired.append((key, value))+ else:+ frontmatter = yaml.safe_load(text)+ # A line that only looked top-level, such as one inside a flow mapping, would not read back.+ if repaired and (+ not isinstance(frontmatter, dict)+ or any(frontmatter.get(key) != value for key, value in repaired)+ ):+ raise yaml.YAMLError("Repaired frontmatter does not read back as written.")+ return frontmatter++def _split_skill_markdown(raw: bytes) -> tuple[dict, str]:if len(raw) > MAX_SKILL_MD_BYTES:raise SkillError("SKILL.md exceeds the 512 KB limit.")@@ -301,7 +348,7 @@ def _split_skill_markdown(raw: bytes) -> tuple[dict, str]:if closing is None:raise SkillError("SKILL.md YAML frontmatter is not closed.")try:- frontmatter = yaml.safe_load("".join(lines[1:closing]))+ frontmatter = _load_frontmatter("".join(lines[1:closing]))except (yaml.YAMLError,AttributeError,diff --git a/studio/backend/tests/test_skills.py b/studio/backend/tests/test_skills.pyindex 81bae70d189..64471c81aad 100644--- a/studio/backend/tests/test_skills.py+++ b/studio/backend/tests/test_skills.py@@ -156,6 +156,28 @@ def test_bundled_image_prompting_skill_parses_and_ships_disabled(isolated_skills"---\nname: bad-metadata\ndescription: valid\nmetadata:\n version: 1\n---\n",),("no-description", "---\nname: no-description\n---\n"),+ ("bad-literal", "---\nname: bad-literal\ndescription: |\n Use when: a\n b\n---\n"),+ ("bad-folded", "---\nname: bad-folded\ndescription: > Use when: a\n---\n"),+ ("bad-anchor", "---\nname: bad-anchor\ndescription: &d |\n a\n b\n---\n"),+ ("bad-tag", '---\nname: bad-tag\ndescription: !!str "Use "a": b"\n---\n'),+ ("wrapped", "---\nname: wrapped\ndescription: Use when: a\n author: b\n---\n"),+ ("bad-flow", '---\nname: bad-flow\ndescription: ["a: b",, "c"]\n---\n'),+ (+ "bad-flow-map",+ '---\nname: bad-flow-map\ndescription: d\nmetadata: {\nauthor: *a* b: c, v: "1"\n}\n---\n',+ ),+ (+ "bad-flow-key",+ "---\nname: bad-flow-key\nmetadata: {\ndescription: *a* b: c, v: d\n}\n"+ "description: Use when: e\n---\n",+ ),+ (+ "bad-merge",+ "---\nname: bad-merge\n<<: &d {\ndescription: Use when: a, license: MIT\n}\n"+ "metadata: *d\n---\n",+ ),+ ("bad-entry", "---\nname: bad-entry\ndescription: - Use when: a\n---\n"),+ ("bad-alias", "---\nname: bad-alias\ndescription: valid\nlicense: *missing\n---\n"),],)def test_invalid_skill_is_reported_without_hiding_valid_skills(@@ -950,6 +972,52 @@ def test_skill_manifest_saved_with_a_utf8_byte_order_mark_is_valid(isolated_skilassert skills.read_skill_manifest("marked", home = home)["instructions"] == "Follow the steps."+ ("written", "description"),+ [+ (+ 'Fill PDF forms. Use when: the user attaches a "PDF" form',+ 'Fill PDF forms. Use when: the user attaches a "PDF" form',+ ),+ (+ "Fill PDF forms. Use when: the user attaches a PDF form # draft",+ "Fill PDF forms. Use when: the user attaches a PDF form",+ ),+ (+ "*Fast PDF filler*. Use when: a form arrives",+ "*Fast PDF filler*. Use when: a form arrives",+ ),+ ],+)+def test_unquoted_description_with_a_colon_is_valid(isolated_skills, written, description):+ home, _ = isolated_skills+ _write_skill(home, "claude", "pdf-forms", description = written)++ record = next(item for item in skills.list_skills(home = home) if item["name"] == "pdf-forms")++ assert record["valid"] is True+ assert record["description"] == description+++def test_colon_fallback_keeps_the_other_fields_as_written(isolated_skills):+ home, _ = isolated_skills+ _write_skill(+ home,+ "claude",+ "pdf-forms",+ description = "Fill PDF forms. Use when: the user attaches a PDF form",+ frontmatter = (+ "license: &license MIT\nmetadata: {author: *license}\ncompatibility: |\n Needs Python 3."+ ),+ )++ record = next(item for item in skills.list_skills(home = home) if item["name"] == "pdf-forms")++ assert record["valid"] is True+ assert record["metadata"] == {"author": "MIT"}+ assert record["compatibility"] == "Needs Python 3.\n"++def test_read_skill_tool_applies_defaults_for_null_arguments(isolated_skills, monkeypatch):from core.inference import tools as tools_module