Skip SSE reconnect when watched run_id set is unchanged#11574
Draft
cephalonaut wants to merge 1 commit into
Draft
Skip SSE reconnect when watched run_id set is unchanged#11574cephalonaut wants to merge 1 commit into
cephalonaut wants to merge 1 commit into
Conversation
`reevaluate_eligibility` previously called `reconnect_sse` unconditionally in the (true, true) arm. The dispatch at `handle_history_event` routes `UpdatedConversationStatus` and `UpdatedConversationMetadata` through `reevaluate_eligibility`, and those events fire on every exchange's status transitions (Idle → InProgress → Success/Cancelled/Error), so each exchange tore down and re-opened the orchestration SSE even when the run-id filter hadn't changed. Snapshot `watched_run_ids` on the connection when it's opened and only reconnect when the current set differs from the snapshot. Call sites that legitimately want a forced reconnect (e.g. `finish_restore_fetch` after children are discovered) still call `reconnect_sse` directly. Co-Authored-By: Oz <oz-agent@warp.dev>
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.
Description
The orchestration SSE connection was being torn down and re-opened on every status transition (Idle → InProgress → Success/Cancelled/Error), even when the underlying run-id filter hadn't changed. This caused unnecessary connection churn on every exchange.
This change tracks the run-id set associated with each open SSE connection and only reconnects when that set actually changes.
Testing
Agent Mode
CHANGELOG-BUG-FIX: Stop tearing down and re-opening the orchestration SSE connection on every exchange's status transitions.