Skip to content

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
masterfrom
oz/app-4793-cap-local-skill-file-reads
Draft

fix: cap local project skill file reads to bound memory (APP-4793)#13130
warp-dev-github-integration[bot] wants to merge 1 commit into
masterfrom
oz/app-4793-cap-local-skill-file-reads

Conversation

@warp-dev-github-integration

Copy link
Copy Markdown
Contributor

Description

read_local_project_skill_contents read every candidate local project skill file fully into memory via fs::read_to_string with no size limit, unlike its remote sibling read_remote_text_file_contents, which enforces REMOTE_CONTEXT_MAX_FILE_BYTES (1 MiB) and REMOTE_CONTEXT_MAX_BATCH_BYTES (5 MiB). A repository containing a large file matched as a project skill (e.g. an oversized SKILL.md/AGENTS.md), or many such files, was slurped entirely into Strings.

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_footprint 10.9 GB, 6.0 GB sampled inuse) showed ~0.70 GB held in:

std::fs::read_to_string
  skill_watcher::read_local_project_skill_contents
  read_project_skill_contents / read_and_parse_project_skills

Fix

Apply the same per-file and per-batch caps to the local read path:

  • read_capped_skill_file reads at most REMOTE_CONTEXT_MAX_FILE_BYTES + 1 bytes so an oversized file is never fully loaded before being rejected.
  • The batch loop stops once cumulative content would exceed REMOTE_CONTEXT_MAX_BATCH_BYTES.

Note: the dominant consumer in the same profile (~3.0 GB, the repo_metadata file-tree store cloned via Arc::make_mut for large repos) is tracked separately in APP-4656 (open PR #12167). This PR addresses only the uncapped local skill-read facet (APP-4793).

Linked Issue

APP-4793https://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 --lib passes. The full warp test binary and workspace clippy could 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.

  • I have manually tested my changes locally with ./script/run

Agent Mode

  • Warp Agent Mode - This PR was created via Warp's AI Agent 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.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant