Skip to content

Read each skill file once when agents share a skills folder - #52629

Merged
brennanb2025 merged 4 commits into
mainfrom
brennanb2025/main-heap-skills
Nov 29, 2026
Merged

brennanb2025 merged 4 commits into
mainfrom
brennanb2025/main-heap-skills

Conversation

@brennanb2025

@brennanb2025 brennanb2025 commented Nov 29, 2026 •

Copy link
Copy Markdown
Contributor

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.

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.

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 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)

@brennanb2025
brennanb2025 marked this pull request as ready for review November 29, 2026 21:14
@greptile-apps

greptile-apps Bot commented Nov 29, 2026 •

Copy link
Copy Markdown

Confidence Score: 5/5 · The PR appears safe to merge; no blocking issues were found.RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge; no blocking issues were found.

Summary

Shares skill summaries by canonical path during native discovery and sends shared file text only once during WSL discovery.

  • Native scans share summary reads for linked skill files.
  • WSL scans send shared skill text once and reuse its summary.

Reviews (2) · Last reviewed commit: "fix(skills): let a later root retry a fa..." · Reviewed by Greptile

@coderabbitai

coderabbitai Bot commented Nov 29, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

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: Passed 4

Check name Status Explanation
Title check Passed 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 Passed 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 Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed 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.

Share

Recent 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: ff27d073-386f-4f76-8865-258a1c8857f8
Commits

Reviewing files that changed from the base of the PR and between 0375378 and 60f962d.

Files selected for processing: 3

  • src/main/skills/discovery/skill-discovery-wsl-script-roundtrip.test.ts
  • src/main/skills/discovery/skill-native-discovery.ts
  • src/main/skills/discovery/skill-summary-shared-reads.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 3 remain after this review.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

Nitpick comments: 1

src/main/skills/discovery/skill-discovery-wsl-script-roundtrip.test.ts: 1

51-51: Trivial · Maintainability & Code Quality · Quick win

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.

Files selected for processing: 4

  • src/main/skills/discovery/skill-discovery-wsl-observation.ts
  • src/main/skills/discovery/skill-discovery-wsl-script-roundtrip.test.ts
  • src/main/skills/discovery/skill-discovery-wsl.ts
  • src/main/skills/discovery/skill-native-discovery.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 4 remain after this review.

@brennanb2025

brennanb2025 commented Nov 29, 2026 •

Copy link
Copy Markdown
Contributor Author

Status: ready for 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.

@brennanb2025
brennanb2025 merged commit beae9da into main Nov 29, 2026
98 of 100 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant