Fix context overrun crash with local LLM backends#403
Merged
teknium1 merged 1 commit intoNousResearch:mainfrom Mar 5, 2026
Merged
Fix context overrun crash with local LLM backends#403teknium1 merged 1 commit intoNousResearch:mainfrom
teknium1 merged 1 commit intoNousResearch:mainfrom
Conversation
…#348) Local backends (LM Studio, Ollama, llama.cpp) return HTTP 400 with messages like "Context size has been exceeded" when the context window is full. The error phrase list did not include "context size" or "context window", so these errors fell through to the generic 4xx abort handler instead of triggering compression. Changes: - Move context-length check above generic 4xx handler so it runs first (same pattern as the existing 413 check) - Add "context size" and "context window" to the phrase list - Guard 4xx handler with `not is_context_length_error` to prevent context-related 400s from being treated as non-retryable
Contributor
|
Merged in commit 3220bb8 — your PR was based on an older main where the error handler ordering was different, so it had merge conflicts, but the fix was applied with your changes preserved (added |
Closed
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.
Fixes #348
Problem
Local inference backends (LM Studio, Ollama, llama.cpp) return HTTP 400 with error messages like
"Context size has been exceeded"when the context window is full. The context-length error phrase list did not include"context size"or"context window", so these errors fell through to the generic 4xx abort handler — crashing the session instead of triggering compression.Error flow before this fix:
Fix
"context size"(LM Studio),"context window"(Ollama)not is_context_length_errorso context-related 400s are never treated as non-retryableError flow after this fix:
Tested error messages
Test plan