Skip to content

fix(model_metadata): parse OpenRouter/Nous 'in the output' format in output-cap errors #38652 - #38689

Closed
kyssta-exe wants to merge 1 commit into
NousResearch:mainfrom
kyssta-exe:auto-fix/issue-38652
Closed

fix(model_metadata): parse OpenRouter/Nous 'in the output' format in output-cap errors #38652#38689
kyssta-exe wants to merge 1 commit into
NousResearch:mainfrom
kyssta-exe:auto-fix/issue-38652

Conversation

@kyssta-exe

Copy link
Copy Markdown
Contributor

Summary

only recognized Anthropic's keyword, causing it to return for OpenRouter/Nous errors that use the breakdown format. This led to the input-too-large recovery path (compression) being triggered instead of the correct output-cap reduction, resulting in infinite auto-reset loops.

Fix

Add a second detection strategy that:

  1. Identifies errors mentioning alongside
  2. Extracts the context limit from
  3. Sums input tokens from patterns like and
  4. Returns as the available output

Example

For the error:

Previously: returned → fell through to compression path → infinite loop
Now: returns (256000 - 5683 - 13410) → retries with

Tests

  • All 27 existing tests in pass
  • All 155 tests in pass
  • Added manual verification for OpenRouter/Nous error format

Closes #38652

@alt-glitch alt-glitch added type/bug Something isn't working P1 High — major feature broken, no workaround comp/agent Core agent runtime: loop, agent_init, prompt builder, context-compression, responses endpoint provider/openrouter OpenRouter aggregator provider/nous Nous Research API (OAuth) labels Jun 4, 2026
…ilable_output_tokens_from_error

The function previously only recognized Anthropic's 'available_tokens'
format, causing OpenRouter/Nous 'output cap too large' errors to fall
through to the input-too-large recovery path. This led to an infinite
auto-reset loop when max_tokens exceeded context_length - input_tokens.

Now also detects the 'N in the output' format used by OpenRouter and
Nous Research providers, enabling proper output-cap recovery.

Fixes NousResearch#38652
@teknium1

Copy link
Copy Markdown
Contributor

This has already been fixed on main.

Automated hermes-sweeper review evidence:

  • agent/model_metadata.py:1053 now recognizes the OpenRouter/Nous output-cap format by checking for "in the output" plus "maximum context length".
  • agent/model_metadata.py:1086 parses the breakdown form (... of text input, ... of tool input, ... in the output) and returns context - text_input - tool_input as the available output budget.
  • agent/conversation_loop.py:3040 consumes that parsed budget by setting _ephemeral_max_output_tokens and retrying without shrinking context_length, which is the recovery path this PR was aiming for.
  • tests/test_output_cap_parsing.py:8 has regression coverage for the OpenRouter/Nous breakdown format.
  • The implementation landed in 1fb99b1f229a700f8ee1a3e90ff1d44f85e963d4 via fix: guard empty streams + parse OpenRouter output-cap errors #40589 and is contained in tag v2026.6.19.

The linked issue #38652 was also already closed by a maintainer as fixed on main. Thanks for the original report and fix direction.

@teknium1 teknium1 closed this Jun 21, 2026
@teknium1 teknium1 added the sweeper:implemented-on-main Sweeper: behavior already present on current main label Jun 21, 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 P1 High — major feature broken, no workaround provider/nous Nous Research API (OAuth) provider/openrouter OpenRouter aggregator sweeper:implemented-on-main Sweeper: behavior already present on current main type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: parse_available_output_tokens_from_error() misses OpenRouter/Nous "in the output" format — causes infinite auto-reset loop

3 participants