Skip to content

fix(error_classifier): narrow max_tokens pattern to avoid matching empty-response advisories (#66818) - #66937

Closed
webtecnica wants to merge 1 commit into
NousResearch:mainfrom
webtecnica:fix/error-classifier-empty-response
Closed

fix(error_classifier): narrow max_tokens pattern to avoid matching empty-response advisories (#66818)#66937
webtecnica wants to merge 1 commit into
NousResearch:mainfrom
webtecnica:fix/error-classifier-empty-response

Conversation

@webtecnica

Copy link
Copy Markdown
Contributor

Summary

Empty-response advisories (e.g. nano-gpt / OpenRouter) include very low max_tokens as a possible cause. The literal substring max_tokens matched _CONTEXT_OVERFLOW_PATTERNS, causing Hermes to misclassify the error as context overflow, enter the compression loop, and end with Cannot compress further.

Fix

Narrowed max_tokensmax_tokens limit in _CONTEXT_OVERFLOW_PATTERNS.

  • Advisory text like very low max_tokens no longer matches (does not contain limit)
  • Real overflow messages like exceeds the max_tokens limit still match

Verification

  • python3 -m py_compile agent/error_classifier.py
  • Existing tests pass (the GPT-5 max_tokens is not supported false positive is already guarded by the request-validation check that runs before context_overflow)
  • No test asserted bare max_tokens alone matches an overflow

Closes #66818

…pty-response advisories (NousResearch#66818)

Empty-response advisories (e.g. nano-gpt / OpenRouter) say 'very low
max_tokens' as a possible cause. The literal substring 'max_tokens'
matched _CONTEXT_OVERFLOW_PATTERNS, causing Hermes to misclassify
the error as context overflow, enter the compression loop, and end
in 'Cannot compress further'.

Narrowed 'max_tokens' to 'max_tokens limit' so advisory text does
not match while real overflow messages (which always reference the
limit) still do.
@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 P2 Medium — degraded but workaround exists duplicate This issue or pull request already exists labels Jul 18, 2026
@alt-glitch

Copy link
Copy Markdown
Collaborator

This was generated by AI during triage.

Duplicate of #66818. Both address empty-response advisories mentioning low max_tokens entering the compression loop; #66818 is the earlier, broader fix and preserves valid bare-max_tokens overflow handling.

@teknium1

Copy link
Copy Markdown
Contributor

Thanks for this, @webtecnica — you nailed the exact root cause (the bare max_tokens substring in _CONTEXT_OVERFLOW_PATTERNS matching nano-gpt/OpenRouter empty-response advisories and sending healthy sessions into the compression death-spiral).

We landed the fix in #66818 (merged as 032a424). It takes a slightly different approach than narrowing max_tokensmax_tokens limit: bare max_tokens is load-bearing — the output-cap-retry path keys off it (e.g. max_tokens: 65536 > context_window: 200000), and some real-overflow phrasings don't contain "limit", so narrowing the pattern would lose coverage. Instead #66818 adds an _EMPTY_PROVIDER_RESPONSE_PATTERNS interceptor that runs before the overflow match in all four classifier paths (400, 500, 503/529, message-only), routing the advisory to retryable server_error with should_compress=False while leaving the overflow list intact.

Closing as redundant, but your diagnosis was spot-on. Appreciate you catching it.

@teknium1 teknium1 closed this Jul 18, 2026
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 duplicate This issue or pull request already exists P2 Medium — degraded but workaround exists type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants