refactor(gateway): extract resume/replay helpers from run.py (slice 3 of #54962) - #77452
refactor(gateway): extract resume/replay helpers from run.py (slice 3 of #54962)#77452andrexibiza wants to merge 1 commit into
Conversation
… of NousResearch#54962) Third slice of the gateway god-file unpacking: extract build_resume_recovery_note, _build_replay_entry and the shared _ASSISTANT_REPLAY_FIELDS whitelist into gateway/resume_replay_helpers.py. - Byte-identical extraction (AST-verified against origin/main): no behavior change - gateway/run.py: -170 lines; helpers imported at the extraction point - 40 tests pass (replay-entry + resume-pending suites) Follow-up to NousResearch#77433 (slice 1) and NousResearch#77438 (slice 2). Progress on NousResearch#54962. Signed-off-by: andrexibiza <84248988+andrexibiza@users.noreply.github.com>
|
FILE-LIST coordination — #86050 (fix(gateway): preserve reasoning-only assistant turns on reload) adds Merge-order handling: if #86050 lands first, this slice's extraction set must include |
Related #2974 #54962 #55138 #57056 #77433 #77438
What does this PR do?
Third slice of the Extract Gateway Platform Routing from
gateway/run.py refactor (#54962, #55138) — standalone PR for the
resume/replay helper cluster (follow-up to #77433 slice 1 and #77438
slice 2).
This slice pulls the resume/recovery + message-replay helpers out of the
god-file into
gateway/resume_replay_helpers.py:build_resume_recovery_note— the resume-pending recovery system note(interactive vs non-interactive guidance, Gateway auto-resume on a non-interactive platform (webhook) acknowledges restoration instead of completing the interrupted turn #57056)
_build_replay_entry+_ASSISTANT_REPLAY_FIELDS— theassistant-message replay field whitelist (reasoning/thinking-mode
round-trip fidelity, PR feat: persist reasoning across gateway session turns (schema v6) #2974 contract)
No behavior change: byte-identical extraction (AST-verified against
origin/main).
gateway/run.pyshrinks by 170 lines; the helpers areimported at the extraction point so the call sites (resume scheduling,
replay building) 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 3, standalone, using the same verified
pattern as slices 1-2 (module + import + shrink + AST-fidelity).
Platform adapters and the dispatch loop remain for follow-up slices.
How to test
pytest tests/gateway/test_replay_entry_fields.py tests/gateway/test_restart_resume_pending.py -q # 40 passedWhat platforms were tested?
AST-identical to origin/main, 40 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 ~200 lines acrossslices 1-3, with more to come.
Part of #54962
Part of #55138 (Extract Gateway Platform Routing)
Checklist
git diff --checkcleanPart of #78647