You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Read each skill file once when agents share a skills folder - #52629
Many people keep one folder of skills and link it into every agent's skills folder. When Orca looked for installed skills, it read every skill file once for each linked folder, so with a dozen agents it read the same files a dozen times and briefly used much more memory. Now each file is read once per scan.
Files
Added
Deleted
Net
Test
1
$\color{#1a7f37}{\Huge{\mathbf{+}}}$28
$\color{#cf222e}{\Huge{\mathbf{−}}}$3
$\color{#1a7f37}{\Huge{\mathbf{+}}}$25
Prod
4
$\color{#1a7f37}{\Huge{\mathbf{+}}}$60
$\color{#cf222e}{\Huge{\mathbf{−}}}$12
$\color{#1a7f37}{\Huge{\mathbf{+}}}$48
What Changed
discoverSkills passes one map of summary reads, keyed by canonical SKILL.md path, to every root it scans. The first root reads through the canonical path, and later roots reuse that read. If the shared read fails, a root reads through its own path, so one broken link can't hide a skill that another root can still reach.
The WSL discovery script remembers the canonical files it already sent in a Bash associative array, then sends empty text for repeats. The parser reuses the first copy's summary for those rows. On Bash older than 4 (not a WSL case), the script sends every copy as before.
A failed shared native read is retried only by a root whose own path differs from the canonical path.
Picker rows, per-root visibility, and the per-root scan cache are unchanged.
Why
Duplicate results were already merged by canonical path, but only after every root had read and decoded its own copy (up to 256 KiB each). The retained side of this was fixed in #52336. This removes the duplicate reads, which set the transient peak. Tracked in #52334.
I used a scratch home with one shared library (a copy of a real 27-skill library plus 20 synthetic 250 KB skills) linked from 13 provider skill roots, and called the real discoverSkills three times before and after:
before
after
SKILL.md reads
611
47
main heap peak during scan, over baseline
+55 MB
+31 MB
scan time
770–1480 ms
100–145 ms
retained after GC
0.4 MB
0.3 MB
The skills and sources returned were identical (47 skills, 13 sources). Against the same 13 roots, the WSL discovery script's output (one string in main, capped at 128 MiB) went from 90.8 MB to 7.1 MB. On Linux with Bash 5.3, the generated WSL script over 1,000 and 5,000 unique skills linked from 4 roots ran in 9.4 s and 50.3 s, against 12.0 s and 58.5 s for the base script. Every row kept its name and description, and time grew linearly. Native discovery was tested on macOS.
I manually tested these changes locally
Automated tests added/updated, or explained why not below: the WSL script round-trip test now includes a linked root and checks that the file's text is sent once and still parses
Every added test fails without this change and avoids the test anti-patterns
Performance
Fewer file reads and a lower transient peak when roots share files. The cost is one short-lived map per discovery call.
Risk
Level: Low. Two roots that reach the same canonical file now share its summary and modification time, which are properties of that file. A row that arrives from WSL with empty text and no earlier copy parses as before (an empty file). Back out with a plain revert.
Review
Agent skill upstream boundary
Not applicable, or this change copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.
Notes
Ensure no issues in: Security, Cross-platform support (Linux, Windows, Mac), Remote SSH, Mobile, general backwards compatibility, performance
Checklist
This PR is small and focused
I explained what changed and why (ELI5, the user-facing before/after, the mechanism, and why over the alternatives)
I stated the risk: what could break, for whom, and how to back it out
Before/after screenshots or videos attached for UI changes, or N/A with reason
Self-reviewed for correctness, security, and performance
Cross-platform, SSH/remote, and path/shortcut impact considered (or N/A)
pnpm lint, pnpm typecheck, pnpm test, and pnpm build pass (or CI will cover; local preferred)
No actionable comments were generated in the recent review.
Walkthrough
WSL discovery emits file contents once per canonical path when Bash associative arrays are available. The observation reader reuses cached summaries for repeated paths with empty Markdown. Native discovery shares summary-read promises across root scans and reads a root-specific path separately after a shared-read failure. The round-trip test checks symlinked roots, skill rows, and Bash-version behavior.
Merge Risk: Minimal · up to 60f96
Skill discovery now reads shared skill files once while keeping them listed in every linked folder. Failed reads can be retried through another path, and no unresolved defects were identified. Merge-readiness risk is minimal.
Pre-merge checks: 4
Check name
Status
Explanation
Title check
The title "Read each skill file once when agents share a skills folder" matches the main change. The PR shares summary reads by canonical SKILL.md path across discovery roots and makes the WSL script …
Description check
The description follows the repository template. It includes ELI5, What Changed, Why, Linked Issue (#52334), Visual Proof (N/A with reason), Testing with a checked manual test and automated test, Perf…
Linked Issues check
Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check
Check skipped because no linked issues were found for this pull request.
Full details: Title check
Explanation
The title "Read each skill file once when agents share a skills folder" matches the main change. The PR shares summary reads by canonical SKILL.md path across discovery roots and makes the WSL script send repeated file text once, so each skill file is read once per scan.
Full details: Description check
Explanation
The description follows the repository template. It includes ELI5, What Changed, Why, Linked Issue (#52334), Visual Proof (N/A with reason), Testing with a checked manual test and automated test, Performance, Risk with level and revert method, AI Disclosure section left as template, and the upstream boundary checkbox. The unchecked lint/typecheck/test/build item is noted as covered by CI, and the 'Fixes #' placeholder was replaced with a tracking reference. Minor gap: the AI Disclosure section is empty.
Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 3 remain after this review.
Assert the linked rows before projection merges them.
If summary reuse breaks, the parser can assign empty summaries to the linked rows while these assertions still pass. Projection keeps the first complete row for each canonical path. The linked exists assertion checks only root existence.
Also call readWslSkillDiscoveryObservation and assert the linked rows' names and descriptions. This directly checks the empty-body reuse contract without changing the existing transmission assertion. (raw.githubusercontent.com)
Review info
Run configuration
Source mode: Auto
Repository: Unavailable
Branch: Unavailable
File: No configuration file from this repository applied
Commit: Unavailable
Layers: Repository UI
Review profile: CHILL
Plan: Advanced
Run ID: 5e67c757-6b55-452f-9b0e-03808fedd82f
Commits
Reviewing files that changed from the base of the PR and between a55699c and 0375378.
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 4 remain after this review.
Problem. When one skills folder is linked into many agents' skills folders, skill discovery read and decoded every skill file once per linked folder. On Windows with WSL, it also sent every copy through one output string with a 128 MiB cap.
Change. Each skill file is read once per scan, and every linked folder still lists it. The skill list is identical.
Fixed during review.
A failed read through one link no longer hides a skill that another folder can still reach.
The WSL script keeps its record of sent files in a Bash map, so the check stays linear.
A file that can't be read is not read a second time through the same path, and a failed read is not kept for the rest of the scan, so a later folder can retry it.
Verified.
13 linked folders, real 27-skill library plus 20 large synthetic skills: 611 → 47 reads, peak main heap +55 → +31 MB, scan time 770–1480 → 100–145 ms.
WSL script over the same folders: 90.8 → 7.1 MB of output.
Bash 5.3 on Linux, 1,000 and 5,000 skills × 4 linked folders: 9.4 s and 50.3 s (base: 12.0 s and 58.5 s). Every row kept its name and description.
The WSL script round-trip test now covers a linked folder and checks that its rows keep their names and descriptions; CI is green.
Deferred. The per-file WSL loop (one realpath and stat per file per folder) predates this change and is still slow on very large libraries.
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
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.
ELI5
Many people keep one folder of skills and link it into every agent's skills folder. When Orca looked for installed skills, it read every skill file once for each linked folder, so with a dozen agents it read the same files a dozen times and briefly used much more memory. Now each file is read once per scan.
What Changed
discoverSkillspasses one map of summary reads, keyed by canonicalSKILL.mdpath, to every root it scans. The first root reads through the canonical path, and later roots reuse that read. If the shared read fails, a root reads through its own path, so one broken link can't hide a skill that another root can still reach.Why
Duplicate results were already merged by canonical path, but only after every root had read and decoded its own copy (up to 256 KiB each). The retained side of this was fixed in #52336. This removes the duplicate reads, which set the transient peak. Tracked in #52334.
Linked Issue
Tracked in #52334
Visual Proof
N/A: no UI change; the skill list is identical.
Testing
I used a scratch home with one shared library (a copy of a real 27-skill library plus 20 synthetic 250 KB skills) linked from 13 provider skill roots, and called the real
discoverSkillsthree times before and after:SKILL.mdreadsThe skills and sources returned were identical (47 skills, 13 sources). Against the same 13 roots, the WSL discovery script's output (one string in main, capped at 128 MiB) went from 90.8 MB to 7.1 MB. On Linux with Bash 5.3, the generated WSL script over 1,000 and 5,000 unique skills linked from 4 roots ran in 9.4 s and 50.3 s, against 12.0 s and 58.5 s for the base script. Every row kept its name and description, and time grew linearly. Native discovery was tested on macOS.
Performance
Fewer file reads and a lower transient peak when roots share files. The cost is one short-lived map per discovery call.
Risk
Level: Low. Two roots that reach the same canonical file now share its summary and modification time, which are properties of that file. A row that arrives from WSL with empty text and no earlier copy parses as before (an empty file). Back out with a plain revert.
Review
Agent skill upstream boundary
Notes
Ensure no issues in: Security, Cross-platform support (Linux, Windows, Mac), Remote SSH, Mobile, general backwards compatibility, performance
Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)