fix(gateway): preserve pending update prompts across restarts#20160
Merged
Conversation
1 task
4 tasks
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.
Salvage of #18477 onto current
main. Cherry-picked @simbam99's commit with authorship preserved — no follow-up fixes needed, cherry-pick applied cleanly.Summary
Stops
_watch_update_progress()from unlinking.update_prompt.jsonthe moment it forwards the prompt. The marker now stays on disk until the user actually replies (or cancels via recognized slash command), so a gateway restart mid-prompt can recover the outstanding question.Why
On current main: user runs
/updateon Telegram/Discord → update subprocess asks "Restore local changes? [Y/n]" → gateway forwards → gateway restarts before the user replies. The prompt file was deleted eagerly and_update_prompt_pendingis in-memory only, so the user'syfalls through as a normal chat message and the detached update subprocess hangs on.update_responseuntil its 300s timeout fires.With this fix,
_schedule_update_notification_watch()at gateway startup (run.py:3314) already re-fires_watch_update_progress()whenever.update_pending.jsonis on disk — that watcher now finds.update_prompt.jsonstill present and re-forwards it.Changes
gateway/run.py: remove eagerprompt_path.unlink()after forwarding; addprompt_path.unlink(missing_ok=True)on the two sites that write.update_response(normal reply + recognized-slash-command cancel)._update_prompt_pending[session_key] = Trueis untouched.tests/gateway/test_update_streaming.py: 5 new/updated cases covering restart-recovery, cleanup on normal reply, recognized-slash cancel, and unrecognized-slash response paths.Verification
origin/main.scripts/run_tests.sh tests/gateway/test_update_streaming.py -v→ 21 passed including the newtest_prompt_is_recovered_after_watcher_restart._gateway_promptin hermes_cli/main.py:5200) only polls.update_response— never re-reads.update_prompt.json— so keeping the marker around has zero effect on the writer.Closes #18477.