fix: Uploaded input_file payloads are persisted as full base64 blobs in session rows#886
Open
sam-saffron-jarvis wants to merge 1 commit into
Open
Conversation
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.
What changed
PartFile.FileData.Base64from persisted session parts when the file has already been saved under term-llm's uploads directory, while retaining the file path, media type, filename, and size metadata.input_filepayloads just before request construction, only for first-party upload paths and within the existing upload size cap/policy.input_filedata URLs, storage sanitization, and native Responses rehydration from a saved upload path.Why this is high-value
Large web/API file uploads were being stored twice: once as decoded bytes in the uploads directory and again as a ~33% larger base64 string in the SQLite
messages.partsJSON. For near-limit files, that bloats session rows by tens of MiB and slows session writes, reads, backups, and resume/search I/O. The fix removes that duplicate serialized payload while preserving native file resend behavior by reading the already-saved upload only when a Responses request can use it.Validation
go test ./internal/session ./internal/llm ./cmdgo build ./...go test ./...git diff --check