fix(curator): protect skills.external_dirs from autonomous curation (#47688) - #52849
Merged
Merged
Conversation
…ration The salvaged #51875 added a background-review write guard in skill_manage that refuses mutations to skills.external_dirs skills — but it only fires when is_background_review() is true. The curator's LLM review fork ran with the default _memory_write_origin='assistant_tool', so the guard never triggered during the exact curation pass it exists to protect against (GH-47688). - Set _memory_write_origin='background_review' on the curator review fork so turn_context binds it onto the write-origin ContextVar and the guard fires. - Add a regression test asserting the fork runs under the background_review origin (the invariant linking the fork to the guard). - AUTHOR_MAP: map yu-xin-c for the salvaged commit.
Contributor
🔎 Lint report:
|
| Rule | Count |
|---|---|
unresolved-attribute |
3 |
First entries
agent/curator.py:1856: [unresolved-attribute] unresolved-attribute: Unresolved attribute `_memory_write_origin` on type `AIAgent`
run_agent.py:2989: [unresolved-attribute] unresolved-attribute: Object of type `Self@get_credits_spent_micros` has no attribute `_credits_session_start_micros`
tests/run_agent/test_credits_notices_toggle.py:76: [unresolved-attribute] unresolved-attribute: Unresolved attribute `_credits_session_start_micros` on type `AIAgent`
✅ Fixed issues (1):
| Rule | Count |
|---|---|
invalid-assignment |
1 |
First entries
tests/run_agent/test_credits_notices_toggle.py:76: [invalid-assignment] invalid-assignment: Object of type `None` is not assignable to attribute `_credits_session_start_micros` of type `int`
Unchanged: 5996 pre-existing issues carried over.
Diagnostics are surfaced as warnings — this check never fails the build.
This was referenced Jun 26, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The skill curator no longer touches
skills.external_dirsskills — the user'sshared, often version-controlled skill library is now read-only to autonomous
curation, while foreground user-directed edits still work.
Salvages #51875 (@yu-xin-c) and closes the gap that made its headline guard
inert, plus credits @x7peeps (#47752) who reported the same fix first.
Root cause
External-dir skills were visible to the curator's LLM review fork, which could
archive/skill_manage/raw-terminalthem in place. The automatic sweep wasalready safe (rooted at the local skills dir), but the LLM agent operated
through general-purpose tools with no external-ownership boundary.
#51875 added an
is_external_skill_pathboundary and a background-review writeguard in
skill_manage— but that guard only fires whenis_background_review()is true, and the curator fork ran under the defaultassistant_toolorigin, so the guard never triggered during the curationpass it was built to stop. This PR fixes that keystone.
Changes
agent/skill_utils.py:is_external_skill_path()— central ownership boundary.tools/skill_usage.py: external skills are ineligible for curation; excludedfrom
list_agent_created_skill_names/agent_created_report(so the LLM isnever shown them);
archive_skillrefuses them.tools/skill_manager_tool.py:_background_review_write_guardrefusesautonomous
patch/edit/delete/write_file/remove_fileon external (andbundled / hub-installed) skills; foreground user edits still pass.
agent/curator.py: set_memory_write_origin="background_review"on thereview fork so
turn_contextbinds the origin and the guard actually fires;prompt rule marks external dirs read-only.
exclusion, background-review
skill_managerefusal, and a regression testasserting the fork runs under the
background_revieworigin.Validation
background_review)patch/deleteof external skillassistant_tool)patchof same external skillcreated_by: agent)is_curation_eligible(external)/archive_skill(external)scripts/run_tests.sh tests/agent/test_skill_utils.py tests/tools/test_skill_usage.py tests/tools/test_skill_manager_tool.py tests/agent/test_curator.py tests/agent/test_turn_context.py→ 236 passed, 0 failed. Plus an isolated E2E run against a temp HERMES_HOME confirming the table above.Known residual
The raw-
terminalmv/rmpath is deterred by the prompt rule (the LLM isnever handed an external path in the candidate list), not hard-blocked — shell
commands can't be intercepted per-path. The enforceable layers (candidate-list
exclusion, eligibility,
archive_skill,skill_manageguard) are all hard.Closes #47688. Supersedes #51875 and #47752.
Infographic