NousResearch/hermes-agent

Fix false context overflow errors in large sessions

Cluster 16351 · agent. Data as of

Nothing open on GitHub. Fix merged in #19723 on 4 May 2026. Check it covers your case.

The short answer

0open issues
0open PRs
4items grouped
Known?
Yes. 4 related items grouped here, 1 issue already closed.
Fix event
A fix was merged to main in PR #19723. Check it covers your case. No release data is tracked.
Tracker
The maintainers' tracker marks this unresolved. That is separate from the fix event.
Still open
Nothing open on GitHub.

These issues and fixes address a bug where generic 400/disconnect errors were incorrectly classified as context overflow in large-context (e.g. 1M-token) sessions. The fixes gate absolute message and token heuristics to small context windows to avoid false positives.

Open issues0

No open issues.

Open PRs0

No open pull requests.

Fixes on record

Merged to main. A stamp counts the issues a fix is linked to.

  • #19723 fix(error_classifier): avoid large-context false overflow heuristics

    merged to main

    files: agent/error_classifier.py, tests/agent/test_error_classifier.py

    Show the diff
    • agent/error_classifier.py
      @@ -520,7 +520,12 @@ def _result(reason: FailoverReason, **overrides) -> ClassifiedError:
       
           is_disconnect = any(p in error_msg for p in _SERVER_DISCONNECT_PATTERNS)
           if is_disconnect and not status_code:
      -        is_large = approx_tokens > context_length * 0.6 or approx_tokens > 120000 or num_messages > 200
      +        # Absolute token/message-count thresholds are only a proxy for smaller
      +        # context windows.  Large-context sessions can have hundreds of
      +        # messages while still being far below their actual token budget.
      +        is_large = approx_tokens > context_length * 0.6 or (
      +            context_length <= 256000 and (approx_tokens > 120000 or num_messages > 200)
      +        )
               if is_large:
                   return _result(
                       FailoverReason.context_overflow,
      @@ -766,7 +771,12 @@ def _classify_400(
               if not err_body_msg:
                   err_body_msg = str(body.get("message") or "").strip().lower()
           is_generic = len(err_body_msg) < 30 or err_body_msg in ("error", "")
      -    is_large = approx_tokens > context_length * 0.4 or approx_tokens > 80000 or num_messages > 80
      +    # Absolute token/message-count thresholds are only a proxy for smaller
      +    # context windows.  Large-context sessions can have many messages while
      +    # still being far below their actual token budget.
      +    is_large = approx_tokens > context_length * 0.4 or (
      +        context_length <= 256000 and (approx_tokens > 80000 or num_messages > 80)
      +    )
       
           if is_generic and is_large:
               return result_fn(
    • tests/agent/test_error_classifier.py
      @@ -410,6 +410,24 @@ def test_400_generic_small_session_is_format_error(self):
               result = classify_api_error(e, approx_tokens=1000, context_length=200000)
               assert result.reason == FailoverReason.format_error
       
      +    def test_400_generic_many_messages_below_large_context_pressure_is_format_error(self):
      +        """Large-context sessions should not overflow solely due to message count."""
      +        e = MockAPIError(
      +            "Error",
      +            status_code=400,
      +            body={"error": {"message": "Error"}},
      +        )
      +        result = classify_api_error(
      +            e,
      +            provider="openai-codex",
      +            model="gpt-5.5",
      +            approx_tokens=[redacted:secret-assignment]
      +            context_length=1_000_000,
      +            num_messages=432,
      +        )
      +        assert result.reason == FailoverReason.format_error
      +        assert result.should_compress is False
      +
           # ── Server disconnect + large session ──
       
           def test_disconnect_large_session_context_overflow(self):
      @@ -425,6 +443,20 @@ def test_disconnect_small_session_timeout(self):
               result = classify_api_error(e, approx_tokens=5000, context_length=200000)
               assert result.reason == FailoverReason.timeout
       
      +    def test_disconnect_many_messages_below_large_context_pressure_is_timeout(self):
      +        """Large-context disconnects should not overflow solely due to message count."""
      +        e = Exception("server disconnected without sending complete message")
      +        result = classify_api_error(
      +            e,
      +            provider="openai-codex",
      +            model="gpt-5.5",
      +            approx_tokens=[redacted:secret-assignment]
      +            context_length=1_000_000,
      +            num_messages=432,
      +        )
      +        assert result.reason == FailoverReason.timeout
      +        assert result.should_compress is False
      +
           # ── Provider-specific: Anthropic thinking signature ──
       
           def test_anthropic_thinking_signature(self):

2 PRs closed without merging

From the close comments: merged via another change 2

  • #16352 fix(error_classifier): avoid large-context false overflow heuristics · merged via another change → #19723
  • #16380 fix(error_classifier): gate absolute msg/token heuristics to small context windows · merged via another change → d29f90e, #19723
Closed issues · 1
  • Closed#16351Generic 400/disconnect errors misclassified as context_overflow in 1M-context sessions
How this cluster was grouped
  • Link evidence (structural links throughout): every member is connected by structural evidence: shared changed files, or a closing/superseded reference.
  • Pairwise link density 0.50: the share of item pairs that carry a link, counting a structural link in full and a relevance-only link at 0.36. 1.00 means every pair is linked.

Pick up a Lab task

Check whether a fix covers the open issues here, with your own agent. Bring back evidence for maintainers.

Open the Lab

At a glance

Subsystem
agent
Merged PRs
#19723
Closed issues
1
Attempts
2 PRs closed without merging
Fix link checked
4 May 2026

For your agent

The same facts, typed.