Skip to content

fix(web): persist uploads .sent marker so restarts do not re-send files - #2518

Closed
Nas01010101 wants to merge 1 commit into
MoonshotAI:mainfrom
Nas01010101:fix-2413-uploads-resent
Closed

fix(web): persist uploads .sent marker so restarts do not re-send files#2518
Nas01010101 wants to merge 1 commit into
MoonshotAI:mainfrom
Nas01010101:fix-2413-uploads-resent

Conversation

@Nas01010101

@Nas01010101 Nas01010101 commented Jul 19, 2026

Copy link
Copy Markdown

Related Issue

Resolve #2413

Description

kimi web re-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 in self._sent_files, but that set lives only in memory. The on-disk uploads/.sent marker it reads at startup is written only by session_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 in uploads/ 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/.sent marker (same JSON format the fork path already writes and the loader already reads). An OSError is logged and non-fatal, preserving current behavior on read-only filesystems.

Verification

  • New regression tests in tests/web/test_uploads_sent_marker.py (all fail on main):
    • .sent marker is persisted after encoding,
    • a fresh SessionProcess (simulated restart) sends nothing,
    • files added after a restart are sent exactly once and merged into the marker.
  • uv run pytest tests/web → 18 passed; full tests/ suite green.
  • ruff check / ruff format --check / pyright clean on touched files.

Checklist

  • I have read the CONTRIBUTING document.
  • I have linked the related issue.
  • I have added tests that prove my fix is effective.
  • Changelog updated (manual ## Unreleased entry in house style; make gen-changelog runs 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).

Open in Devin Review

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
Copilot AI review requested due to automatic review settings July 19, 2026 22:19

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no bugs or issues to report.

Open in Devin Review

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.

重启kimi cli 会发送历史图片 污染会话 || Restarting kimi cli will send historical pictures and pollute the session.

2 participants