resolveAppContextWindow function
Resolves the app's context window for a connection (gh-1077 fix contract 2 / AC3): the endpoint-reported or picker-stored value wins, else the provider-catalog window, else the pinned shared fallback (fallbackContextWindow, 200000 — pi's smallest modern per-model value; E1: this is the documented answer for unknown/custom providers with no catalog entry).
A stored value equal to the fallback constant means "nothing was known" (both the pickers and the persisted configs use the constant as their default), so it does not suppress the catalog lookup.
Implementation
int resolveAppContextWindow({String? providerKind, int? storedWindow}) {
if (storedWindow != null &&
storedWindow > 0 &&
storedWindow != fallbackContextWindow) {
return storedWindow;
}
final catalog = providerKind == null
? null
: catalogProvider(providerKind)?.contextWindow;
return catalog ?? fallbackContextWindow;
}