fix: deduplicate files by destination before sandbox validation - #247
Open
proseer-lars wants to merge 2 commits into
Open
proseer-lars wants to merge 2 commits into
proseer-lars wants to merge 2 commits into
Conversation
Some callers (e.g. LibreChat) send the same file more than once per exec request when a user re-uploads a file in the same conversation. The sandbox's validateExecuteFiles() rejects duplicate destinations, which causes every tool call in that conversation to fail with: Error from sandbox: [bad_request] files contains duplicate destination "filename.pdf" This surfaces to the end user as a confusing "sandbox is down" error when the sandbox itself is fine - it is just rejecting the duplicate file list. Fix: add deduplicateFilesByDestination() and call it in getJob() before validateExecuteFiles(). Keeps the first file for each destination, silently drops subsequent duplicates, and logs a warning.
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.
Problem
Some callers (e.g. LibreChat) send the same file more than once per exec request when a user re-uploads a file in the same conversation. The sandbox's
validateExecuteFiles()rejects duplicate destinations, which causes every tool call in that conversation to fail with:This surfaces to the end user as a confusing "the code-execution sandbox appears to be down" error — the sandbox itself is healthy, it's just rejecting the duplicate file list.
Fix
Add
deduplicateFilesByDestination()ingetJob()before final validation. It bounds and validates every raw entry, then keeps the latest file at each exact destination so re-uploads replace older copies. It preserves original implicitfile${index}.codedestinations across compaction, matching signed manifest claims, and emits one aggregated warning when duplicates are dropped.validateExecuteFiles()still rejects duplicate and ancestor-conflicting destinations (e.g.resultsvsresults/out.csv) when called directly. Its per-file validation is shared with the dedup step so malformed entries cannot be concealed by a later duplicate.Test plan
validateExecuteFilesstill rejects duplicates when called directly)/executeroutetsc --noEmitstill reports diagnostics in unrelated pre-existing API files; no diagnostics in the three changed files