Skip to content

refactor(conversation_loop): extract image-rejection phrases slice CL-R3-1 into agent/conversation_loop_image_recovery.py - #84330

Open
andrexibiza wants to merge 2 commits into
NousResearch:mainfrom
andrexibiza:gfg/conversation-loop-r31-image-recovery
Open

refactor(conversation_loop): extract image-rejection phrases slice CL-R3-1 into agent/conversation_loop_image_recovery.py#84330
andrexibiza wants to merge 2 commits into
NousResearch:mainfrom
andrexibiza:gfg/conversation-loop-r31-image-recovery

Conversation

@andrexibiza

@andrexibiza andrexibiza commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

Summary

Byte-verbatim extraction of slice CL-R3-1 from agent/conversation_loop.py (7,757 lines at pin ee4bb75b532e932a1055d9a710802a7435163b6a) into a new module, per the repo-wide god-file sharding policy.

  • Moved: the LOCAL _IMAGE_REJECTION_PHRASES tuple assignment (lines 4048–4092, 2,787 bytes, 18 elements, image-rejection phrase data) → agent/conversation_loop_image_recovery.py as a module-level private constant
  • Golden sha (window at pin): c5f51fe68fcacfdfe0936c10660d87259ccaf0f70e12213eb57916dfb6f2f527 — byte-verbatim under the sanctioned dedent normalization (module-level move strips the 16-space common indent; re-indented module == pin window, byte-identical, comments/phrase order/quoting/issue references preserved)
  • Seam: compatibility reference in agent/conversation_loop.py — the caller's lookup resolves the module tuple through the original namespace; single authority (one tuple definition, no duplicate local copy); no public API surface introduced; monkeypatch authority intact; runtime value identity (same values/order/case).
  • Seam tests: tests/agent/test_conversation_loop_image_recovery_seam.py — tuple value/order, original-module resolution, no duplicate local definition, no import-time side effects
  • Zero behavior change. Diff: agent/conversation_loop.py 1 insertion / 45 deletions (deleted set exactly 4048–4092); new module 45 lines; seam test 91 lines.

Method

5×2×3 double-blind decomposition (per the All Gods Must Die mandate): 5 blind region analysts → 5 blind adversarial witnesses → 5 consensus adjudicators → blind implementer → 2 blind re-reviewers, both APPROVED:

  • Review 1: C:/tmp/tg-Feature Package/conversation-loop/review/CLR31-review-1.md (11,075 B) — all gates PASS
  • Review 2: C:/tmp/tg-Feature Package/conversation-loop/review/CLR31-review-2.md (12,735 B) — APPROVED, all gates (golden bytes, exact diff scope, runtime seam, namespace/monkeypatch compatibility, orphan/import/startup gates, source-scanning compatibility, differential suite, mutation positive control)

Suite evidence: pristine-pin vs post-extraction failure sets identical; source-scanning tests (test_nous_oauth_401_guidance.py, test_prompt_caching.py, test_surrogate_chokepoints.py) verified — no source assertions invalidated by the relocation. No new failures.

Coordination table

Item Value
Pin ee4bb75b532e932a1055d9a710802a7435163b6a (origin/main)
Slice CL-R3-1 (conversation_loop region 3, first slice)
Window 4048–4092 (45 lines, 2,787 bytes, 18-element tuple)
Module agent/conversation_loop_image_recovery.py
Golden sha c5f51fe68fcacfdfe0936c10660d87259ccaf0f70e12213eb57916dfb6f2f527
Colliders #83437 (langfuse tracing) — live file-list check at extraction: no hunks in 4048–4092; semantic overlap LOW (phrase data only). Siblings #84275 (CL-R1-1), #84310 (CL-R2-1) — no hunks in window
Dependencies none
Conflicts none
Merge position standalone; no stacking

Dedup statement

No prior extraction of this window exists. No duplicate work.

Credit

  • Author: Axl Ibiza, MBA (DCO-signed commit 351915781b3)
  • Method: All Gods Must Die 5×2×3 (blind lanes, consensus contracts, blind re-review)

This slice is governed by the conversation_loop (posted on #78641). Former whole: 7,757 lines. Fixer roster: #83437.

Part of #78641
Part of #78647

Signed-off-by: Axl Ibiza <andrexibiza@gmail.com>
Contributor email mapping required by check-attribution CI for the
god-file kill campaign PRs (Axl Ibiza, MBA <andrexibiza@gmail.com>).

Signed-off-by: Axl Ibiza, MBA <andrexibiza@gmail.com>
@Enough1122

Copy link
Copy Markdown
Contributor

AI code review — automated review for reference, author can ignore or act on any point.

refactor(conversation_loop): extract image-rejection phrases slice CL-R3-1 into agent/conversation_loop_image_recovery.py

  1. Source-reading test contradicts repo policytests/agent/test_conversation_loop_image_recovery_seam.py:176-195: test_original_module_has_no_duplicate_local_tuple_definition reads _LOOP_PATH.read_text(encoding="utf-8") and AST-parses it, and test_image_recovery_module_has_no_import_time_side_effect_nodes reads the new module's source too. Per AGENTS.md ("Never read source code in tests"), these test the shape of files, not behavior — they pass even if the wiring is broken at runtime and break on unrelated formatting/refactor changes. The identity assertion (conversation_loop._IMAGE_REJECTION_PHRASES is _IMAGE_REJECTION_PHRASES) already proves the re-export contract; the AST/read_text checks are change-detectors on file shape and should be dropped.

  2. Local -> module-global move is safe here — the tuple previously lived as a local inside _perform_api_call; it is now a module-level name imported into conversation_loop. Immutable tuple, so behavior is identical, and the local-assignment shadowing hazard (a future local reassignment accidentally shadowing the module global) is the only new risk — the AST test guards exactly that, which is the one defensible use of a source check, but it could be replaced by a runtime assertion on the resolved value inside the handler path.

  3. No blocking issues — the extraction is byte-verbatim with zero imports in the new module; the phrase-list equality test (tuple preserved, value order intact) is a reasonable pin given the tuple is a hardcoded allow-list.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/agent Core agent runtime: loop, agent_init, prompt builder, context-compression, responses endpoint P3 Low — cosmetic, nice to have tool/vision Vision analysis and image generation type/refactor Code restructuring, no behavior change

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants