You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix(gateway): preserve internal events during active sessions - #75849
Thanks for the focused regression coverage. The premise is confirmed on current origin/main (991f5f1e): gateway/run.py:8362-8473 processes authorization and plain-text approval before its existing internal-event guard at gateway/run.py:8486-8498; gateway/platforms/base.py:5546, :5580, and :5644-5685 also treat internal text as commands or clarify input.
The diff closes those control paths in both adapter and direct-runner entry points. It also preserves the distinct Yuanbao recall cancellation path: current gateway/platforms/yuanbao.py:1107-1118 explicitly queues a recall event and signals the active session, so classifying that event as non-internal keeps it eligible under the proposed has_pending_interrupt rule. The added tests cover each changed boundary, including queue draining of command-shaped internal evidence.
I checked this against current main. The bug is still there: an internal event (a background completion or watch notification) can still answer a pending clarify prompt or the /update prompt. But gateway/run.py has been split, and part of this PR is now already on main, so it needs a rebase with a smaller scope.
Already on main, drop these hunks:
The busy-handler change. Commit d6867ab now admits event.internal and event.allow_gateway_control wakes at the very top of _handle_active_session_busy_message (gateway/run_busy.py, around line 785), before auth and approval routing. Moving the internal early return there again would conflict with that. The internal check later in the same function also already queues these events.
Still needed, at the new locations:
gateway/run_inbound.py: skip internal events in _hm_update_prompt_reply (around line 319), _hm_clarify_reply (around line 364) and _hm_slash_confirm_reply plus the has_blocking_approval check (around line 454). These are the old _handle_message intercepts.
gateway/platforms/base.py: skip coerce_plaintext_gateway_command(event) (around line 3972) and the text clarify bypass (around line 4031) for internal events, as this PR does.
gateway/run_turn.py: the pending / command check (around line 3695) should ignore internal events, same as your run.py hunk.
Suggest splitting out: the has_pending_interrupt change and the Yuanbao recall flip to internal=False. They change interrupt behavior for every adapter, which is wider than this bug, so they will be easier to review on their own.
The clarify test here is a good invariant test. A matching one for the /update prompt would cover the idle path too. I have not opened a competing PR, so this one can carry the fix.
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
area/sessionsSession lifecycle, resume, persistence, historycomp/gatewayGateway runner, session dispatch, deliveryP2Medium — degraded but workaround existssweeper:blast-broadSweeper blast radius: broad — a core path most sessions hitsweeper:risk-message-deliverySweeper risk: may drop, duplicate, misroute, or suppress messagessweeper:risk-security-boundarySweeper risk: may affect sandboxing, auth, credentials, or sensitive datasweeper:risk-session-stateSweeper risk: may lose/corrupt/mis-associate session or context statetype/bugSomething isn't working
4 participants
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
Tests
python -m pytest -q tests/gateway/test_internal_event_never_interrupts_busy_session.py tests/gateway/test_internal_event_bypass_pairing.py tests/gateway/test_clarify_active_session_bypass.py tests/gateway/test_command_bypass_active_session.py tests/gateway/test_interrupt_key_match.py tests/gateway/test_plaintext_approval_routing.py tests/gateway/test_queued_native_image_session_key.py tests/gateway/test_session_race_guard.py tests/test_yuanbao_pipeline.pypython -m compileall -q gatewaygit diff --check origin/main...HEAD