fix: skill test-task / precision helpers crash on a non-dict skill (#1638)

This commit is contained in:
Afonso Coutinho
2026-06-03 00:59:24 +01:00
committed by GitHub
parent 8783f12c4c
commit 0051023056
2 changed files with 18 additions and 0 deletions

View File

@@ -79,6 +79,8 @@ def _skill_test_task(skill: dict) -> str:
an email); if we just hand over the 'when to use' text the agent has nothing
to work on and stalls asking for input. So we tell it to create its own
realistic fixture first, then apply the skill end-to-end."""
if not isinstance(skill, dict):
skill = {}
ctx = (skill.get("when_to_use") or skill.get("description") or skill.get("name") or "").strip()
return (
"Test this skill end-to-end. FIRST, set up a small realistic scenario it "
@@ -310,6 +312,8 @@ def _should_check_retrieval_precision(skill: dict) -> bool:
"installation", "install", "system", "ssh", "document", "documents",
"search", "email", "calendar", "gpu", "server", "python",
}
if not isinstance(skill, dict):
return False
tags = {str(t or "").strip().lower() for t in (skill.get("tags") or [])}
if tags & broad:
return True

View File

@@ -0,0 +1,14 @@
"""Regression: skill helpers must tolerate a non-dict skill.
_skill_test_task did `skill.get(...)` and _should_check_retrieval_precision did
`skill.get("tags")`; a skill row that loaded as a bare string/None raised
AttributeError. They now treat a non-dict as empty / not-applicable.
"""
from routes.skills_routes import _skill_test_task, _should_check_retrieval_precision
def test_non_dict_skill_does_not_crash():
assert isinstance(_skill_test_task("not a dict"), str)
assert isinstance(_skill_test_task(None), str)
assert _should_check_retrieval_precision("x") is False
assert _should_check_retrieval_precision(None) is False