Skip to content

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
SamSaffron:mainfrom
sam-saffron-jarvis:feat/codereview-d47cc7b1
Open

fix: Uploaded input_file payloads are persisted as full base64 blobs in session rows#886
sam-saffron-jarvis wants to merge 1 commit into
SamSaffron:mainfrom
sam-saffron-jarvis:feat/codereview-d47cc7b1

Conversation

@sam-saffron-jarvis

Copy link
Copy Markdown
Contributor

What changed

  • Strip PartFile.FileData.Base64 from 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.
  • Rehydrate path-only uploaded files for Responses native input_file payloads just before request construction, only for first-party upload paths and within the existing upload size cap/policy.
  • Added coverage for parsed input_file data 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.parts JSON. 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 ./cmd
  • go build ./...
  • go test ./...
  • git diff --check

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant