Repository navigation
Remove the 10 MiB skill-tree byte limit for skills with supporting assets - #6267
Merged
ymichael merged 2 commits intoOct 26, 2026
Merged
Conversation
…sets Supporting assets are staged to disk and read on demand, not sent to the model, yet the host daemon rejected any skill tree over 10 MiB. User, plugin and built-in skills arrive as required trees, so one large skill failed every thread start and turn, and bb skill install refused the same skills. The file-count and depth limits stay.
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
ymichael
added a commit
that referenced
this pull request
Oct 26, 2026
## Human comments ## What was wrong Server-owned skills (global, plugin and built-in) went to the host daemon as one JSON document with every file base64-encoded. The server re-read the tree, and the daemon parsed, decoded, hashed and rewrote it, holding the whole tree in memory at each step. The daemon also kept a per-tree cache of file contents with no byte budget. Any edit, even one line of SKILL.md, re-sent the entire tree including large assets. The server computed tree hashes by synchronously reading every file on each thread start and turn submit. Follows #6332 (merged), which added attachment streaming and the shared `verified-file-transfer.ts` helper. This PR covers only the skill-tree transfer and extends that helper. ## What changed - **Contract (`HOST_DAEMON_PROTOCOL_VERSION` 252 → 253):** - The tree hash is now v2: sha256 over each file's path, mode, size and content sha256, defined once in `@bb/host-daemon-contract/skill-tree` for both server and daemon. - `GET /internal/skills/tree/:hash` returns a manifest (path, mode, size, sha256 per file). - New `POST /internal/skills/tree/:hash/content` streams the requested files back to back. The base64 tree response is removed. - **Server:** - `SkillTreeRegistry.readTree` hashes files asynchronously with streamed reads. If a file changes while it is being hashed, it retries up to 3 times and takes size and mode from the stat the hash matched. - It keeps metadata-only manifests by hash. A root's previous hash is dropped when its content changes. - The content route refuses (404) any file whose stat changed since it was hashed. - There is deliberately no per-file hash cache. It saved about 20 ms per resolution for 36 MiB of skills, and about 1–2 ms at typical sizes, and its invalidation was the most error-prone part. - **Daemon:** - Pulls validate the manifest (hash, path safety, depth, count, 10 MiB budget). Files the local store already has with the same sha256 are copied and re-verified, and only the rest are downloaded, in one streamed request. - Each file is verified for size and sha256 and written fully. On failure nothing is published and partial files are removed. - Stored trees keep a `manifest.json`. The collected-tree cache holds metadata only, bounded by tree and file counts. - Staging copies from disk with verification. The source is opened lazily, so a missing file can't surface as an unhandled stream error. Staging retries up to 3 times if a host source changes mid-stage. - **Unchanged on purpose:** the daemon's 10 MiB per-skill limit (#6267 is where that is decided). No CLI, SDK, plugin API or config changes. ## How you verified - **Tests:** - Bad downloads: manifest hash mismatch, unsafe paths, wrong content, truncated and over-long streams — each leaves nothing in the store. - Edits and reuse: only changed files are fetched after an edit, and a corrupted stored copy is re-downloaded. - Concurrency and rebuild: concurrent stages pull a tree once, and the stage rebuilds after store eviction. - Copy safety: a missing source with a failing destination raises no unhandled error. This test fails without the fix. - Server routes: manifest, content and path validation, refusal of changed files, and dropping superseded hashes. - Contract: v2 hash ordering and field binding. - **Manual repro:** a 200 MiB file appended mid-hash. The old code recorded the pre-append size; the fix records the final size. - **Commands:** `turbo run typecheck` and `turbo run test` for `@bb/host-daemon-contract`, `@bb/host-daemon` and `@bb/server`. - **Benchmark:** real server on loopback HTTP plus the real daemon client and staging code. "Before" was measured on the base commit. | Scenario | Before | After | |---|---|---| | 9 MiB skill, first pull, wire bytes | 12.0 MiB | 9.0 MiB | | Same skill after a one-line SKILL.md edit, wire bytes | 12.0 MiB | ~0 | | Skill pull, peak live heap (GC while sampling) | ≥ 24.8 MiB | 2.3 MiB | | Catalog resolve, 4 × 9 MiB skills | 15 ms, blocking the event loop | 23 ms, async | - **Live run** on a `pnpm start:worktree` instance with a real Codex thread: - A 9 MiB skill asset was staged with a matching sha256. - After a SKILL.md edit and a follow-up turn, the daemon logged 1 file downloaded (182 bytes) and 1 reused. 🤖 Generated with [Claude Code](https://claude.com/claude-code) > AGENT GENERATED --------- Co-authored-by: review <review@local> Co-authored-by: Claude Opus 5.5 <[email protected]>
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.
Human comments
What was wrong
A skill folder larger than 10 MiB could prevent every thread from starting, even when most of its size was supporting assets rather than instructions. The server included the skill in the catalog, but the daemon rejected the required tree with
Skill tree exceeds max byte count 10485760. Registry installation separately rejected the same folders withSkill tree exceeds installation limits.What changed
How you verified
Skill tree exceeds max byte count 10485760. The same regression passes with this change and verifies the complete staged bytes.STREAMING_OK. The staged asset is 11,534,336 bytes and its SHA-256 matches the source.git diff --checkpass.Fixes #6240