fix(gateway): batch critical fixes — session resume, /new race, HA WebSocket scheme#19182
Merged
Conversation
…suspend suspend_recently_active() was unconditionally setting suspended=True on startup, causing get_or_create_session() to wipe conversation history on every restart. Change to set resume_pending=True instead, so sessions auto-resume while still allowing stuck-loop escalation after 3 failures.
…avoid race (#18912) When /new is issued while an agent is actively processing, the confirmation response was never sent to the user because cancel_session_processing() was called before _send_with_retry(). Task cancellation side effects could silently drop the response. Fix: reorder to send the response BEFORE cancelling the old task. Add logging at the send point (matching the pattern at line 2800 in _process_message_background) so future failures are visible. Closes: #18912
1 task
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.
Summary
Batch salvage of 3 critical gateway fixes from independent contributors. Each addresses a confirmed bug on current main.
PR #19033 by @millerc79 — Session history destroyed on gateway restart
suspend_recently_active()blanket-setsuspended=Trueon recent sessions at startup. Next message hitget_or_create_sessionwhich sawsuspended=True→ auto-reset → new session_id, empty history. Every fast restart/crash wiped ALL active conversations.Fix: Set
resume_pending=Trueinstead ofsuspended=True. The resume path inget_or_create_sessionpreserves the existing session_id and transcript. Tests updated to reflect the new semantics (4 tests updated across 2 files).PR #18915 by @shellybotmoyer — /new response silently dropped (race condition)
In
_dispatch_active_session_command(), the response to/newwas sent AFTERcancel_session_processing(). The cancellation's 5-secwait_for+ finally blocks could interfere with the send, silently dropping the confirmation. User saw infinite "typing..." with no reply.Fix: Send the response BEFORE cancelling the old task. Fixes #18912.
PR #18984 by @CharlieKerfoot — Home Assistant HTTPS WebSocket broken
.replace("http://", "ws://").replace("https://", "wss://")— forhttps://URLs, the first replace matches thehttpprefix ofhttps, producingws://s://.... The second replace then has nothing to match. Completely breaks HA integration over TLS.Fix: Swap replace order:
https://→wss://first, thenhttp://→ws://.Test results