refactor(gateway): extract GatewayDispatchMixin from run.py (slice 26 of #54962) - #77756
Open
andrexibiza wants to merge 2 commits into
Open
refactor(gateway): extract GatewayDispatchMixin from run.py (slice 26 of #54962)#77756andrexibiza wants to merge 2 commits into
andrexibiza wants to merge 2 commits into
Conversation
… of NousResearch#54962) Signed-off-by: andrexibiza <84248988+andrexibiza@users.noreply.github.com>
andrexibiza
force-pushed
the
refactor/gateway-mixin-dispatch
branch
from
August 3, 2026 14:30
eff2f78 to
01e2be2
Compare
This was referenced Aug 4, 2026
Open
Open
Open
Open
Open
This was referenced Aug 5, 2026
Open
Open
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.
Related #54962 #55138
What / Why
Extracts the message-dispatch / event-routing core of
GatewayRunnerout ofgateway/run.py(26,823 → 21,948 lines) into a newgateway/dispatch_mixin.pymodule, following the established mixin pattern(
gateway/authz_mixin.py,gateway/kanban_watchers.py,gateway/slash_commands.py). This is the largest mixin of theGatewayRunner decomposition (gate 4 of #54962): 28 methods / 4,812 lines,
including the inbound pipeline (
_handle_message,_handle_message_with_agent), the busy-session slash commands(/stop, /new, /queue, /steer, /goal, ...), the active-session-slot admission
control, and the destructive-slash confirmation gates.
GatewayDispatchMixinis added first inGatewayRunner's bases. Everymethod is moved verbatim (byte-identical, verified against
HEAD~1by anin-memory splice reconstruction);
self.*calls resolve unchanged via the MRO.Behavior-neutral mechanics:
_hermes_home,_load_gateway_config,_AGENT_PENDING_SENTINEL,_float_env, ...) are imported lazily insidethe method that uses them (
from gateway.run import ...at call time),so
gateway/dispatch_mixin.pynever importsgateway.runat module level —no import cycle.
logger = logging.getLogger("gateway.run")at module top preserves theoriginal log-record name.
from gateway.run importin the new module; run.py keepsits own definitions of those helpers.
How to test
Verification receipts:
git diff --checkclean;scripts/check-windows-footguns.pyclean; byte-verbatim move check 28/28 methods; post-commit in-memory splice
reconstruction vs
HEAD~1byte-identical.Platforms tested
Scope notes (honest)
(test_10710, test_35809, test_48031, test_compression_deferred_soft_result,
test_compression_session_id_persistence) parse
gateway/run.pysource to pinfingerprints that live inside
_handle_message_with_agent. They now parsegateway.dispatch_mixininstead (same pattern the codebase already uses forgateway/slash_commands.pyin test_48031). Pin logic and assertions areunchanged — only the module whose source is inspected moved.
the moved code are deferred
from gateway.run import ...lines at the top ofthe 9 methods that reference run.py module-level helpers (listed in the new
module's docstring). This is the documented sibling-mixin pattern.
run.pystill importsGatewayDispatchMixinfor the class MRO; all moved names remain reachableas
gateway.run.GatewayRunner.<name>and viafrom gateway.run import <name>test monkeypatches.
Part of #54962
Part of #55138
Part of #78207
Part of #78647
Part of #78791