fix(error_classifier): avoid large-context false overflow heuristics - #16352
Closed
JayGwod wants to merge 1 commit into
Closed
fix(error_classifier): avoid large-context false overflow heuristics#16352JayGwod wants to merge 1 commit into
JayGwod wants to merge 1 commit into
Conversation
JayGwod
force-pushed
the
fix/error-classifier-large-context-heuristics
branch
3 times, most recently
from
April 28, 2026 21:09
a10d5f1 to
083fcb1
Compare
Author
|
Bumping — open for 5 days, no review activity. Status on current upstream/main (
Happy to clarify or rework the heuristic if there's a preferred boundary. Thanks! |
JayGwod
force-pushed
the
fix/error-classifier-large-context-heuristics
branch
from
May 3, 2026 02:42
083fcb1 to
fdadc26
Compare
Generic 400 and server-disconnect heuristics used absolute token/message-count fallbacks that are too aggressive for 1M context sessions. Gate those absolute fallbacks to smaller context windows while preserving relative pressure checks. Fixes NousResearch#16351
JayGwod
force-pushed
the
fix/error-classifier-large-context-heuristics
branch
from
May 4, 2026 02:03
fdadc26 to
abf4d53
Compare
Contributor
|
Salvaged via #19723 onto current main - your commit authorship was preserved. Thanks! |
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
Fixes a large-context false-positive in
agent.error_classifier: generic HTTP 400 responses and server disconnects should not be classified ascontext_overflowsolely because a 1M-context session has many messages.The previous heuristic used absolute fallbacks:
Those thresholds are useful proxies for smaller context windows, but they are too aggressive for explicitly large windows. A 1M-context session can have 432 messages and ~74K estimated tokens while still being far below the real budget.
This patch keeps the relative pressure checks for all models, but gates the absolute token/message-count fallbacks to smaller context windows (
<= 256000).Behavior covered
approx_tokens=74320,context_length=1_000_000,num_messages=432is nowformat_error, notcontext_overflow.timeout, notcontext_overflow.Test plan
RED before fix:
/home/ubuntu/.hermes/hermes-agent/venv/bin/python -m pytest \ tests/agent/test_error_classifier.py::TestClassifyApiError::test_400_generic_many_messages_below_large_context_pressure_is_format_error \ tests/agent/test_error_classifier.py::TestClassifyApiError::test_disconnect_many_messages_below_large_context_pressure_is_timeout \ -v -o 'addopts='Both tests failed with
FailoverReason.context_overflow.GREEN after fix:
/home/ubuntu/.hermes/hermes-agent/venv/bin/python -m pytest tests/agent/test_error_classifier.py -q -o 'addopts=' /home/ubuntu/.hermes/hermes-agent/venv/bin/python -m py_compile agent/error_classifier.py tests/agent/test_error_classifier.py git diff --checkResult:
Manual reproduction after fix:
Fixes #16351
Related: #14499, #14858, #14953, #15844, #6751