[Bug] Cross-provider catalog limit contradictions cause silent truncation and premature compaction #1724
Replies: 1 comment
|
Investigated this report and produced a candidate fix, validated on a fork of this repository. Root cause, fix and validation from the working notes:
Diff: awhite0030/prime-agent@main...fix-cross-provider-limits-15907095065189478282 The change passes |
Uh oh!
There was an error while loading. Please reload this page.
Description
The generated catalog (
packages/ai/src/models.generated.ts, currentmain) contains entries where the same model is listed with drastically differentcontextWindow/maxTokensvalues across providers, and the outliers silently change runtime behavior. Because these limits feed directly into request construction and compaction, users on the outlier provider get truncated output or far-too-early compaction with no warning.Verified examples (all on current
main):1.
moonshotai/kimi-k2.5on openrouter:maxTokens: 4096contextWindow: 262144,maxTokens: 4096contextWindow: 262144,maxTokens: 262144packages/ai/src/providers/simple-options.ts:6derives the default output budget asMath.min(model.maxTokens, 32000), so OpenRouter users of kimi-k2.5 get responses capped at 4,096 output tokens - 16x below what the same model produces via Moonshot direct.2.
openai/gpt-5.6on prime-inference:contextWindow: 128000,maxTokens: 8192gpt-5.6-luna/sol/terraand pro variants, lines 17310+): 1050000 / 128000Two effects for Prime Inference subscribers picking gpt-5.6: compaction triggers at ~120k tokens instead of ~1M (
shouldCompact,packages/coding-agent/src/core/compaction/compaction.ts:206:contextTokens > contextWindow - reserveTokens), and output is capped at 8192 tokens. The row looks like a stale early-listing snapshot that was never refreshed while its siblings were.3.
claude-sonnet-4outliers (softer - providers may cap deliberately):maxTokens: 8192; github-copilot:16000; vs 64000 on opencode/openrouter/prime-inference (Anthropic's spec).Steps to reproduce
Or statically: compare the cited entries in
models.generated.ts.Expected behavior
Per-model limits should be consistent across providers unless a transport genuinely caps lower, and any deliberate deviation should be visible/commented. The generator (
packages/ai/scripts/generate-models.ts) should cross-check each model's values against the canonical listing (the upstream vendor's own entry) and flag or override extreme outliers instead of copying them verbatim.Actual behavior
Outlier rows are copied through silently; runtime clamps and compaction math then degrade those providers' sessions invisibly.
Prime Agent version
main @ e319a66
Operating system
Any (generated data; platform-independent)
Additional context
The scheduled daily catalog refresh (#1633) will reproduce this class continuously if upstream sources carry stale rows, so the durable fix is an outlier check in the generator (e.g., flag >4x deviation from the cross-provider median per model) rather than a one-off data correction. Related but distinct: #1677 (impossible
maxTokens > contextWindowpairs).First filed as issue #1718; it was auto-closed by the contribution vouch gate within seconds, so I am re-filing it here per CONTRIBUTING.md's discussion-first process.
All reactions