Merge pull request #1272 from NousResearch/hermes/hermes-315847fd
fix: log prompt builder skill parsing fallbacks
This commit is contained in:
commit
728fa66ef0
2 changed files with 37 additions and 2 deletions
|
|
@ -177,7 +177,8 @@ def _parse_skill_file(skill_file: Path) -> tuple[bool, dict, str]:
|
||||||
desc = desc[:57] + "..."
|
desc = desc[:57] + "..."
|
||||||
|
|
||||||
return True, frontmatter, desc
|
return True, frontmatter, desc
|
||||||
except Exception:
|
except Exception as e:
|
||||||
|
logger.debug("Failed to parse skill file %s: %s", skill_file, e)
|
||||||
return True, {}, ""
|
return True, {}, ""
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -194,7 +195,8 @@ def _read_skill_conditions(skill_file: Path) -> dict:
|
||||||
"fallback_for_tools": hermes.get("fallback_for_tools", []),
|
"fallback_for_tools": hermes.get("fallback_for_tools", []),
|
||||||
"requires_tools": hermes.get("requires_tools", []),
|
"requires_tools": hermes.get("requires_tools", []),
|
||||||
}
|
}
|
||||||
except Exception:
|
except Exception as e:
|
||||||
|
logger.debug("Failed to read skill conditions from %s: %s", skill_file, e)
|
||||||
return {}
|
return {}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
import builtins
|
import builtins
|
||||||
import importlib
|
import importlib
|
||||||
|
import logging
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
from agent.prompt_builder import (
|
from agent.prompt_builder import (
|
||||||
|
|
@ -144,6 +145,23 @@ class TestParseSkillFile:
|
||||||
assert frontmatter == {}
|
assert frontmatter == {}
|
||||||
assert desc == ""
|
assert desc == ""
|
||||||
|
|
||||||
|
def test_logs_parse_failures_and_returns_defaults(self, tmp_path, monkeypatch, caplog):
|
||||||
|
skill_file = tmp_path / "SKILL.md"
|
||||||
|
skill_file.write_text("---\nname: broken\n---\n")
|
||||||
|
|
||||||
|
def boom(*args, **kwargs):
|
||||||
|
raise OSError("read exploded")
|
||||||
|
|
||||||
|
monkeypatch.setattr(type(skill_file), "read_text", boom)
|
||||||
|
with caplog.at_level(logging.DEBUG, logger="agent.prompt_builder"):
|
||||||
|
is_compat, frontmatter, desc = _parse_skill_file(skill_file)
|
||||||
|
|
||||||
|
assert is_compat is True
|
||||||
|
assert frontmatter == {}
|
||||||
|
assert desc == ""
|
||||||
|
assert "Failed to parse skill file" in caplog.text
|
||||||
|
assert str(skill_file) in caplog.text
|
||||||
|
|
||||||
def test_incompatible_platform_returns_false(self, tmp_path):
|
def test_incompatible_platform_returns_false(self, tmp_path):
|
||||||
skill_file = tmp_path / "SKILL.md"
|
skill_file = tmp_path / "SKILL.md"
|
||||||
skill_file.write_text(
|
skill_file.write_text(
|
||||||
|
|
@ -440,6 +458,21 @@ class TestReadSkillConditions:
|
||||||
conditions = _read_skill_conditions(tmp_path / "missing.md")
|
conditions = _read_skill_conditions(tmp_path / "missing.md")
|
||||||
assert conditions == {}
|
assert conditions == {}
|
||||||
|
|
||||||
|
def test_logs_condition_read_failures_and_returns_empty(self, tmp_path, monkeypatch, caplog):
|
||||||
|
skill_file = tmp_path / "SKILL.md"
|
||||||
|
skill_file.write_text("---\nname: broken\n---\n")
|
||||||
|
|
||||||
|
def boom(*args, **kwargs):
|
||||||
|
raise OSError("read exploded")
|
||||||
|
|
||||||
|
monkeypatch.setattr(type(skill_file), "read_text", boom)
|
||||||
|
with caplog.at_level(logging.DEBUG, logger="agent.prompt_builder"):
|
||||||
|
conditions = _read_skill_conditions(skill_file)
|
||||||
|
|
||||||
|
assert conditions == {}
|
||||||
|
assert "Failed to read skill conditions" in caplog.text
|
||||||
|
assert str(skill_file) in caplog.text
|
||||||
|
|
||||||
|
|
||||||
class TestSkillShouldShow:
|
class TestSkillShouldShow:
|
||||||
def test_no_filter_info_always_shows(self):
|
def test_no_filter_info_always_shows(self):
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue