The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(profiles): @profile completion never walks skill trees; drop dead OSError guard; pin router + completion in the walk-free test
teknium147b58634c3b7
diff --git a/hermes_cli/profiles.py b/hermes_cli/profiles.pyindex 6bedee98ec5..9169885f3b9 100644--- a/hermes_cli/profiles.py+++ b/hermes_cli/profiles.py@@ -684,13 +684,10 @@ def _skills_dir_signature(skills_dir: Path) -> float:def _walk_skill_count(skills_dir: Path) -> int:"""One ``os.walk`` over the skills tree (prunes ``.git``/``node_modules``/support dirsinstead of statting them). Best-effort: a subtree that vanishes mid-walk (a concurrent- skill install/update) is skipped, never raised — one profile's churn must not abort the- whole enumeration."""+ skill install/update) is skipped, never raised — ``os.walk`` (``onerror=None``) swallows+ scandir errors itself, so one profile's churn cannot abort the whole enumeration."""from agent.skill_utils import iter_skill_index_files- try:- return sum(1 for _ in iter_skill_index_files(skills_dir, "SKILL.md"))- except OSError:- return 0+ return sum(1 for _ in iter_skill_index_files(skills_dir, "SKILL.md"))def _count_skills(profile_dir: Path) -> int:diff --git a/tests/hermes_cli/test_profiles.py b/tests/hermes_cli/test_profiles.pyindex 6df1b991106..0d1bfff4a8d 100644--- a/tests/hermes_cli/test_profiles.py+++ b/tests/hermes_cli/test_profiles.py@@ -795,6 +795,23 @@ class TestListProfiles:assert list_profiles(lazy_skill_count=True)[0].skill_count == 3assert walks == ["hermes-skill-count"] # a second poll inside the window schedules nothing+ # GET /api/profiles (the router's own ``lazy_skill_count=True`` call) and the per-keystroke+ # ``@<profile>`` completion must be just as walk-free: same spy, still one background walk.+ from fastapi import FastAPI+ from fastapi.testclient import TestClient+ from hermes_cli.web_routers import profiles as profiles_router+ from tui_gateway import methods_complete+ app = FastAPI()+ app.include_router(profiles_router.router)+ # Cold cache: a synchronous list_profiles() in either caller would walk on the request thread.+ profiles._SKILL_COUNT_CACHE.clear()+ resp = TestClient(app).get("/api/profiles")+ assert resp.status_code == 200+ assert resp.json()["profiles"][0]["name"] == "default"+ assert walks == ["hermes-skill-count"]+ assert any(i["text"] == "@default" for i in methods_complete._profile_mention_items("def"))+ assert walks == ["hermes-skill-count"]+# Control: the detail/CLI path counts synchronously on the caller's thread.profiles._SKILL_COUNT_CACHE.clear()assert list_profiles()[0].skill_count == 3diff --git a/tui_gateway/methods_complete.py b/tui_gateway/methods_complete.pyindex 18502b08dd3..2fda7eb9cbb 100644--- a/tui_gateway/methods_complete.py+++ b/tui_gateway/methods_complete.py@@ -63,7 +63,8 @@ def _profile_mention_items(prefix: str) -> list[dict]:try:from hermes_cli.profiles import list_profilesseen: set[str] = set()- for p in list_profiles():+ # Per keystroke: only name/description are read, so never walk skill trees in-request (#114041).+ for p in list_profiles(lazy_skill_count=True):if not (name := (p.name or "").strip()):continueseen.add(name.lower())