#397·inkos

Make the context-window guard configurable for custom/unknown providers (hardcoded 128k fallback blocks 200k+ context endpoints)

Author: yaliklintyCreated Sep 20, 2026Updated Sep 20, 2026

llm/provider.js falls back to a hardcoded window for models absent from the registry: contextWindow: modelCard?.contextWindowTokens ?? 128_000. Custom OpenAI-compatible services are never in the registry, so the pre-send guard always assumes 128k and rejects with InkOS context window guard: estimated input N tokens + reserved output M exceeds context window 128000 — even when the endpoint's model handles far more (measured needle-in-haystack recall at ~435k tokens through such an endpoint).

Accept a per-service contextWindowTokens in the service config and/or an env override (INKOS_MODEL_CONTEXT_WINDOW) as the fallback instead of the literal. Verified one-line variant locally: modelCard?.contextWindowTokens || Number(process.env.INKOS_MODEL_CONTEXT_WINDOW) || 128_000.