Skip to content

fix(cli): auto-detect context length for custom providers when not specified - #2522

Closed
ygd58 wants to merge 3 commits into
NousResearch:mainfrom
ygd58:fix/custom-provider-context-length-autodetect
Closed

ygd58 wants to merge 3 commits into
NousResearch:mainfrom
ygd58:fix/custom-provider-context-length-autodetect

Conversation

@ygd58

@ygd58 ygd58 commented Mar 22, 2026

Copy link
Copy Markdown

Fixes #2513

Problem

When saving a custom provider via /model without specifying a context length, users had no feedback on what context window was being used.

Fix

After the user leaves context length blank, attempt auto-detection via get_model_context_length(model_name):

  • If detected: show 💡 Context length auto-detected: X tokens and save to config
  • If not detected: show 📏 Context length: using default 128,000 tokens

Tests

Added tests/test_custom_provider_context_detection.py with 4 tests:

  • Auto-detection for known models
  • Default fallback for unknown models
  • _save_custom_provider with context_length
  • _save_custom_provider without context_length

@alt-glitch

Copy link
Copy Markdown

Competing with #2514 for the same issue #2513. This PR is narrower in scope (context detection only), while #2514 also touches flag parsing and delegate_tool credential resolution.

@alt-glitch alt-glitch added type/bug Something isn't working P3 Low — cosmetic, nice to have comp/cli CLI entry point, hermes_cli/, setup wizard area/config Config system, migrations, profiles labels May 3, 2026
@alt-glitch

Copy link
Copy Markdown

Competing with #2514 for the same issue #2513.

@teknium1 teknium1 closed this May 11, 2026
teknium1 added a commit that referenced this pull request Sep 12, 2026
…der is saved without one

Leaving the context-length prompt blank in the custom-endpoint wizard said
"will auto-detect" and then went silent, so users could not tell whether their
endpoint runs on a detected window or the runtime's default fallback (which
shapes compression and prompt-cache behaviour). After the save prompt, run the
same resolver the runtime uses (with the endpoint's URL and key) and print
either "auto-detected N tokens" or "not detected — using the default N tokens".
Feedback only: the probe result is not persisted, and a failing probe never
blocks the save.

Fixes #2513. Approach from PR #2522 (@ygd58) and PR #85499 (@Luna161), both
written against the pre-decomposition wizard module.

Co-authored-by: Luna161 <268031236+Luna161@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/config Config system, migrations, profiles comp/cli CLI entry point, hermes_cli/, setup wizard P3 Low — cosmetic, nice to have type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Custom providers lack context length auto-detection when saved via /model command

3 participants