The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(skills): preload and cron say "Ambiguous" instead of "Unknown"/"not found"
kshitijk4poor7025dd1cee43
diff --git a/agent/skill_commands.py b/agent/skill_commands.pyindex 59441161795..244576d4c85 100644--- a/agent/skill_commands.py+++ b/agent/skill_commands.py@@ -245,6 +245,32 @@ def _load_skill_payload(skill_identifier: str, task_id: str | None = None) -> tureturn loaded_skill, skill_dir, str(loaded_skill.get("name") or normalized)+def ambiguous_skill_label(identifier: str, payload: dict) -> Optional[str]:+ """``Ambiguous skill name X: use one of <paths>`` when a failed skill_view *payload* is a same-tier+ name collision, else None — so preload/cron say why instead of "Unknown"/"not found"."""+ load_names = payload.get("load_names") if isinstance(payload, dict) else None+ return f"Ambiguous skill name {identifier}: use one of {', '.join(load_names)}" if load_names else None+++def _missing_skill_label(identifier: str) -> str:+ """Display form of an identifier that failed to load (failure path only: re-asks skill_view)."""+ try:+ from tools.skills_tool import skill_view+ from agent.skill_utils import normalize_skill_lookup_name+ payload = json.loads(skill_view(normalize_skill_lookup_name(identifier), preprocess=False))+ except Exception:+ return identifier+ return ambiguous_skill_label(identifier, payload) or identifier+++def format_missing_skills(missing: list[str]) -> str:+ """One error line for unresolved preload identifiers: ambiguous ones keep their own wording,+ the rest are reported as ``Unknown skill(s): ...``."""+ ambiguous = [m for m in missing if m.startswith("Ambiguous skill name ")]+ unknown = [m for m in missing if m not in ambiguous]+ return "; ".join(ambiguous + ([f"Unknown skill(s): {', '.join(unknown)}"] if unknown else []))++def _inject_skill_config(loaded_skill: dict[str, Any], parts: list[str]) -> None:"""Append a ``[Skill config: ...]`` block with resolved ``metadata.hermes.config``values so the agent needn't read config.yaml. Any failure leaves the message without it."""@@ -677,8 +703,8 @@ def build_preloaded_skills_prompt(lambda name: (f'[IMPORTANT: The user launched this CLI session with the "{name}" skill '"preloaded. Treat its instructions as active guidance for the duration of this ""session unless the user overrides them.]"),- task_id, disabled_names=_disabled_skill_names(), disabled_as_missing=True,- already_loaded=excluded_loaded_names,+ task_id, missing_label=_missing_skill_label, disabled_names=_disabled_skill_names(),+ disabled_as_missing=True, already_loaded=excluded_loaded_names,)return "\n\n".join(prompt_parts), loaded_names, missingdiff --git a/cli.py b/cli.pyindex 52c67c8331d..6c27c901250 100644--- a/cli.py+++ b/cli.py@@ -1055,7 +1055,8 @@ class HermesCLI(CLIInitMixin, CLITuiRuntimeMixin, CLIProcessNotificationsMixin,", ".join(loaded_skills),)else:- raise ValueError(f"Unknown skill(s): {missing_display}")+ from agent.skill_commands import format_missing_skills+ raise ValueError(format_missing_skills(missing_skills))if skills_prompt:self.system_prompt = "\n\n".join(p for p in (self.system_prompt, skills_prompt) if p).strip()self.preloaded_skills += [name for name in loaded_skills if name not in self.preloaded_skills]diff --git a/cron/scheduler_prompt.py b/cron/scheduler_prompt.pyindex 48d36bd09bb..68c1819ac03 100644--- a/cron/scheduler_prompt.py+++ b/cron/scheduler_prompt.py@@ -195,16 +195,16 @@ def _load_cron_skill_parts(job: dict, skill_names: list[str]) -> list[str]:from tools.skills_tool import skill_viewfrom tools.skill_usage import bump_usefrom agent.skill_bundles import build_bundle_invocation_message, resolve_bundle_command_key- from agent.skill_commands import _inject_skill_config+ from agent.skill_commands import _inject_skill_config, ambiguous_skill_labelfrom agent.skill_utils import normalize_skill_lookup_namejob_label = job.get("name", job.get("id"))task_id = str(job.get("id") or "") or Noneparts: list[str] = []skipped: list[str] = []- def _skip(msg: str, *args) -> None:+ def _skip(msg: str, *args, label: str | None = None) -> None:logger.warning("Cron job '%s': " + msg, job_label, *args)- skipped.append(skill_name)+ skipped.append(label or skill_name)for skill_name in skill_names:# Bundles shadow same-slug skills, mirroring the CLI/gateway slash-command path.@@ -225,6 +225,9 @@ def _load_cron_skill_parts(job: dict, skill_names: list[str]) -> list[str]:except (json.JSONDecodeError, TypeError):_skip("skill '%s' returned invalid JSON, skipping", skill_name)continue+ if ambiguous := ambiguous_skill_label(skill_name, loaded):+ _skip("%s — skipping", ambiguous, label=ambiguous)+ continueif not loaded.get("success"):_skip("skill not found, skipping — %s",diff --git a/hermes_cli/oneshot.py b/hermes_cli/oneshot.pyindex 6a0d7ada683..d18ade56798 100644--- a/hermes_cli/oneshot.py+++ b/hermes_cli/oneshot.py@@ -127,13 +127,13 @@ def _build_preloaded_skills_prompt(skills: object = None) -> str | None:if not parsed_skills:return None- from agent.skill_commands import build_preloaded_skills_prompt+ from agent.skill_commands import build_preloaded_skills_prompt, format_missing_skillsskills_prompt, loaded_skills, missing_skills = build_preloaded_skills_prompt(parsed_skills)if missing_skills:missing_display = ", ".join(missing_skills)if not loaded_skills:- raise ValueError(f"Unknown skill(s): {missing_display}")+ raise ValueError(format_missing_skills(missing_skills))logging.warning("Unknown skill(s) requested, skipping: %s. Continuing with: %s. ""List available skills with `hermes skills list`.",diff --git a/tui_gateway/server.py b/tui_gateway/server.pyindex 168e1b98ea4..1fdfec497dd 100644--- a/tui_gateway/server.py+++ b/tui_gateway/server.py@@ -2601,12 +2601,12 @@ def _startup_system_prompt(cfg: dict, task_id: str) -> str:startup_skills = _parse_tui_skills_env()if not startup_skills:return system_prompt- from agent.skill_commands import build_preloaded_skills_prompt+ from agent.skill_commands import build_preloaded_skills_prompt, format_missing_skillsskills_prompt, loaded_skills, missing_skills = build_preloaded_skills_prompt(startup_skills, task_id=task_id)if missing_skills:missing_display = ", ".join(missing_skills)if not loaded_skills:- raise ValueError(f"Unknown skill(s): {missing_display}")+ raise ValueError(format_missing_skills(missing_skills))logger.warning("Unknown skill(s) requested, skipping: %s. Continuing with: %s. ""List available skills with `hermes skills list`.", missing_display, ", ".join(loaded_skills))if skills_prompt: