refactor(gateway): extract compression-status helpers from run.py (slice 4 of #54962) - #77450
Open
andrexibiza wants to merge 3 commits into
Open
refactor(gateway): extract compression-status helpers from run.py (slice 4 of #54962)#77450andrexibiza wants to merge 3 commits into
andrexibiza wants to merge 3 commits into
Conversation
…ice 4 of NousResearch#54962) Fourth slice of the gateway god-file unpacking: extract _status_template_to_regex and the _COMPRESSION_PROGRESS_STATUS_RE matcher into gateway/status_helpers.py. - Byte-identical extraction (AST-verified): the regex is built from the SAME template constants the emit sites format (agent/conversation_compression.py), so wording drift cannot silently diverge - gateway/run.py: -47 lines; the 8 now-unused template imports removed; helpers imported at the extraction point - 78 tests pass (compression-progress notices + replay + resume suites) Follow-up to NousResearch#77433 (slice 1) and NousResearch#77438 (slices 2-3). Progress on NousResearch#54962. Signed-off-by: andrexibiza <84248988+andrexibiza@users.noreply.github.com>
… 5 of NousResearch#54962) Fifth slice of the gateway god-file unpacking: extract _is_transient_network_error and _gateway_loop_exception_handler into gateway/error_helpers.py. - Byte-identical extraction (AST-verified against origin/main): the classifier walks the exception cause chain (NousResearch#31066/NousResearch#31110); the loop handler wires it into the event-loop safety net - gateway/run.py: -78 lines; helpers imported at the extraction point - 46 tests pass (loop exception handler + compression notices) Follow-up to NousResearch#77433 (slice 1), NousResearch#77438 (slices 2-3), NousResearch#77450 (slice 4). Progress on NousResearch#54962. Signed-off-by: andrexibiza <84248988+andrexibiza@users.noreply.github.com>
8 tasks
…y (slice 5 of NousResearch#54962)" This reverts commit 605227e.
Open
9 tasks
19 tasks
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 #52995 #54962 #55138 #69550 #77433 #77438
What does this PR do?
Fourth slice of the Extract Gateway Platform Routing from
gateway/run.py refactor (#54962, #55138) — follow-up to #77433 (slice 1:
display helpers) and #77438 (slices 2-3: message/config + resume/replay
helpers).
This slice pulls the compression-status matcher out of the god-file
into
gateway/status_helpers.py:_status_template_to_regex— compiles a compression status templateconstant into regex source (literal text escaped verbatim,
{field}placeholders → numeric pattern)
_COMPRESSION_PROGRESS_STATUS_RE— the compiled opt-in matcher,built from the SAME 8 template constants the emit sites format
(
agent/conversation_compression.py), so wording drift cannotsilently diverge from the gateway matcher (fix(gateway): suppress routine pre-API compression chatter on chat platforms #69550, Opt-in progress notice during long auto-compression pauses? (compression is silent by design today) #52995)
No behavior change: byte-identical extraction (AST-verified against
origin/main).
gateway/run.pyshrinks by 47 lines; the 8 now-unusedtemplate imports are removed from run.py and live only in the new module.
The matcher is imported at the extraction point so the line-628 call site
and existing tests stay green.
Scope honesty
The full platform-routing extraction from a 26.7K-line file is a
multi-PR effort. This is slice 4, using the same verified pattern as
slices 1-3 (module + import + shrink + AST-fidelity). Platform adapters
and the dispatch loop remain for follow-up slices.
How to test
What platforms were tested?
_status_template_to_regexAST-identical to origin/main, 78 tests pass,
git diff --checkclean,attribution audit clean.
Why this matters
Every slice shrinks the largest file in the codebase and gives extracted
helpers direct coverage.
gateway/run.pyis down ~360 lines acrossslices 1-4, with more to come.
Part of #54962
Part of #55138 (Extract Gateway Platform Routing)
Checklist
git diff --checkcleanPart of #78647