feat: introduce skills management features in AIAgent and CLI

- Added skills configuration options in cli-config.yaml.example, including a nudge interval for skill creation reminders.
- Implemented skills guidance in AIAgent to prompt users to save reusable workflows after complex tasks.
- Enhanced skills indexing in the prompt builder to include descriptions from SKILL.md files for better context.
- Updated the agent's behavior to periodically remind users about potential skills during tool-calling iterations.
This commit is contained in:
teknium1 2026-02-22 13:28:13 -08:00
parent 3c6750f37b
commit db23f51bc6
4 changed files with 112 additions and 10 deletions

View file

@ -60,7 +60,7 @@ from hermes_constants import OPENROUTER_BASE_URL, OPENROUTER_MODELS_URL
# Agent internals extracted to agent/ package for modularity
from agent.prompt_builder import (
DEFAULT_AGENT_IDENTITY, PLATFORM_HINTS,
MEMORY_GUIDANCE, SESSION_SEARCH_GUIDANCE,
MEMORY_GUIDANCE, SESSION_SEARCH_GUIDANCE, SKILLS_GUIDANCE,
)
from agent.model_metadata import (
fetch_model_metadata, get_model_context_length,
@ -393,6 +393,15 @@ class AIAgent:
except Exception:
pass # Memory is optional -- don't break agent init
# Skills config: nudge interval for skill creation reminders
self._skill_nudge_interval = 15
try:
from hermes_cli.config import load_config as _load_skills_config
skills_config = _load_skills_config().get("skills", {})
self._skill_nudge_interval = int(skills_config.get("creation_nudge_interval", 15))
except Exception:
pass
# Initialize context compressor for automatic context management
# Compresses conversation when approaching model's context limit
# Configuration via environment variables (can be set in .env or cli-config.yaml)
@ -1040,6 +1049,8 @@ class AIAgent:
tool_guidance.append(MEMORY_GUIDANCE)
if "session_search" in self.valid_tool_names:
tool_guidance.append(SESSION_SEARCH_GUIDANCE)
if "skill_manage" in self.valid_tool_names:
tool_guidance.append(SKILLS_GUIDANCE)
if tool_guidance:
prompt_parts.append(" ".join(tool_guidance))
@ -1658,6 +1669,19 @@ class AIAgent:
break
api_call_count += 1
# Periodic skill creation nudge after many tool-calling iterations
if (self._skill_nudge_interval > 0
and api_call_count > 0
and api_call_count % self._skill_nudge_interval == 0
and "skill_manage" in self.valid_tool_names):
messages.append({
"role": "user",
"content": (
"[System: This task has involved many steps. "
"If you've discovered a reusable workflow, consider saving it as a skill.]"
),
})
# Prepare messages for API call
# If we have an ephemeral system prompt, prepend it to the messages