Improve skills tool error handling
This commit is contained in:
parent
d63b363cde
commit
19459b7623
1 changed files with 13 additions and 2 deletions
|
|
@ -60,6 +60,7 @@ Usage:
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import json
|
import json
|
||||||
|
import logging
|
||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
@ -67,6 +68,8 @@ from typing import Dict, Any, List, Optional, Tuple
|
||||||
|
|
||||||
import yaml
|
import yaml
|
||||||
|
|
||||||
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
# All skills live in ~/.hermes/skills/ (seeded from bundled skills/ on install).
|
# 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
|
# This is the single source of truth -- agent edits, hub installs, and bundled
|
||||||
|
|
@ -226,7 +229,11 @@ def _find_all_skills() -> List[Dict[str, Any]]:
|
||||||
"category": category,
|
"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
|
continue
|
||||||
|
|
||||||
return skills
|
return skills
|
||||||
|
|
@ -265,7 +272,11 @@ def _load_category_description(category_dir: Path) -> Optional[str]:
|
||||||
description = description[:MAX_DESCRIPTION_LENGTH - 3] + "..."
|
description = description[:MAX_DESCRIPTION_LENGTH - 3] + "..."
|
||||||
|
|
||||||
return description if description else None
|
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
|
return None
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue