Skip to content

fix(fallback): forward custom_providers to fallback model context-length detection#26043

Closed
PaTTeeL wants to merge 1 commit into
NousResearch:mainfrom
PaTTeeL:fix/fallback-forward-custom-providers
Closed

fix(fallback): forward custom_providers to fallback model context-length detection#26043
PaTTeeL wants to merge 1 commit into
NousResearch:mainfrom
PaTTeeL:fix/fallback-forward-custom-providers

Conversation

@PaTTeeL

@PaTTeeL PaTTeeL commented May 15, 2026

Copy link
Copy Markdown
Contributor

This is a sibling fix to the auxiliary compression fix (PR #25494). The same root cause: get_model_context_length() is called without custom_providers, so per-model context_length overrides in custom_providers are silently skipped. The fallback activation path (_try_activate_fallback) had the same missing parameter.

When the agent switches to a fallback provider, _try_activate_fallback() probes the fallback model's context window via get_model_context_length(). Without custom_providers, it skips step 0b and falls through to models.dev, which may return a different value than what the user configured (e.g. 204800 from models.dev vs 196608 from custom_providers for NVIDIA NIM minimax-m2.7). This can cause the fallback model to run with an incorrect context window, leading to truncated messages or failed API requests.

Fix: added custom_providers=self._custom_providers to the get_model_context_length() call in _try_activate_fallback(), matching what the main model and auxiliary compression paths already do.

Changes: 1 line in run_agent.py

Related to #25494 (same root cause, different call site).

…gth detection

The same root cause as the auxiliary compression fix (commit 7becb19):
get_model_context_length() is called without custom_providers, so per-model
context_length overrides are silently skipped.  The fallback activation path
(_try_activate_fallback) had the same missing parameter.

When the agent switches to a fallback provider, the fallback model would use
the models.dev value (e.g. 204800 for NVIDIA NIM minimax-m2.7) instead of
the user-configured one in custom_providers (e.g. 196608) — a subtle
discrepancy that could cause the fallback model to run with an incorrect
context window, leading to truncated messages or failed API requests when
the model does not support the detected length.

Fix: pass self._custom_providers to get_model_context_length() so the
fallback path sees the same per-model overrides as the main model path.
@alt-glitch alt-glitch added type/bug Something isn't working duplicate This issue or pull request already exists P2 Medium — degraded but workaround exists comp/agent Core agent loop, run_agent.py, prompt builder area/config Config system, migrations, profiles labels May 15, 2026
@alt-glitch

Copy link
Copy Markdown
Collaborator

Duplicate of #25554 — same one-line fix (forward custom_providers to get_model_context_length() in _try_activate_fallback()). PR #25554 is more comprehensive (re-reads from config, includes regression test). Part of the broader context-length propagation chain: #8785, #15844 (merged), #25494 (merged).

@teknium1

Copy link
Copy Markdown
Contributor

Merged via PR #27247 — your commit was cherry-picked onto current main as part of a batch salvage of low-risk new-contributor PRs. Authorship preserved (fix(fallback): forward custom_providers to fallback model context-length detection). Thanks for the contribution — appreciate it.

@teknium1 teknium1 closed this May 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/config Config system, migrations, profiles comp/agent Core agent loop, run_agent.py, prompt builder duplicate This issue or pull request already exists P2 Medium — degraded but workaround exists type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants