feat(mcp): --output-max-size with post-response disk eviction#41031
Open
Skn0tt wants to merge 2 commits into
Open
feat(mcp): --output-max-size with post-response disk eviction#41031Skn0tt wants to merge 2 commits into
Skn0tt wants to merge 2 commits into
Conversation
…aft) Alternative to microsoft#41021 implementing Pavel's suggestion: instead of intercepting writes in code with an OutputFile/OutputDir layer, let tools write whatever and prune the outputDir from disk after each tool call. After Response.serialize() builds its sections, _enforceOutputBudget recursively lists outputDir, sorts by mtime ascending, and unlinks oldest files until total <= outputMaxSize. Files written by the current Response are tracked in _writtenFiles and never evicted, so artifacts referenced in the response stay readable. Config: same outputMaxSize field, --output-max-size CLI flag, and PLAYWRIGHT_MCP_OUTPUT_MAX_SIZE env var as microsoft#41021. Trade-offs vs microsoft#41021: - ~74 lines added vs ~390; no new types or evictable plumbing. - Trace/sessionLog need no special-casing — their mtime bumps keep them young, naturally last to evict. - Sees externally-written files (downloads, trace bundles) — they count against the budget and evict by age. - Self-healing on external fs changes. - Cap can briefly exceed during a single tool call that writes a large artifact; microsoft#41021 pre-evicts so the cap is hard. - Weaker pin guarantee for session.md (recency-based, not flag-based).
Contributor
Test results for "MCP"1 failed 7232 passed, 1113 skipped Merge workflow run. |
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.
Alternative to #41021 implementing @pavelfeldman's suggestion: examine the response for new output-folder entries and remove oldest entries on disk, instead of intercepting at the write layer with
OutputFile/OutputDir.Approach
After
Response.serialize()builds its sections,_enforceOutputBudget()recursively lists the output directory, sorts by mtime ascending, and unlinks oldest files untiltotal <= outputMaxSize. Files written by the currentResponseare tracked in_writtenFilesand never evicted, so artifacts the response references stay readable.Trade-offs vs #41021
evictableplumbing.