fix: preserve Ollama model:tag colons in context length detection#2147
Closed
kshitijk4poor wants to merge 3 commits into
Closed
fix: preserve Ollama model:tag colons in context length detection#2147kshitijk4poor wants to merge 3 commits into
kshitijk4poor wants to merge 3 commits into
Conversation
The colon-split logic in get_model_context_length() and _query_local_context_length() assumed any colon meant provider:model format (e.g. "local:my-model"). But Ollama uses model:tag format (e.g. "qwen3.5:27b"), so the split turned "qwen3.5:27b" into just "27b" — which matches nothing, causing a fallback to the 2M token probe tier. Now only recognised provider prefixes (local, openrouter, anthropic, etc.) are stripped. Ollama model:tag names pass through intact.
- Replace double split(":", 1) with single partition() call
- Add comment noting _PROVIDER_PREFIXES mirrors hermes_cli/models.py
and must be kept in sync when adding new providers
Contributor
|
Merged via PR #2149 — your commit was cherry-picked onto current main with authorship preserved. Thanks for the fix @kshitijk4poor! |
This was referenced Apr 21, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
get_model_context_length()and_query_local_context_length()(agent/model_metadata.py) assumed any colon in a model name meantprovider:modelformat (e.g.local:my-model). Ollama usesmodel:tagformat (e.g.qwen3.5:27b), so the split turnedqwen3.5:27binto just27b— which matches nothing in the defaults or cache, causing a fallback to the 2M token probe tier._strip_provider_prefix()helper that only strips recognised provider names (matching the set already used byparse_model_inputinhermes_cli/models.py). Ollama-stylemodel:tagnames now pass through intact.get_model_context_lengthline ~693 and_query_local_context_lengthline ~584) now use the safe helper.Test plan
TestStripProviderPrefixwith 5 test cases covering:local:my-model→my-model)qwen3.5:27b,llama3.3:70b,gemma2:9b,codellama:13b-instruct-q4_0)qwen3.5:27breaches endpoint metadata lookup with full name intact