Merge PR #617: Improve skills tool error handling

Authored by aydnOktay. Adds logging to skills_tool.py with specific
exception handling for file read errors (UnicodeDecodeError, PermissionError)
vs unexpected exceptions, replacing bare except-and-continue blocks.
This commit is contained in:
teknium1
2026-03-10 04:32:26 -07:00

View File

@@ -63,6 +63,7 @@ Usage:
"""
import json
import logging
import os
import re
import sys
@@ -71,6 +72,8 @@ from typing import Dict, Any, List, Optional, Tuple
import yaml
logger = logging.getLogger(__name__)
# All skills live in ~/.hermes/skills/ (seeded from bundled skills/ on install).
# This is the single source of truth -- agent edits, hub installs, and bundled
@@ -269,7 +272,11 @@ def _find_all_skills() -> List[Dict[str, Any]]:
"category": category,
})
except Exception:
except (UnicodeDecodeError, PermissionError) as e:
logger.warning("Failed to read skill file %s: %s", skill_md, e)
continue
except Exception as e:
logger.warning("Error parsing skill %s: %s", skill_md, e, exc_info=True)
continue
return skills
@@ -308,7 +315,11 @@ def _load_category_description(category_dir: Path) -> Optional[str]:
description = description[:MAX_DESCRIPTION_LENGTH - 3] + "..."
return description if description else None
except Exception:
except (UnicodeDecodeError, PermissionError) as e:
logger.debug("Failed to read category description %s: %s", desc_file, e)
return None
except Exception as e:
logger.warning("Error parsing category description %s: %s", desc_file, e, exc_info=True)
return None