fix(agent): preserve _skill_commands cache on scan failure; cap rglob fallback (#18659, #18675)#18717
Closed
Bartok9 wants to merge 0 commit into
Closed
Conversation
Collaborator
1 similar comment
Collaborator
12 tasks
b9e9a59 to
af312cc
Compare
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
Fixes two related bugs in
agent/skill_commands.py:Fix 1 — #18659: Cache cleared on scan failure (P2)
Root cause:
scan_skill_commands()set_skill_commands = {}unconditionally before thetryblock that populated it. Any exception (broken import, unreadable skills dir, etc.) left the global permanently empty with no user-visible error.Fix: Build results into a local
freshdict inside thetryblock. On success, atomically replace the global. On failure, log aWARNINGand leave the previous cache intact so all previously-registered slash commands keep working.Fix 2 — #18675: rglob fallback injects node_modules (P2)
Root cause: The
_build_skill_messagefallback path usedsubdir.rglob("*")with no directory exclusions or file count cap. Skills withscripts/node_modules/could inject thousands of file paths into the model context.Fix: Mirror
skill_view()'s intent by:node_modules,.venv,venv,__pycache__,.git,.tox,dist,build,.mypy_cache_MAX_SUPPORTING_FILES = 50Tests Added
test_preserves_cache_on_total_scan_failure— RuntimeError inside scan leaves cache intacttest_preserves_cache_on_import_failure— ImportError inside scan leaves cache intactTestBuildSkillMessageRglobFallback.test_node_modules_excluded_from_fallback_scan— node_modules paths don't appear in skill messageTestBuildSkillMessageRglobFallback.test_fallback_caps_at_max_files— 200 reference files → ≤50 listedChecklist