mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-05-06 02:41:48 +00:00
fix(curator): only mark agent-created for background-review sediment (#19621)
Tighten the provenance semantics added in #19618: skills a user asks a foreground agent to write via skill_manage(create) now stay invisible to the curator. Only skills the background self-improvement review fork sediments through skill_manage get the created_by=agent marker. - tools/skill_provenance.py — new ContextVar module mirroring the _approval_session_key pattern: set_current_write_origin / reset / get / is_background_review. Default origin is 'foreground'; the review fork sets 'background_review'. - run_agent.py — run_conversation() binds the ContextVar from self._memory_write_origin at the top of each call. The review fork runs on its own thread (fresh context), so foreground and review contexts never cross-contaminate. - tools/skill_manager_tool.py — skill_manage(action='create') now only calls mark_agent_created() when is_background_review(). All other cases (foreground create, patch, edit, write_file, delete) continue as before. - tests: test_skill_provenance.py (6 tests covering the ContextVar surface), split test_full_create_via_dispatcher into foreground vs. review-fork variants, curator status tests now mark-first. Why: the agent routinely edits existing user skills on the user's behalf; those writes must never flip provenance. And when a user explicitly asks the foreground agent to create a skill, that skill belongs to the user. The curator should only be cleaning up after its own autonomous sediment from the review nudge loop.
This commit is contained in:
parent
bff484a51b
commit
3c070f9f9d
6 changed files with 234 additions and 4 deletions
|
|
@ -531,13 +531,41 @@ class TestSkillManageDispatcher:
|
|||
assert result["success"] is False
|
||||
|
||||
def test_full_create_via_dispatcher(self, tmp_path):
|
||||
"""Foreground create does NOT mark the skill as agent-created.
|
||||
|
||||
Skills created by user-directed foreground turns belong to the user;
|
||||
only the background self-improvement review fork should mark its
|
||||
own sediment as agent-created (so the curator can later consolidate
|
||||
or prune it).
|
||||
"""
|
||||
with _skill_dir(tmp_path):
|
||||
raw = skill_manage(action="create", name="test-skill", content=VALID_SKILL_CONTENT)
|
||||
from tools.skill_usage import load_usage
|
||||
usage = load_usage()
|
||||
result = json.loads(raw)
|
||||
assert result["success"] is True
|
||||
assert usage["test-skill"]["created_by"] == "agent"
|
||||
# No provenance marker on a foreground create — record either missing
|
||||
# entirely (telemetry best-effort) or present with created_by unset.
|
||||
rec = usage.get("test-skill") or {}
|
||||
assert rec.get("created_by") in (None, "", False)
|
||||
|
||||
def test_create_from_background_review_marks_agent_created(self, tmp_path):
|
||||
"""Background-review fork creates ARE marked as agent-created."""
|
||||
from tools.skill_provenance import set_current_write_origin, BACKGROUND_REVIEW
|
||||
token = set_current_write_origin(BACKGROUND_REVIEW)
|
||||
try:
|
||||
with _skill_dir(tmp_path):
|
||||
raw = skill_manage(
|
||||
action="create", name="review-sediment", content=VALID_SKILL_CONTENT
|
||||
)
|
||||
from tools.skill_usage import load_usage
|
||||
usage = load_usage()
|
||||
finally:
|
||||
from tools.skill_provenance import reset_current_write_origin
|
||||
reset_current_write_origin(token)
|
||||
result = json.loads(raw)
|
||||
assert result["success"] is True
|
||||
assert usage["review-sediment"]["created_by"] == "agent"
|
||||
|
||||
def test_delete_via_dispatcher_threads_absorbed_into(self, tmp_path):
|
||||
# Dispatcher must plumb absorbed_into through to _delete_skill so the
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue