fix: avoid resending web uploads after restart#2288
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: a6c4cb6a9b
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| sent_marker.write_text( | ||
| json.dumps(sorted(self._sent_files), ensure_ascii=False), | ||
| encoding="utf-8", |
There was a problem hiding this comment.
Persist upload marker only after prompt send succeeds
Writing .sent here commits uploads as delivered before send_message() actually forwards the prompt to the worker (stdin.write/drain happens later). If the worker exits or the pipe write fails in that window, the prompt never reaches the model, but the persisted marker survives restart and causes those files to be skipped on retry, silently dropping user uploads. This regression is specific to restart/error paths introduced by persisting the marker in _encode_uploaded_files.
Useful? React with 👍 / 👎.
Summary
.sentmarker after normal upload encodingSessionProcessso already-sent uploads are not attached to a later text-only promptFixes #2279.
To verify
uv run pytest tests\web\test_uploaded_files.py -q --basetemp .tmp\pytest -p no:cacheprovideruv run pytest tests\web -q --basetemp .tmp\pytest -p no:cacheprovideruv run ruff check src\kimi_cli\web\runner\process.py tests\web\test_uploaded_files.pyuv run ruff format --check src\kimi_cli\web\runner\process.py tests\web\test_uploaded_files.pyuv run python -m py_compile src\kimi_cli\web\runner\process.py tests\web\test_uploaded_files.py