Skip to content

refactor(gateway): extract auto-continue helpers from run.py (slice 8 of #54962) - #77706

Open
andrexibiza wants to merge 2 commits into
NousResearch:mainfrom
andrexibiza:fix/gateway-auto-continue-helpers
Open

refactor(gateway): extract auto-continue helpers from run.py (slice 8 of #54962)#77706
andrexibiza wants to merge 2 commits into
NousResearch:mainfrom
andrexibiza:fix/gateway-auto-continue-helpers

Conversation

@andrexibiza

@andrexibiza andrexibiza commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

Related #54962 #55138

What / Why

Slice 8 of the gateway/run.py god-file extraction campaign (#54962): a pure
move of the auto-continue noise / history-media cluster out of the
26,823-line messaging gateway module into a focused new module,
gateway/auto_continue_helpers.py.

Moved verbatim (zero behavior change, no refactor, docstrings/comments kept):

  • _last_transcript_timestamp
  • _is_auto_continue_noise
  • _strip_auto_continue_noise
  • _collect_auto_append_media_tags
  • _collect_history_media_paths (with nested _add_text_media_paths)
  • exclusive constants: _AUTO_CONTINUE_NOTE_PREFIX, _AUTO_CONTINUE_FALLBACK_PREFIX,
    _AUTO_APPEND_MEDIA_TOOL_NAMES, _JSON_MEDIA_TOOL_PATH_FIELDS, _TOOL_MEDIA_RE

gateway/run.py now re-exports the five functions via a top-of-file
module-attribute import, so every existing gateway.run.<name> reference
(tests, gateway/platforms/base.py) stays green without edits.

How to test

# from the repo root, with the project venv active:
python -c "import gateway.run, gateway.auto_continue_helpers"
python -m pytest tests/gateway/test_73771_media_resend_dedup.py \
  tests/gateway/test_media_extraction.py \
  tests/gateway/test_media_spaced_paths_and_history_dedupe.py \
  tests/gateway/test_restart_resume_pending.py \
  tests/gateway/test_run_tool_media_re.py -q --no-header -p no:cacheprovider

Expected: import gateway.run succeeds (no circular import), all five names
resolve as gateway.run.<name> attributes, and the five referencing test
suites pass. On this machine: 65 passed; the 2 failures in those files
(test_streamed_explicit_media_resend_is_delivered,
test_quoted_spaced_home_path_is_collected_in_delivery_form) are
pre-existing Windows path-normalization environment failures — verified by
stash-proving the identical 2 failures against pristine main.

Platforms tested

  • Windows 10 (native) — import gateway.run + targeted pytest suites green,
    scripts/check-windows-footguns.py clean on both files, git diff --check clean.

Shrink

  • gateway/run.py: 26,823 → 26,597 lines (−234 moved, +8 import lines; net −226)

Part of #54962
Part of #55138

Part of #78207
Part of #78647

… of NousResearch#54962)

Signed-off-by: andrexibiza <84248988+andrexibiza@users.noreply.github.com>
@alt-glitch alt-glitch added type/refactor Code restructuring, no behavior change P3 Low — cosmetic, nice to have comp/gateway Gateway runner, session dispatch, delivery sweeper:risk-message-delivery Sweeper risk: may drop, duplicate, misroute, or suppress messages labels Aug 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/gateway Gateway runner, session dispatch, delivery P3 Low — cosmetic, nice to have sweeper:risk-message-delivery Sweeper risk: may drop, duplicate, misroute, or suppress messages type/refactor Code restructuring, no behavior change

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants