From 5eb772111d9f4552abc1d6282804593fc2838bb1 Mon Sep 17 00:00:00 2001 From: Alan Harman-Box Date: Tue, 12 May 2026 09:55:53 +0000 Subject: [PATCH] refactor: extract SKILL_PROMPT_DESC_LIMIT constant and normalize description helpers MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The system prompt skill index truncates long descriptions to 57 chars, but this limit was a hardcoded magic number. Extract it as a named constant and factor the normalization logic into a shared private helper so the extraction function and the new truncation predicate cannot drift. No behaviour change — pure refactor. --- agent/skill_utils.py | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/agent/skill_utils.py b/agent/skill_utils.py index f96238b9bd95..df0f933317fc 100644 --- a/agent/skill_utils.py +++ b/agent/skill_utils.py @@ -779,18 +779,31 @@ def resolve_skill_config_values( # ── Description extraction ──────────────────────────────────────────────── +SKILL_PROMPT_DESC_LIMIT = 60 + + +def _normalize_skill_description(frontmatter: Dict[str, Any]) -> str: + """Normalize a skill's description field for comparison/truncation.""" + raw_desc = frontmatter.get("description", "") + return str(raw_desc).strip().strip("'\"") if raw_desc else "" + def extract_skill_description(frontmatter: Dict[str, Any]) -> str: - """Extract a truncated description from parsed frontmatter.""" - raw_desc = frontmatter.get("description", "") - if not raw_desc: + """Extract a system-prompt-length description from parsed frontmatter.""" + desc = _normalize_skill_description(frontmatter) + if not desc: return "" - desc = str(raw_desc).strip().strip("'\"") - if len(desc) > 60: - return desc[:57] + "..." + if len(desc) > SKILL_PROMPT_DESC_LIMIT: + return desc[:SKILL_PROMPT_DESC_LIMIT - 3] + "..." return desc +def is_skill_description_truncated_for_prompt(frontmatter: Dict[str, Any]) -> bool: + """True when the description will be truncated in the system prompt skill index.""" + desc = _normalize_skill_description(frontmatter) + return len(desc) > SKILL_PROMPT_DESC_LIMIT + + # ── File iteration ────────────────────────────────────────────────────────