fix: handled unknown model limits as null to avoid artificial token caps

- Replaced unknown model contextWindow/maxTokens sentinels with nullable values across types and catalog data.
- Mapped request token calculations to treat null maxTokens as unlimited output caps.
- Updated remote compaction and context checks to ignore unknown limits by using Infinity/0 fallbacks.
- Adjusted CLI/model registry flows to skip cap enforcement for null limits and render unknown values as '-'.
This commit is contained in:
can1357
2026-06-13 15:35:40 +02:00
parent 2a7e10cc44
commit f0c6a54f51
43 changed files with 3014 additions and 2798 deletions
+12 -8
View File
@@ -68,8 +68,8 @@ interface ModelJson {
id: string;
selector: string;
name: string;
contextWindow: number;
maxTokens: number;
contextWindow: number | null;
maxTokens: number | null;
reasoning: boolean;
/** Supported thinking efforts when the model thinks, otherwise null. */
thinking: readonly Effort[] | null;
@@ -81,8 +81,8 @@ interface CanonicalJson {
id: string;
selected: string;
variants: number;
contextWindow: number;
maxTokens: number;
contextWindow: number | null;
maxTokens: number | null;
}
interface ModelsJson {
@@ -97,6 +97,10 @@ function writeLine(line = ""): void {
process.stdout.write(`${line}\n`);
}
function formatLimit(n: number | null): string {
return n === null ? "-" : formatNumber(n);
}
function byProviderThenId(left: Model<Api>, right: Model<Api>): number {
const providerCmp = left.provider.localeCompare(right.provider);
if (providerCmp !== 0) return providerCmp;
@@ -229,8 +233,8 @@ function renderProviderModels(
writeLine(`${chalk.bold.cyan(provider)} ${chalk.dim(`(${models.length})`)}`);
const rows = models.map(model => [
model.id,
formatNumber(model.contextWindow),
formatNumber(model.maxTokens),
formatLimit(model.contextWindow),
formatLimit(model.maxTokens),
model.thinking ? getSupportedEfforts(model).join(",") : model.reasoning ? "yes" : "-",
model.input.includes("image") ? "yes" : "no",
]);
@@ -293,8 +297,8 @@ function renderCanonicalModels(modelRegistry: ModelRegistry, pattern: string | u
record.id,
`${model.provider}/${model.id}`,
String(record.variants.length),
formatNumber(model.contextWindow),
formatNumber(model.maxTokens),
formatLimit(model.contextWindow),
formatLimit(model.maxTokens),
]);
for (const line of boxTable(
[