VFS: cap concurrent scripts and enforce execution deadline - #997
Open
henry-dowling wants to merge 1 commit into
Open
VFS: cap concurrent scripts and enforce execution deadline#997henry-dowling wants to merge 1 commit into
henry-dowling wants to merge 1 commit into
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
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.
Why
On 2026-07-09, one customer's agent fired about 20 concurrent VFS scripts. Each script retained a full filesystem model and the documents it read, pushing the 512 MB API instance into an OOM restart. The restart caused product-wide 502s and dropped every in-flight request.
The server still had no concurrency or elapsed-time guard. PR #779 proposed one, but its VFS route, service, and tests all conflicted with current
main.What
429andRetry-After: 2; do not queue memory-heavy requests.finallyon success or failure.grepscan budgets, search auditing, downloads, and path resolution.This supersedes #779.
Testing
pytest -q backend/tests/test_vfs.py --no-cov -k 'not grep_searches_connected_source_documents'— 17 passed, 1 deselected. The deselected existing test aborts this local Python process inside sentence-transformers/Torch during connected-source embedding setup; the existing partial-grepbudget test passes.ruff check backend/ cli/ruff format --check backend/ cli/git diff --checkNote
Medium Risk
Changes resource limits on a hot agent-facing path; mis-tuned caps or timeouts could cause false 429/413s, but the design preserves existing auth, scan budgets, and audit behavior.
Overview
Adds process-level guards on the HTTP VFS endpoint so agent bursts cannot OOM the API: at most four concurrent scripts per process, with excess requests rejected immediately as 429 and
Retry-After: 2(no queuing).Each script now has a 60-second wall-clock budget. Nested in-process ASGI reads wait only for the remaining time; overdue work is cancelled and surfaced as
VfsBudgetExceeded(HTTP 413), same as the existing document-read cap. The concurrency slot is always released infinally, including after crashes.Tests cover overlapping 429 behavior, slot release on failure, command-level timeout, and cancellation of a stalled nested request.
Reviewed by Cursor Bugbot for commit cc4e68c. Bugbot is set up for automated code reviews on this repo. Configure here.