Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions agent/prompt_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -583,9 +583,14 @@ def _skill_should_show(
def build_skills_system_prompt(
available_tools: "set[str] | None" = None,
available_toolsets: "set[str] | None" = None,
lazy: bool = False,
) -> str:
"""Build a compact skill index for the system prompt.

When *lazy* is ``True``, the full skill listing is omitted from the prompt.
Instead a short hint tells the agent to call ``skills_list`` on demand. This
saves ~1,500–2,000 system-prompt tokens when many skills are installed.

Two-layer cache:
1. In-process LRU dict keyed by (skills_dir, tools, toolsets)
2. Disk snapshot (``.skills_prompt_snapshot.json``) validated by
Expand All @@ -604,6 +609,17 @@ def build_skills_system_prompt(
if not skills_dir.exists() and not external_dirs:

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This removes every skill name from the initial prompt. Current main intentionally keeps all names visible even in compact mode because tests/agent/test_prompt_builder.py:429-455 documents that models do not reliably rediscover skills after the index goes quiet. Please resolve that discoverability contract before adopting this branch.

return ""

# ── Lazy loading: short hint instead of full listing ────────────────
if lazy:
return (
"## Skills (on-demand)\n"
"A skills catalog is available. Call skills_list() when you think a "
"specialized skill might help with your task, then load it with "
"skill_view(name). If a skill has issues, fix it with "
"skill_manage(action='patch'). After difficult/iterative tasks, "
"offer to save as a skill."
)

# ── Layer 1: in-process LRU cache ─────────────────────────────────
# Include the resolved platform so per-platform disabled-skill lists
# produce distinct cache entries (gateway serves multiple platforms).
Expand Down
3 changes: 3 additions & 0 deletions hermes_cli/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -689,6 +689,9 @@ def _ensure_hermes_home_managed(home: Path):
# always goes to ~/.hermes/skills/.
"skills": {
"external_dirs": [], # e.g. ["~/.agents/skills", "/shared/team-skills"]
# "eager" (default): inject full skill listing into system prompt every turn.
# "lazy": omit listing from system prompt; agent calls skills_list() on demand.
"loading": "eager",
},

# Honcho AI-native memory -- reads ~/.honcho/config.json as single source of truth.
Expand Down
2 changes: 2 additions & 0 deletions run_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -1405,6 +1405,7 @@ def __init__(
try:
skills_config = _agent_cfg.get("skills", {})
self._skill_nudge_interval = int(skills_config.get("creation_nudge_interval", 10))
self._skills_loading = str(skills_config.get("loading", "eager")).lower()
except Exception:
pass

Expand Down Expand Up @@ -3772,6 +3773,7 @@ def _build_system_prompt(self, system_message: str = None) -> str:
skills_prompt = build_skills_system_prompt(
available_tools=self.valid_tool_names,
available_toolsets=avail_toolsets,
lazy=getattr(self, "_skills_loading", "eager") == "lazy",
)
else:
skills_prompt = ""
Expand Down