The Kilocode gateway publishes an OpenRouter-shaped catalog in which
`context_length` is the catalog-wide ceiling while `top_provider.context_length`
describes the primary provider that actually serves the request. Discovery read
only the catalog-wide value, so models whose primary provider offers a smaller
window were registered with a context window larger than requests can use.
Prefer the primary-provider window and fall back to the catalog-wide value,
matching the precedence already owned by
`extensions/openrouter/provider-catalog.ts`.
Completion-token handling is left alone on purpose: the live Kilocode catalog
exposes no top-level `max_completion_tokens` or `max_output_tokens`, so the
existing `top_provider` read is already the only available source.