refactor(gateway): extract config/runtime-resolution helpers from run.py (slice 12 of #54962) - #77719
Open
andrexibiza wants to merge 2 commits into
Open
refactor(gateway): extract config/runtime-resolution helpers from run.py (slice 12 of #54962)#77719andrexibiza wants to merge 2 commits into
andrexibiza wants to merge 2 commits into
Conversation
….py (slice 12 of NousResearch#54962) Signed-off-by: andrexibiza <84248988+andrexibiza@users.noreply.github.com>
This was referenced Aug 4, 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.
Related #54962 #55138 #77702 #77704 #77706 #77707 #77708
What
Twelfth slice of the
gateway/run.pylarge-file decomposition (#54962): extract the config/runtime-resolution cluster into a newgateway/config_helpers.pymodule — pure move, zero behavior change, zero refactor.Moved (verbatim, byte-identical to HEAD):
_profile_runtime_scope— profile-runtime scoping (config/skills/memory + credentials) for the multiplexerload_gateway_config_for_runner— process-level config load for the runner (multiplex-aware)_OWN_POLICY_OPEN_ENV+_own_policy_open_startup_violation— open-policy allow-all startup validation_resolve_runtime_agent_kwargs_for_provider— per-provider runtime credential resolution_credential_pool_for_provider— live credential-pool lookupgateway/run.pynow imports these names back from the new module (module-attribute import, in place of the first moved block), so every existinggateway.run.<name>reference — production modules, plugins, and tests — stays green. The new module never importsgateway.run(no circularity).Stayed in
gateway/run.py(honest scope note):_current_max_iterations— its reload helper_reload_runtime_env_preserving_config_authorityreads_hermes_homemodule state that 20+ test files monkeypatch viagateway.run._hermes_home; moving it would silently break that contract._resolve_runtime_agent_kwargs/_try_resolve_fallback_provider— the fallback chain calls_load_gateway_runtime_config, which builds on the_load_gateway_confighub (17+ call sites) that stays ingateway/run.py. These move in a later slice together with the hub.Also removed the now-dead
from contextlib import contextmanager as _contextmanageralias (its only consumer moved).Why
gateway/run.pyis a 26.8k-line god file; AGENTS.md explicitly blesses extracting clusters into focused modules. This slice is one of the parallel extraction PRs tracked in #54962 (gate 3) and #55138, following the verified pattern from slices 1–11 (e.g. #77708, #77707, #77706, #77704, #77702).Shrink
gateway/run.py: 26,823 → 26,677 lines (−146 net; −155/+9)gateway/config_helpers.py: +188 lines (new)How to test
Targeted suites (all referencing the moved names):
Result: 187 passed, 1 xfailed, 1 failed (
test_health_detailed_returns_ok— pre-existing env failure, stash-proven identical on cleanmain).Platforms tested
Part of #54962
Part of #55138
Part of #78207
Part of #78647