Skip to content

refactor(agent): extract fallback policy into auxiliary_fallback_policy (auxiliary_client.py R3-S1) - #80138

Open
andrexibiza wants to merge 1 commit into
NousResearch:mainfrom
andrexibiza:gfg/aux-extract-r3s1
Open

refactor(agent): extract fallback policy into auxiliary_fallback_policy (auxiliary_client.py R3-S1)#80138
andrexibiza wants to merge 1 commit into
NousResearch:mainfrom
andrexibiza:gfg/aux-extract-r3s1

Conversation

@andrexibiza

@andrexibiza andrexibiza commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

Summary

agent/auxiliary_client.py god-file slice R3-S1: extract the runtime fallback policy cluster (window 4891–5369, 479 lines, 9 defs) into agent/auxiliary_fallback_policy.py. Part of the repo-wide large-file decomposition (tracker #78647, target #78635).

What changed and why

  • 9 defs moved byte-verbatim (golden sha256 c365b2fde16264d31cb79e577ad4519162ac172aea689fa273aca215ef7ded11 verified; zero unsanctioned byte differences)
  • Moved: _try_payment_fallback, _try_main_agent_model_fallback, _task_minimum_context_length, _candidate_context_window, _try_configured_fallback_chain, _try_configured_fallback_for_unavailable_client, _fallback_entry_api_key, _resolve_fallback_entry, _try_main_fallback_chain
  • Re-export block at the old location keeps all 9 names resolvable as agent.auxiliary_client.<name> with __func__ identity (tests patch these names; agent/conversation_compression.py:1595 imports one of them)
  • Outward edges (6 names) are function-local lazy imports — no import cycle, patch-through-monolith probes observed patched globals (no silent no-op seam)
  • Window collision-free: consensus census verified zero open-PR hunks in 4891–5369; fix(copilot): support GitHub Enterprise endpoints #78378's hunk sits below the window (in _auth_refresh_provider_for_route)
  • Double-blind: 2 blind analysts → R3-CONSENSUS → blind implementer → 2 independent blind witnesses (pass A + adversarial pass B) — both VERIFIED, zero failing checks

Testing

  • 213 passed / 2 failed (4 gate files) in worktree; the 2 failures are byte-identical at pristine origin/main baseline (environment class, proven — not slice regressions)
  • Seam identity: all 9 names is-identical in fresh interpreters, both import orders
  • Standalone import agent.auxiliary_fallback_policy succeeds (no eager monolith import)
  • py_compile clean · LF-only · git diff --check clean · DCO signed

Coordination / interlock

Part of #78647
Part of #78635

…cy (auxiliary_client.py R3-S1, epic NousResearch#78647)

Signed-off-by: andrexibiza <84248988+andrexibiza@users.noreply.github.com>
@alt-glitch alt-glitch added type/refactor Code restructuring, no behavior change comp/agent Core agent runtime: loop, agent_init, prompt builder, context-compression, responses endpoint P3 Low — cosmetic, nice to have needs-decision Awaiting maintainer decision before any implementation labels Aug 6, 2026

Copy link
Copy Markdown
Contributor Author

Decision recorded against current main 3a034356a237341452b7afebd3a2bfd21021609f.

Do not land this fallback-policy slice first. The maintained auxiliary sequence is:

  1. refactor(agent): extract anthropic-compat helpers into aux_anthropic_compat (auxiliary_client.py R4-S1) #80139 — Anthropic compatibility leaf
  2. refactor(agent): extract extract_content_or_reasoning into auxiliary_text (auxiliary_client.py R5-S1) #80140 — text-normalization leaf
  3. refactor(agent): extract fallback policy into auxiliary_fallback_policy (auxiliary_client.py R3-S1) #80138 — fallback policy

The historical #79787 gate is no longer pending: its work was salvaged to main through #85576. The active semantic gates are #79792, which still changes auto-resolution/provider-coherence behavior in this ownership area, and #78378, whose current Enterprise-endpoint disposition must be reconciled before fallback policy is frozen into a new module.

Required branch work: rebase after #80139/#80140, retarget any surviving #79792/#78378 logic to the canonical owner, fail closed on duplicate ownership, recompute the exact source-window/golden proof, and rerun current-main fallback/resolver suites. The decision is complete; the current head is not yet landable.

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 needs-decision Awaiting maintainer decision before any implementation P3 Low — cosmetic, nice to have type/refactor Code restructuring, no behavior change

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants