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 ────────────────────────────────────────────────────────