Skip to content

feat(skills): add opt-in 'compact' index_mode to shrink the skills system prompt - #24448

Open
RyanRana wants to merge 1 commit into
NousResearch:mainfrom
RyanRana:perf/lazy-skill-descriptions
Open

feat(skills): add opt-in 'compact' index_mode to shrink the skills system prompt#24448
RyanRana wants to merge 1 commit into
NousResearch:mainfrom
RyanRana:perf/lazy-skill-descriptions

Conversation

@RyanRana

Copy link
Copy Markdown
Contributor

What does this PR do?

The skills system-prompt builder already does the right thing for full skill bodies — they're not in the prompt; only name + 60-char description per skill is, and the body is loaded on demand via skill_view(name).

But for users with many skills, even those one-line descriptions add up. With 50 skills × ~70 chars/line that's ~3.5KB / ~900 tokens of index in every system prompt, on top of the ~400-token preamble that explains how skills work.

This PR adds an opt-in skills.index_mode setting that lets users trade per-skill description visibility (still discoverable via skill_view(name)) for a smaller prompt:

mode format per-skill per-category
detailed (default, unchanged) - name: description shown shown
compact (new) - name dropped dropped

Default behavior is unchanged. Users without the setting see the exact same prompt as today.

Why this is the right shape

  • Strictly additive — new config key, default preserves today's behavior.
  • No new state — the existing skills-prompt cache key is extended with index_mode so a config change takes effect on the next build.
  • Test-friendly — also honors HERMES_SKILLS_INDEX_MODE env var for one-shot runs / tests, matching the pattern used elsewhere (HERMES_PLATFORM, HERMES_KANBAN_TASK).
  • Defensive — invalid values (index_mode: turbo) fall back to detailed rather than producing an empty / malformed index.
  • The full description is always one skill_view(name) call away — the agent's instruction block already tells it to load skills when even partially relevant.

Changes Made

  • agent/skill_utils.py — Adds get_skills_index_mode() following the existing get_disabled_skill_names() pattern (direct config.yaml read, no extra deps).
  • agent/prompt_builder.py — Threads index_mode into the cache key and skips per-skill / per-category descriptions in the formatting step when compact.
  • cli-config.yaml.example — Documents the new option with a clear when-to-use note (handful of skills → leave default; 50+ → consider compact).
  • tests/agent/test_prompt_builder.py — Three new regression tests:
    • test_compact_index_mode_drops_descriptions — names kept, descriptions stripped.
    • test_detailed_index_mode_is_default_and_keeps_descriptions — guards against accidental regressions.
    • test_invalid_index_mode_falls_back_to_detailed — boundary check for bad config values.

Type of Change

  • ✨ New feature (non-breaking change that adds functionality)
  • ✅ Tests (adding or improving test coverage)

How to Test

# New + existing skills-prompt tests
python -m pytest tests/agent/test_prompt_builder.py -v -k "index_mode or compact or detailed"

# Full prompt_builder + skill_utils sweep
python -m pytest tests/agent/test_prompt_builder.py tests/agent/test_skill_utils.py -q

# Try it live
echo 'skills:\n  index_mode: compact' >> ~/.hermes/config.yaml
# (or) export HERMES_SKILLS_INDEX_MODE=compact
hermes chat

Local results: 3 new + 125 existing = 128 passed, 1 skipped in the relevant suite.

Diff size

 agent/prompt_builder.py            | 13 ++++++--
 agent/skill_utils.py               | 42 ++++++++++++++++++++++++
 cli-config.yaml.example            | 13 ++++++++
 tests/agent/test_prompt_builder.py | 66 ++++++++++++++++++++++++++++++++++++++
 4 files changed, 132 insertions(+), 2 deletions(-)

Checklist

  • My commit messages follow Conventional Commits (feat(skills):)
  • My PR contains only changes related to this feature (no unrelated commits)
  • I've run the relevant test suites and all tests pass (128/128)
  • I've added regression tests covering both modes + invalid value
  • Tested on: macOS 15 / Python 3.12
  • I've updated cli-config.yaml.example with the new config key
  • No tool schema or behavior changes for existing users (opt-in only)

🤖 Generated with Claude Code

…pt skill list

The skills system-prompt builder already ships only name + 60-char
description per skill — full bodies are correctly deferred to
``skill_view(name)``. For users with many skills, even those per-skill
descriptions add up: 50 skills × ~70 chars = ~3.5KB / ~900 tokens of
index in every system prompt, on top of the preamble guidance.

This adds an opt-in ``skills.index_mode`` setting:

- ``detailed`` (default, unchanged): ``- name: description``
- ``compact``: ``- name`` only — drops per-skill descriptions and
  per-category descriptions. The full description is still one
  ``skill_view(name)`` call away.

Resolution: ``HERMES_SKILLS_INDEX_MODE`` env var > ``skills.index_mode``
in config.yaml > ``detailed``. Invalid values fall back to ``detailed``
rather than producing an empty / malformed index.

The mode is included in the existing skills-prompt cache key so a
config change takes effect on the next build.

Tests:
- ``test_compact_index_mode_drops_descriptions`` — verifies per-skill
  and per-category descriptions are stripped while names stay.
- ``test_detailed_index_mode_is_default_and_keeps_descriptions`` —
  guards against accidental regressions for existing users.
- ``test_invalid_index_mode_falls_back_to_detailed`` — boundary check.

No behavior change for any existing user (default unchanged). All 128
prompt_builder + skill_utils tests pass.
@alt-glitch alt-glitch added type/feature New feature or request P3 Low — cosmetic, nice to have comp/agent Core agent runtime: loop, agent_init, prompt builder, context-compression, responses endpoint tool/skills Skills system (list, view, manage) labels May 12, 2026

@teknium1 teknium1 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for targeting a real prompt-budget concern. Current main has moved to a scoped names-only implementation, so this needs a design-aware salvage rather than direct application.

Problems

  • The documented HERMES_SKILLS_INDEX_MODE override in cli-config.yaml.example:541 (PR commit c0ab216b) is a new user-facing non-secret behavior variable. AGENTS.md:102-105 requires behavioral settings to use config.yaml instead.
  • The proposed helper reparses raw YAML independently, while current main already has the shared raw-config cache at agent/skill_utils.py:322-354.
  • Main now renders scoped compaction through agent/system_prompt.py:292-318 and agent/prompt_builder.py:1622-1667; merged #44342 (ee1a744) intentionally chose category-scoped names-only demotion. The submitted tests exercise the environment override but not an actual skills.index_mode config file.

Suggested changes

  • Remove the user-facing env-var path; use config.yaml only.
  • If a global mode is desired, build it atop current compact_categories, register it in hermes_cli/config.py:2317, and test config-file and cache interactions.

Automated hermes-sweeper review.

Comment thread cli-config.yaml.example
# 50+ skills, negligible with a handful.
# Override at runtime with HERMES_SKILLS_INDEX_MODE=compact for one-shots.
# index_mode: detailed

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove the documented HERMES_SKILLS_INDEX_MODE override. AGENTS.md:102-105 requires non-secret behavioral settings to be user-facing through config.yaml; this prompt-index mode is not a credential or build-only transport setting.

@teknium1 teknium1 added sweeper:risk-caching Sweeper risk: may break/degrade prompt caching or cache-key stability (invariant) sweeper:risk-compatibility Sweeper risk: may break existing users, config, migrations, defaults, or upgrades sweeper:blast-moderate Sweeper blast radius: moderate — a subsystem or single platform labels Jul 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/agent Core agent runtime: loop, agent_init, prompt builder, context-compression, responses endpoint P3 Low — cosmetic, nice to have sweeper:blast-moderate Sweeper blast radius: moderate — a subsystem or single platform sweeper:risk-caching Sweeper risk: may break/degrade prompt caching or cache-key stability (invariant) sweeper:risk-compatibility Sweeper risk: may break existing users, config, migrations, defaults, or upgrades tool/skills Skills system (list, view, manage) type/feature New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants