fix(error_classifier): gate absolute msg/token heuristics to small context windows - #16380
Closed
Sanjays2402 wants to merge 1 commit into
Closed
fix(error_classifier): gate absolute msg/token heuristics to small context windows#16380Sanjays2402 wants to merge 1 commit into
Sanjays2402 wants to merge 1 commit into
Conversation
…ntext windows (closes NousResearch#16351) Generic 400s and server disconnects in long Codex/GPT-5.x sessions (1M context window) were being classified as context_overflow purely because num_messages > 80 (or > 200 for disconnects), even when approx_tokens was well under the relative threshold (e.g. 74K against 1M). That sent non-context errors into the compression/probe-down recovery path, causing unnecessary compaction and stale handoff pollution on explicit 1M sessions. Gate the absolute fallbacks behind context_length <= 256000 — preserves existing behavior for ~128K/200K windows while letting 1M sessions classify correctly via relative pressure only. Tests: pytest tests/agent/test_error_classifier.py -q -> 122/122 pass (118 pre-existing + 4 new for 1M-context generic-400 / disconnect low and high token-pressure cases).
Collaborator
Contributor
Author
|
CI status note for maintainers — the failing Verified by diffing the failing-test sets:
The clusters on main:
Happy to open targeted fix PRs for any of these clusters if it helps unblock the queue. Otherwise this PR is ready whenever main is green. |
Contributor
|
This appears to be implemented on current main now. Automated hermes-sweeper review found that the same large-context error-classifier fix was salvaged and merged via #19723 after the duplicate discussion noted on this PR. Evidence:
Thanks for the original fix and for the CI analysis on the PR. |
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.
Closes #16351.
Problem
agent/error_classifier.pyflagged non-context errors ascontext_overflowin long-context (1M) Codex/GPT-5.x sessions, purely becausenum_messages > 80(generic 400) ornum_messages > 200(disconnect) — even whenapprox_tokenswas a fraction of the actual budget.Repro from the issue:
That sent format errors into the compression/probe-down path, causing unnecessary compaction and stale handoff pollution on 1M sessions.
Fix
Apply exactly the gate suggested in the issue body: scope absolute token/message-count fallbacks to
context_length <= 256000. Relative pressure thresholds (> 0.6for disconnect,> 0.4for generic 400) still fire on any context size.Existing behavior for ~128K/200K context windows is unchanged.
Tests
tests/agent/test_error_classifier.py— 4 new tests covering the 1M-context regime:test_400_generic_1m_context_high_message_count_not_overflow— exact repro from issue (74K tokens, 432 msgs, 1M ctx) →format_error.test_400_generic_1m_context_relative_pressure_still_overflow— 500K tokens / 1M ctx still →context_overflow.test_disconnect_1m_context_high_message_count_is_timeout— 150K tokens, 300 msgs, 1M ctx →timeout.test_disconnect_1m_context_relative_pressure_still_overflow— 700K tokens / 1M ctx still →context_overflow.