fix(agent): preserve MiniMax context length on delta-only overflow (salvage #9170)#14743
Merged
Conversation
For release-notes attribution of PR #9170 (MiniMax context preservation).
This was referenced Apr 24, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
On MiniMax providers, treat
context window exceeds limit (N)as an overflow delta — keep the known 204,800-token window and compress, instead of probing down to the generic 128k tier.Root cause
MiniMax's Anthropic-compatible endpoint returns
"invalid params, context window exceeds limit (2013)"where2013is the overflow amount, not the window size.parse_context_limit_from_error()correctly returnsNonefor this message (the generic regex doesn't match numbers inside parentheticals).get_next_probe_tier(204800)→ returns128000.compressor.update_model(context_length=128000)silently halves the window for the rest of the session./exit+ resume fixes it becauseDEFAULT_CONTEXT_LENGTHS["minimax"] = 204800is re-read from scratch. Reported in Discord against MiniMax M2.7.Changes
run_agent.py(+22 / -1 around L10576): when the provider is MiniMax (by provider name OR Anthropic-compat base URL) and the message matches the delta-only pattern, keepcontext_lengthand compress without demoting the window.tests/agent/test_model_metadata.py(+4): regression — parser returnsNonefor the MiniMax delta message.tests/run_agent/test_run_agent.py(+83): MiniMax path keeps 204,800; non-MiniMax providers still probe down to 128k for the same text.scripts/release.py(+1): AUTHOR_MAP entry for contributor attribution (separate commit).Validation
NoneNone(unchanged)scripts/run_tests.sh tests/agent/test_model_metadata.py tests/run_agent/test_run_agent.py -k "minimax_delta or glm_prompt"→ 3/3 passed. Broader sweep acrosstest_minimax_provider.py,test_1630_context_overflow_loop.py,test_413_compression.py→ 151 passed, 1 pre-existing_fallback_chainfailure onorigin/mainunrelated to this PR.Attribution
Salvage of #9170 by @maelrx. Cherry-picked onto current main (branch was 1,508 commits behind); authorship preserved via rebase-merge. Follow-up commit adds the contributor to
scripts/release.pyAUTHOR_MAP for release-notes CI.