Skip to content

fix(agent): route reasoning model disconnects to timeout, not context_overflow - #52294

Closed
AlexFucuson9 wants to merge 1 commit into
NousResearch:mainfrom
AlexFucuson9:fix/reasoning-model-context-overflow-misclassify
Closed

fix(agent): route reasoning model disconnects to timeout, not context_overflow#52294
AlexFucuson9 wants to merge 1 commit into
NousResearch:mainfrom
AlexFucuson9:fix/reasoning-model-context-overflow-misclassify

Conversation

@AlexFucuson9

Copy link
Copy Markdown
Contributor

Problem

When a reasoning model (o1/o3, DeepSeek R1, Nemotron, Grok reasoning, QwQ) hits a transport disconnect on a large session, the error classifier incorrectly classifies it as context_overflow with should_compress=True.

Reasoning models can think for minutes before producing tokens. A transport disconnect during thinking is almost always an upstream proxy idle-kill (NVIDIA NIM ~120s, OpenAI/Anthropic stream-idle), NOT a real context overflow. Classifying it as context_overflow triggers destructive compression on a phantom error, silently deleting conversation history.

Fix

Add reasoning model detection before the context_overflow classification at agent/error_classifier.py:718. For reasoning models, route to timeout instead so retries/fallback can handle the disconnect properly.

# Reasoning model prefixes that should skip context_overflow classification
_reasoning_prefixes = (
    "o1", "o3", "o4",
    "deepseek-r", "deepseek-reasoner",
    "nemotron", "qwq", "qwen3",
    "grok-4",
)

Files changed

File Change
agent/error_classifier.py Add reasoning model check before context_overflow classification (+21 lines)

Fixes #52271

…_overflow

When a reasoning model (o1/o3, DeepSeek R1, Nemotron, Grok reasoning,
QwQ) hits a transport disconnect on a large session, the error classifier
incorrectly classified it as context_overflow with should_compress=True.

Reasoning models can think for minutes before producing tokens. A
transport disconnect during thinking is almost always an upstream proxy
idle-kill (NVIDIA NIM ~120s, OpenAI/Anthropic stream-idle), NOT a real
context overflow. Classifying it as context_overflow triggers destructive
compression on a phantom error, silently deleting conversation history.

Add reasoning model detection before the context_overflow classification.
For reasoning models, route to timeout instead so retries/fallback can
handle the disconnect properly.

Fixes NousResearch#52271
@alt-glitch alt-glitch added type/bug Something isn't working comp/agent Core agent runtime: loop, agent_init, prompt builder, context-compression, responses endpoint P1 High — major feature broken, no workaround labels Jun 25, 2026

@tonydwb tonydwb left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review Summary

Verdict: Approved

Clean fix for reasoning model error classification. Transport disconnects on reasoning models now correctly route to timeout instead of context_overflow, preventing destructive compression on phantom errors. Good explanation of the root cause.

Changes:

  • agent/error_classifier.py: 21 additions — reasoning model detection before context_overflow classification

LGTM.

Reviewed by Hermes Agent

@kshitijk4poor

Copy link
Copy Markdown
Collaborator

Issue #52271 was fixed in #52795 (merged). This PR addresses Layer 1 of the same issue (classifier routing) but the full fix has landed. Thanks for the contribution!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/agent Core agent runtime: loop, agent_init, prompt builder, context-compression, responses endpoint P1 High — major feature broken, no workaround type/bug Something isn't working

Projects

None yet

5 participants