agent_skills: Read SKILL.md in one shot via fs.load#57510
Merged
Conversation
The previous chunked reader exists to stop pulling from disk once the closing `---` is found, sparing the SKILL.md body. But MAX_SKILL_FILE_SIZE is 100KB and the metadata check already caps the worst case at that, so the optimization is negligible. The hand-rolled loop forced the use of `open_sync` (and a long comment about smol::unblock and the GPUI test scheduler) and admits the UTF-8-at-chunk-boundary bug class fixed in the previous commits. Drop the loop, delete `closing_delimiter_end` and `SKILL_READ_CHUNK_SIZE`, and read via `fs.load` the same way `read_skill_body` already does. `parse_skill_frontmatter`'s own size check stays as a backstop in case metadata is unavailable or unreliable. Keep the boundary test as a regression check against any future reintroduction of buggy chunked reads.
MartinYe1234
approved these changes
May 26, 2026
Contributor
Author
|
/cherry-pick preview |
Contributor
|
🍒💥 Cherry-pick did not succeed |
MartinYe1234
pushed a commit
that referenced
this pull request
May 27, 2026
…pick to preview) (#57831) Cherry-pick of #57510 to preview ---- Follow-up to #57466 simplifying `load_skill_frontmatter` rather than fixing a separate bug. the frontmatter boundary, preventing `str::from_utf8` from failing on a multi-byte grapheme split across chunks. That fix is correct, but the chunked read it's working around isn't pulling its weight: `MAX_SKILL_FILE_SIZE` is 100KB and there's already a metadata pre-check, so "stop reading early once we've seen the closing `---`" saves at most ~25 pages per file while forcing the use of `open_sync`, a hand-rolled loop, and a long comment about `smol::unblock` vs the GPUI test scheduler. This PR: - replaces the chunked `open_sync` + read loop with a single `fs.load(...)` call (the same primitive `read_skill_body` already uses); - deletes `closing_delimiter_end`, `SKILL_READ_CHUNK_SIZE`, the `std::io::{self, Read}` import, and the `Parking forbidden` paragraph; - tightens the metadata pre-check so a metadata error (permissions, I/O, etc.) bails out instead of silently falling through to a blind read; - removes the now-obsolete `test_load_skill_frontmatter_with_emoji_at_chunk_boundary` test — by construction, a single full read can't split a UTF-8 sequence at any boundary. Closes AI-303 Release Notes: - N/A
This was referenced May 27, 2026
TomPlanche
pushed a commit
to TomPlanche/zed
that referenced
this pull request
Jun 2, 2026
…7510) Follow-up to zed-industries#57466 simplifying `load_skill_frontmatter` rather than fixing a separate bug. zed-industries#57466 fixed the chunked-read loop so it truncates accumulated bytes at the frontmatter boundary, preventing `str::from_utf8` from failing on a multi-byte grapheme split across chunks. That fix is correct, but the chunked read it's working around isn't pulling its weight: `MAX_SKILL_FILE_SIZE` is 100KB and there's already a metadata pre-check, so "stop reading early once we've seen the closing `---`" saves at most ~25 pages per file while forcing the use of `open_sync`, a hand-rolled loop, and a long comment about `smol::unblock` vs the GPUI test scheduler. This PR: - replaces the chunked `open_sync` + read loop with a single `fs.load(...)` call (the same primitive `read_skill_body` already uses); - deletes `closing_delimiter_end`, `SKILL_READ_CHUNK_SIZE`, the `std::io::{self, Read}` import, and the `Parking forbidden` paragraph; - tightens the metadata pre-check so a metadata error (permissions, I/O, etc.) bails out instead of silently falling through to a blind read; - removes the now-obsolete `test_load_skill_frontmatter_with_emoji_at_chunk_boundary` test — by construction, a single full read can't split a UTF-8 sequence at any boundary. Closes AI-303 Release Notes: - N/A
This was referenced Jun 3, 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.
Follow-up to #57466 simplifying
load_skill_frontmatterrather than fixing a separate bug.#57466 fixed the chunked-read loop so it truncates accumulated bytes at the frontmatter boundary, preventing
str::from_utf8from failing on a multi-byte grapheme split across chunks. That fix is correct, but the chunked read it's working around isn't pulling its weight:MAX_SKILL_FILE_SIZEis 100KB and there's already a metadata pre-check, so "stop reading early once we've seen the closing---" saves at most ~25 pages per file while forcing the use ofopen_sync, a hand-rolled loop, and a long comment aboutsmol::unblockvs the GPUI test scheduler.This PR:
open_sync+ read loop with a singlefs.load(...)call (the same primitiveread_skill_bodyalready uses);closing_delimiter_end,SKILL_READ_CHUNK_SIZE, thestd::io::{self, Read}import, and theParking forbiddenparagraph;test_load_skill_frontmatter_with_emoji_at_chunk_boundarytest — by construction, a single full read can't split a UTF-8 sequence at any boundary.Closes AI-303
Release Notes: