fix(web): persist uploads .sent marker so restarts do not re-send files - #2518
Closed
Nas01010101 wants to merge 1 commit into
Closed
fix(web): persist uploads .sent marker so restarts do not re-send files#2518Nas01010101 wants to merge 1 commit into
Nas01010101 wants to merge 1 commit into
Conversation
The web runner tracked already-sent uploads only in memory; the on-disk .sent marker was written by session forks but never by the normal send path. After any server restart the next prompt re-attached every file in the session uploads directory, growing the context with duplicate images on each restart. Resolve MoonshotAI#2413
This was referenced Jul 25, 2026
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.
Related Issue
Resolve #2413
Description
kimi webre-sends every previously uploaded file (including images) with the next prompt after any server restart, polluting the session — exactly as reported in #2413 ("every time the session is restarted, the pictures previously sent to Kimi will be sent again").Root cause:
SessionProcess._encode_uploaded_files()skips files recorded inself._sent_files, but that set lives only in memory. The on-diskuploads/.sentmarker it reads at startup is written only bysession_fork.py(fork inheritance, #1004) — the normal send path never persists it. So after a restart the set is empty, the marker doesn't exist, and every file inuploads/is re-encoded and re-attached; the pile grows with each restart because the files are (deliberately) kept on disk.Fix (5 lines): after marking files as sent, write the sorted set to the existing
uploads/.sentmarker (same JSON format the fork path already writes and the loader already reads). AnOSErroris logged and non-fatal, preserving current behavior on read-only filesystems.Verification
tests/web/test_uploads_sent_marker.py(all fail onmain):.sentmarker is persisted after encoding,SessionProcess(simulated restart) sends nothing,uv run pytest tests/web→ 18 passed; fulltests/suite green.ruff check/ruff format --check/pyrightclean on touched files.Checklist
## Unreleasedentry in house style;make gen-changelogruns kimi itself, which needs API auth not available in this environment).make gen-docs— N/A: no user-facing docs change (internal web-runner behavior fix).