fix(gateway): route multiplex profile responses through the profile's own adapter (#56854 salvage) - #59310
Merged
Merged
Conversation
Collaborator
Salvage of #56854 (@AndreasHiltner, broadest) plus the fail-closed resolver hunk from #57417 (@ManniBr). Competing/related multiplex response-delivery cluster: #57492 (44-site routing + profile prompt-stamp), #52225 (~12-site + secret-scope), #49962 (narrow dedicated route); underlying issue #49634. Marked |
This was referenced Jul 6, 2026
Merged
Replace 53 instances of self.adapters.get(source.platform) with self._adapter_for_source(source) in gateway/run.py. self.adapters is the default profile's adapter map. In multiplex mode, secondary profiles (lars, kira, jonas, caro) have their adapters in _profile_adapters[profile]. _adapter_for_source() (from authz_mixin.py) correctly resolves through _profile_adapters when source.profile is set. Without this fix, ALL response paths for secondary profiles — streaming, sending, media delivery, voice, typing indicators, queue operations, startup restore, and platform notices — route through the default profile's bot token instead of the profile's own token. Fixes: Multiplex profiles responding with wrong bot token on Telegram, Discord, and all other platforms.
…ry profiles Follow-up to the routing sweep: when a stamped secondary profile has no _profile_adapters entry (adapter failed to connect / was refused), return None instead of falling back to the default profile's adapter — the fallback sends replies out the wrong bot, which is the exact leak class this cluster fixes. Also restores main's deliberate fail-fast on port-binding platforms in secondary profiles (the cherry-picked commit had softened it to silent force-disable). Co-authored-by: ManniBr <m888.braun@hotmail.com>
…_adapter_for_source The routing sweep sends these paths through _adapter_for_source, which reads source.profile. A bare MagicMock auto-attribute is truthy, so the fixtures looked like stamped secondary profiles and hit the new fail-closed branch. Real SessionSource.profile is None or str (AGENTS.md pitfall #17).
teknium1
force-pushed
the
salvage/56854-adapter-routing
branch
from
July 6, 2026 04:39
c05c981 to
cea79d6
Compare
This was referenced Jul 14, 2026
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
In multiplex mode, secondary profiles' replies now go out through their own bot: all 53 remaining
self.adapters.get(source.platform)call sites ingateway/run.pyare swapped to the profile-aware_adapter_for_source(source)resolver, and the resolver itself now fails closed instead of falling back to the default profile's adapter.Salvages #56854 by @AndreasHiltner (cherry-picked, authorship preserved) plus the fail-closed resolver hunk from #57417 by @ManniBr (Co-authored-by).
Root cause: phase 3's adapter registry stamped
source.profileand bb304b4 added_adapter_for_source, but only 5 of ~55 source-keyed call sites used it. Streaming replies (run.py:17533), typing indicators, media-after-streaming, footers, platform notices, and queue acks all pickedself.adapters— the default profile's bot. This is the remaining half of #49634 (session keys were already profile-namespaced; delivery was not).Changes
gateway/run.py: 53 sitesself.adapters.get(source.platform)→self._adapter_for_source(source)(@AndreasHiltner's commit, conflict-resolved onto current main preserving the_should_echo_stt_transcripts()gating that landed after the PR)gateway/run.py: dropped the original PR's port-binding force-disable hunk — main's fail-fastMultiplexConfigErroron secondary-profile port binders is deliberate and staysgateway/authz_mixin.py:_authorization_adapterfails closed for a stamped secondary profile with no registry entry (from fix(gateway): isolate multiplexed profile routing #57417);defaultstamps still use the primary mapscripts/release.py: AUTHOR_MAP entriesValidation
Part of the multiplex isolation cluster (issues #49634, #52446, #50051). Ordered first; the config.py secret-scope fix follows separately.
Infographic