Skip to content

fix(agent): preserve MiniMax context length on delta-only overflow (salvage #9170)#14743

Merged
teknium1 merged 2 commits into
mainfrom
hermes/hermes-246692a8
Apr 23, 2026
Merged

fix(agent): preserve MiniMax context length on delta-only overflow (salvage #9170)#14743
teknium1 merged 2 commits into
mainfrom
hermes/hermes-246692a8

Conversation

@teknium1

Copy link
Copy Markdown
Contributor

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)" where 2013 is the overflow amount, not the window size.

  1. parse_context_limit_from_error() correctly returns None for this message (the generic regex doesn't match numbers inside parentheticals).
  2. Recovery falls through to get_next_probe_tier(204800) → returns 128000.
  3. compressor.update_model(context_length=128000) silently halves the window for the rest of the session.
  4. User-visible symptom: context window shows 204,800 at session start, 128,000 after the first overflow round-trip. /exit + resume fixes it because DEFAULT_CONTEXT_LENGTHS["minimax"] = 204800 is 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, keep context_length and compress without demoting the window.
  • tests/agent/test_model_metadata.py (+4): regression — parser returns None for 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

Before After
MiniMax + delta-only overflow context 204,800 → 128,000 context stays at 204,800, compresses
Non-MiniMax + same text probes to 128,000 probes to 128,000 (unchanged)
Parser on delta msg None None (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 across test_minimax_provider.py, test_1630_context_overflow_loop.py, test_413_compression.py → 151 passed, 1 pre-existing _fallback_chain failure on origin/main unrelated 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.py AUTHOR_MAP for release-notes CI.

@teknium1 teknium1 merged commit a0d8dd7 into main Apr 23, 2026
10 of 11 checks passed
@teknium1 teknium1 deleted the hermes/hermes-246692a8 branch April 23, 2026 21:06
@alt-glitch alt-glitch added type/bug Something isn't working P2 Medium — degraded but workaround exists comp/agent Core agent loop, run_agent.py, prompt builder provider/minimax MiniMax (Anthropic transport) labels Apr 23, 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 provider/minimax MiniMax (Anthropic transport) type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants