Skip to content

agent_skills: Read SKILL.md in one shot via fs.load#57510

Merged
rtfeldman merged 2 commits into
mainfrom
AI-303/fix-skill-utf8-chunk-boundary
May 27, 2026
Merged

agent_skills: Read SKILL.md in one shot via fs.load#57510
rtfeldman merged 2 commits into
mainfrom
AI-303/fix-skill-utf8-chunk-boundary

Conversation

@rtfeldman

Copy link
Copy Markdown
Contributor

Follow-up to #57466 simplifying load_skill_frontmatter rather than fixing a separate bug.

#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

rtfeldman added 2 commits May 22, 2026 11:44
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.
@rtfeldman rtfeldman self-assigned this May 22, 2026
@cla-bot cla-bot Bot added the cla-signed The user has signed the Contributor License Agreement label May 22, 2026
@zed-community-bot zed-community-bot Bot added the staff Pull requests authored by a current member of Zed staff label May 22, 2026
@rtfeldman rtfeldman marked this pull request as ready for review May 26, 2026 20:26
@MartinYe1234 MartinYe1234 self-requested a review May 26, 2026 20:40
@rtfeldman rtfeldman added this pull request to the merge queue May 27, 2026
Merged via the queue into main with commit a55e3e9 May 27, 2026
45 checks passed
@rtfeldman rtfeldman deleted the AI-303/fix-skill-utf8-chunk-boundary branch May 27, 2026 13:55
@rtfeldman

Copy link
Copy Markdown
Contributor Author

/cherry-pick preview

@zed-zippy

zed-zippy Bot commented May 27, 2026

Copy link
Copy Markdown
Contributor

🍒💥 Cherry-pick did not succeed
https://github.com/zed-industries/zed/actions/runs/26516369090

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
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla-signed The user has signed the Contributor License Agreement staff Pull requests authored by a current member of Zed staff

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants