Skip to content

fix: preserve explicit context window on generic overflow#14953

Closed
atmigtnca wants to merge 1 commit into
NousResearch:mainfrom
atmigtnca:fix/preserve-explicit-context-window
Closed

fix: preserve explicit context window on generic overflow#14953
atmigtnca wants to merge 1 commit into
NousResearch:mainfrom
atmigtnca:fix/preserve-explicit-context-window

Conversation

@atmigtnca

@atmigtnca atmigtnca commented Apr 24, 2026

Copy link
Copy Markdown

Summary

  • Preserve explicit model.context_length when a generic context-overflow error does not include a concrete provider limit.
  • Keep trusting parsed provider-reported lower limits when present.
  • Add regression coverage for explicit 1M context windows so sessions do not silently degrade to the 128K probe tier.

Test Plan

  • python -m pytest tests/test_ctx_halving_fix.py -q -o 'addopts='
  • python -m pytest tests/agent/test_model_metadata.py tests/run_agent/test_switch_model_context.py tests/run_agent/test_compressor_fallback_update.py -q -o 'addopts='

Context

Long-running TUI sessions with an explicit 1M context configuration could fall back to the generic 128K probe tier after a generic overflow/transport error that did not report an actual lower context limit. This made the status bar suddenly show 128K even though the configured model window was still 1M.

@teknium1

Copy link
Copy Markdown
Contributor

Closing — same root cause was addressed via #33826 (salvaged from #33673 by @yangguangjin). Your earlier PR identified and partially fixed the same bug (preserving explicit model.context_length on generic overflow). The final fix takes a broader stance: never probe-step down on a guessed tier, regardless of whether the window was explicitly configured or auto-detected.

Thanks for the original work and analysis here — it informed the eventual fix.

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

Labels

comp/agent Core agent loop, run_agent.py, prompt builder 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