fix(context_breakdown): search the volatile tier for the skills index - #78186
pierrenode wants to merge 1 commit into
Conversation
NousResearch#37117 moved the <available_skills> block from the stable band to the volatile band so skill edits don't invalidate the cached identity prefix. hermes_cli/prompt_size.py's compute_prompt_breakdown() was updated for this today, but agent/context_breakdown.py — which powers the /context and /context all commands (NousResearch#72242) — has its own copy of the same regex and was missed: both compute_session_context_breakdown() and compute_context_details() still search only the stable tier, so the "Skills" category silently disappears from /context and /context all reports zero skills for any session with skills loaded. Search volatile first, fall back to stable for sessions whose cached prompt predates NousResearch#37117 (mirroring prompt_size.py's fix). Also strip the found skills block from the volatile tail before folding it into "system_prompt", so skills tokens aren't double-counted once they're correctly attributed to their own category.
|
Independent reproduction on from hermes_cli.prompt_size import _build_inspection_agent
from agent.system_prompt import build_system_prompt_parts
from agent.context_breakdown import compute_session_context_breakdown
a = _build_inspection_agent("cli")
p = build_system_prompt_parts(a)
print(len(p["stable"]), len(p["volatile"])) # 9942 29260
print("<available_skills>" in p["stable"], "<available_skills>" in p["volatile"]) # False True
print([(c["id"], c["tokens"]) for c in compute_session_context_breakdown(a, [])["categories"]])Output: So on a fresh session: there is no Two user-visible symptoms in the Desktop Context usage popover, both from this root cause:
Same payload feeds the Desktop popover, |
Summary
#37117 (salvaged and merged today as #77696) moved the
<available_skills>block from the stable band of the system prompt to the volatile band, so skill edits don't invalidate the cached identity prefix. A same-day CI-caught follow-up fixedhermes_cli/prompt_size.py'scompute_prompt_breakdown()for this move.agent/context_breakdown.py— which powers the/contextand/context allcommands (shipped via #72242) — has its own independent copy of the same_SKILLS_BLOCK_REregex, used in two places (compute_session_context_breakdown(),compute_context_details()), and both were missed by the follow-up fix: they still search only the stable tier.Empirically confirmed before writing the fix: with a skill loaded,
/context's "Skills" category is silently absent from the breakdown, and/context alllists zero skills.Fix
prompt_size.py's fix).compute_session_context_breakdown()also now strips the found skills block out of the volatile tail before folding it into thesystem_prompttext, so skills tokens are attributed only to their own category rather than double-counted once they're found (a bug that would otherwise have been introduced by fixing the lookup alone).Test plan
test_breakdown_includes_major_categories's fixture to place<available_skills>in the volatile tier (matching current production reality) rather than stable — this is why the bug wasn't caught: the existing test's mock reflected the pre-fix(system_prompt): move the skills index out of the stable band to preserve the cached prefix #37117 layout.test_skills_index_falls_back_to_stable_for_legacy_sessionsfor the legacy fallback path.test_skills_index_not_double_counted_in_system_promptproving the volatile-tail stripping fix.test_context_details_finds_skills_in_volatile_tier—compute_context_details()had no prior direct behavioral test coverage at all.ruff checkclean on all changed files.