mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-05-08 03:01:47 +00:00
fix(skills): pin protects against deletion only, not edits (#20220)
Previously, pinning a skill blocked every skill_manage write action
(edit, patch, delete, write_file, remove_file). The 'hard fence'
design conflated two concerns:
1. Pin as deletion protection — don't let the curator archive
or the agent delete a stable skill.
2. Pin as content freeze — don't let the agent rewrite it mid-conversation.
In practice (1) is what users pin for: they want a skill to survive
curator passes. (2) created friction — agents finding a new pitfall
in a pinned skill had to ask the user to unpin, then the agent
patches, then the user re-pins. The dance discouraged skill
maintenance and pinned skills went stale.
This narrows the _pinned_guard to skill_manage(action='delete') only.
Patches, edits, and supporting-file writes go through on pinned
skills so the agent can keep improving them. The curator's own
pinned-skip behavior (agent/curator.py:271 for auto-archive,
line 349 for the LLM review prompt) is unchanged — curator still
never touches pinned skills.
Changes:
- tools/skill_manager_tool.py: remove _pinned_guard calls from
_edit_skill, _patch_skill, _write_file, _remove_file; keep on
_delete_skill. Updated _pinned_guard docstring and error message.
- tools/skill_manager_tool.py: updated skill_manage model-facing tool
description to reflect the new semantic.
- website/docs/user-guide/features/curator.md: updated pinning
section.
- tests/tools/test_skill_manager_tool.py: flipped refuses-pinned
tests for edit/patch/write_file/remove_file into allowed-when-pinned;
kept test_delete_refuses_pinned (strengthened assertion to check the
'cannot be deleted' wording).
Closes #18354
This commit is contained in:
parent
fe8560fc12
commit
b10e38e392
3 changed files with 48 additions and 66 deletions
|
|
@ -137,14 +137,12 @@ def _containing_skills_root(skill_path: Path) -> Path:
|
|||
def _pinned_guard(name: str) -> Optional[str]:
|
||||
"""Return a refusal message if *name* is pinned, else None.
|
||||
|
||||
Pinned skills are off-limits to the agent's skill_manage tool. The only
|
||||
way to modify one is for the user to unpin it via
|
||||
``hermes curator unpin <name>`` (or edit it directly by hand). This
|
||||
mirrors the curator's own pinned-skip behavior but extends the guard
|
||||
to tool-driven writes as well, giving users a hard fence against
|
||||
accidental agent edits.
|
||||
Pin protects a skill from **deletion** — both the curator's auto-archive
|
||||
passes and the agent's ``skill_manage(action="delete")`` tool call. The
|
||||
agent can still patch/edit pinned skills; pin only guards against
|
||||
irrecoverable loss, not against content evolution.
|
||||
|
||||
Best-effort: if the sidecar is unreadable we let the write through
|
||||
Best-effort: if the sidecar is unreadable we let the delete through
|
||||
rather than block on a broken telemetry file.
|
||||
"""
|
||||
try:
|
||||
|
|
@ -152,9 +150,11 @@ def _pinned_guard(name: str) -> Optional[str]:
|
|||
rec = skill_usage.get_record(name)
|
||||
if rec.get("pinned"):
|
||||
return (
|
||||
f"Skill '{name}' is pinned and cannot be modified by "
|
||||
f"Skill '{name}' is pinned and cannot be deleted by "
|
||||
f"skill_manage. Ask the user to run "
|
||||
f"`hermes curator unpin {name}` if they want the change."
|
||||
f"`hermes curator unpin {name}` if they want to delete it. "
|
||||
f"Patches and edits are allowed on pinned skills; only "
|
||||
f"deletion is blocked."
|
||||
)
|
||||
except Exception:
|
||||
logger.debug("pinned-guard lookup failed for %s", name, exc_info=True)
|
||||
|
|
@ -439,10 +439,6 @@ def _edit_skill(name: str, content: str) -> Dict[str, Any]:
|
|||
if not existing:
|
||||
return {"success": False, "error": f"Skill '{name}' not found. Use skills_list() to see available skills."}
|
||||
|
||||
pinned_err = _pinned_guard(name)
|
||||
if pinned_err:
|
||||
return {"success": False, "error": pinned_err}
|
||||
|
||||
skill_md = existing["path"] / "SKILL.md"
|
||||
# Back up original content for rollback
|
||||
original_content = skill_md.read_text(encoding="utf-8") if skill_md.exists() else None
|
||||
|
|
@ -483,10 +479,6 @@ def _patch_skill(
|
|||
if not existing:
|
||||
return {"success": False, "error": f"Skill '{name}' not found."}
|
||||
|
||||
pinned_err = _pinned_guard(name)
|
||||
if pinned_err:
|
||||
return {"success": False, "error": pinned_err}
|
||||
|
||||
skill_dir = existing["path"]
|
||||
|
||||
if file_path:
|
||||
|
|
@ -645,10 +637,6 @@ def _write_file(name: str, file_path: str, file_content: str) -> Dict[str, Any]:
|
|||
if not existing:
|
||||
return {"success": False, "error": f"Skill '{name}' not found. Create it first with action='create'."}
|
||||
|
||||
pinned_err = _pinned_guard(name)
|
||||
if pinned_err:
|
||||
return {"success": False, "error": pinned_err}
|
||||
|
||||
target, err = _resolve_skill_target(existing["path"], file_path)
|
||||
if err:
|
||||
return {"success": False, "error": err}
|
||||
|
|
@ -683,10 +671,6 @@ def _remove_file(name: str, file_path: str) -> Dict[str, Any]:
|
|||
if not existing:
|
||||
return {"success": False, "error": f"Skill '{name}' not found."}
|
||||
|
||||
pinned_err = _pinned_guard(name)
|
||||
if pinned_err:
|
||||
return {"success": False, "error": pinned_err}
|
||||
|
||||
skill_dir = existing["path"]
|
||||
|
||||
target, err = _resolve_skill_target(skill_dir, file_path)
|
||||
|
|
@ -835,9 +819,10 @@ SKILL_MANAGE_SCHEMA = {
|
|||
"Skip for simple one-offs. Confirm with user before creating/deleting.\n\n"
|
||||
"Good skills: trigger conditions, numbered steps with exact commands, "
|
||||
"pitfalls section, verification steps. Use skill_view() to see format examples.\n\n"
|
||||
"Pinned skills are off-limits — all write actions refuse with a message "
|
||||
"pointing the user to `hermes curator unpin <name>`. Don't try to route "
|
||||
"around this by renaming or recreating."
|
||||
"Pinned skills are protected from deletion only — skill_manage(action='delete') "
|
||||
"will refuse with a message pointing the user to `hermes curator unpin <name>`. "
|
||||
"Patches and edits go through on pinned skills so you can still improve them as "
|
||||
"pitfalls come up; pin only guards against irrecoverable loss."
|
||||
),
|
||||
"parameters": {
|
||||
"type": "object",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue