[codex] Persist Codex update prompt dedupe#96
Conversation
080d45d to
48c6c8c
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 080d45d4ac
ℹ️ 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".
|
|
||
| prompted_versions.add(key) | ||
| _codex_update_prompted_versions.update(prompted_versions) | ||
| _save_codex_update_prompted_versions(prompted_versions) |
There was a problem hiding this comment.
Persist prompts only after successful notification
When Telegram returns RetryAfter (which safe_send re-raises), this save has already written the latest version to codex_update_prompt_state.json. The exception aborts notify_codex_update_available before the prompt is delivered to all users, and subsequent checks/restarts will skip the update because the version is now persisted; save the key only after the send loop completes, or roll it back on failure.
Useful? React with 👍 / 👎.
Summary
codex_update_prompt_state.json.Root Cause
The previous dedupe set lived only in process memory, so the same Codex CLI update prompt could be sent again after a bot restart.
Validation
timeout 180 uv run --extra dev pytest tests/telegram_codex_bot/test_codex_update_prompt.pytimeout 120 uv run --extra dev ruff check src/telegram_codex_bot/bot.py tests/telegram_codex_bot/test_codex_update_prompt.py