fix: cap local project skill file reads to bound memory (APP-4793)#13130
Draft
warp-dev-github-integration[bot] wants to merge 1 commit into
Draft
fix: cap local project skill file reads to bound memory (APP-4793)#13130warp-dev-github-integration[bot] wants to merge 1 commit into
warp-dev-github-integration[bot] wants to merge 1 commit into
Conversation
read_local_project_skill_contents read every candidate project skill file fully into memory via fs::read_to_string with no size limit, unlike the remote sibling read_remote_text_file_contents which enforces REMOTE_CONTEXT_MAX_FILE_BYTES (1 MiB) and REMOTE_CONTEXT_MAX_BATCH_BYTES (5 MiB). Apply the same per-file and per-batch caps to the local path using a bounded read that never loads more than the per-file cap + 1 byte. Found via Sentry 7259255054 heap profile (~0.7 GB held in this path). Co-Authored-By: Oz <oz-agent@warp.dev>
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.
Description
read_local_project_skill_contentsread every candidate local project skill file fully into memory viafs::read_to_stringwith no size limit, unlike its remote siblingread_remote_text_file_contents, which enforcesREMOTE_CONTEXT_MAX_FILE_BYTES(1 MiB) andREMOTE_CONTEXT_MAX_BATCH_BYTES(5 MiB). A repository containing a large file matched as a project skill (e.g. an oversizedSKILL.md/AGENTS.md), or many such files, was slurped entirely intoStrings.Found while triaging Sentry 7259255054 ("Excessive memory usage detected"). The symbolized heap profile for the latest event (macOS, Apple M4 Max, release
v0.2026.06.10.09.27.stable_01,total_footprint10.9 GB, 6.0 GB sampled inuse) showed ~0.70 GB held in:Fix
Apply the same per-file and per-batch caps to the local read path:
read_capped_skill_filereads at mostREMOTE_CONTEXT_MAX_FILE_BYTES + 1bytes so an oversized file is never fully loaded before being rejected.REMOTE_CONTEXT_MAX_BATCH_BYTES.Linked Issue
APP-4793 — https://linear.app/warpdotdev/issue/APP-4793
Testing
Added unit tests in
skill_watcher_tests.rs:read_local_project_skill_contents_skips_oversized_files— a >1 MiB file is skipped while the small file is returned.read_local_project_skill_contents_enforces_batch_limit— eight ~900 KiB files exceed the 5 MiB batch cap, so not all are read and the total stays ≤ 5 MiB.cargo check -p warp --libpasses. The fullwarptest binary and workspaceclippycould not be run in the triage sandbox due to memory/disk limits (the test build was OOM-killed). The capping algorithm was instead validated by extracting it into a standalone program that runs both scenarios and passes. Please rely on CI for full clippy/test../script/runAgent Mode
CHANGELOG-BUG-FIX: Bound memory used when loading local project skill files so a large skill file no longer spikes client memory.
Conversation: https://staging.warp.dev/conversation/446bd03a-e8f0-4097-9862-90494dd273ac
Run: https://oz.staging.warp.dev/runs/019f0ae4-c865-76bf-b289-56134b123d08
Plans:
This PR was generated with Oz.