mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-07-24 16:54:43 +00:00
refactor: extract SKILL_PROMPT_DESC_LIMIT constant and normalize description helpers
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.
This commit is contained in:
parent
6441b05888
commit
5eb772111d
1 changed files with 19 additions and 6 deletions
|
|
@ -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 ────────────────────────────────────────────────────────
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue