You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
OpenAI-compatible providers without /v1/models endpoint fall back to hardcoded 200k context limit with no override #262
When using an OpenAI-compatible provider that doesn't expose a GET /v1/models endpoint (e.g. a custom proxy/gateway), the context window
resolution chain has no way to discover the actual context_length for models.
Resolution chain observed:
openai_compatible_profile_context_limit() — only has a hardcoded entry for DeepSeek V4; returns None for other models
GET {api_base}/models — returns 404 on providers that don't support it
CONTEXT_LIMIT_CACHE — empty (nothing to populate from)
Falls back to DEFAULT_CONTEXT_LIMIT = 200,000
This means models with larger context windows (e.g. mimo-v2.5-pro which may support 128k+) are incorrectly limited, and models with smaller
windows waste budget on requests that will fail.
Steps to reproduce:
Configure an OpenAI-compatible provider pointing to a gateway without /v1/models (e.g. opengateway.gitlawb.com/v1)
Use a model like mimo-v2.5-pro
context_limit_for_model() returns None, resolved as 200k
Suggested improvements:
Allow users to set per-model context limits via config (e.g. context_limits map in provider config)
Support a context_window field in NamedProviderConfig model entries
Fall back to probing (send a request and detect context-limit errors) rather than assuming 200k
This is now supported via per-model config overrides. In a named provider profile (~/.jcode/config.toml) you can set a per-model context_window (aliases: context_limit, context-window, context-length):
[providers.my-gateway]
type = "openai-compatible"api_base = "https://opengateway.example.com/v1"
[[providers.my-gateway.models]]
id = "mimo-v2.5-pro"context_window = 131072
Code path:
NamedProviderModelConfig.context_window is defined in crates/jcode-config-types/src/lib.rs (with the aliases above).
It's collected into static_context_limits when the provider is built (crates/jcode-base/src/provider/openrouter.rs, ~L1121).
OpenRouterProvider::context_window() (crates/jcode-base/src/provider/openrouter_provider_impl.rs, ~L1028) consults self.static_context_limits for the active model before falling back to the live /models catalog or DEFAULT_CONTEXT_LIMIT (200k).
So a gateway without /v1/models can now have correct per-model windows without probing. The probing-fallback idea from the issue is a separate, optional enhancement.
If a configured context_window isn't being honored for your gateway model on a current build, please reopen with your (redacted) profile and jcode --version.
Activity
fix: populate global context-limit cache from named provider model co…
feat: support provider-level context_window as fallback for all models (
fix: populate context-limit cache from config on initial load (1jehua…
1jehuang commentedon May 31, 2026
This is now supported via per-model config overrides. In a named provider profile (
~/.jcode/config.toml) you can set a per-modelcontext_window(aliases:context_limit,context-window,context-length):Code path:
NamedProviderModelConfig.context_windowis defined incrates/jcode-config-types/src/lib.rs(with the aliases above).static_context_limitswhen the provider is built (crates/jcode-base/src/provider/openrouter.rs, ~L1121).OpenRouterProvider::context_window()(crates/jcode-base/src/provider/openrouter_provider_impl.rs, ~L1028) consultsself.static_context_limitsfor the active model before falling back to the live/modelscatalog orDEFAULT_CONTEXT_LIMIT(200k).So a gateway without
/v1/modelscan now have correct per-model windows without probing. The probing-fallback idea from the issue is a separate, optional enhancement.If a configured
context_windowisn't being honored for your gateway model on a current build, please reopen with your (redacted) profile andjcode --version.fix: populate global context-limit cache from named provider model co…
feat: support provider-level context_window as fallback for all models (
fix: populate context-limit cache from config on initial load (1jehua…