Skip to content

Cross-provider catalog limit contradictions cause silent truncation and premature compaction (kimi-k2.5/OpenRouter max=4096, prime-inference gpt-5.6 ctx=128000/max=8192) #1718

Description

@aniruddhaadak80

Description

The generated catalog (packages/ai/src/models.generated.ts, current main) contains entries where the same model is listed with drastically different contextWindow / maxTokens values 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.5 on openrouter: maxTokens: 4096

  • openrouter (line ~12835): contextWindow: 262144, maxTokens: 4096
  • moonshotai direct (line ~8046): contextWindow: 262144, maxTokens: 262144
  • huggingface (line ~6898): 262144 / 262144
  • prime-inference (line ~16832): 262144 / 65535
  • opencode (line ~10097): 262144 / 65536

packages/ai/src/providers/simple-options.ts:6 derives the default output budget as Math.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.6 on prime-inference: contextWindow: 128000, maxTokens: 8192

  • prime-inference (line ~17291): 128000 / 8192
  • openai (line ~8851), azure-openai-responses (line ~2839), cloudflare-ai-gateway (line ~3670): 1050000 / 128000
  • prime-inference's own sibling gpt-5.6 family entries (gpt-5.6-luna/sol/terra and pro variants, lines 17310+): 1050000 / 128000

Two 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-4 outliers (softer - providers may cap deliberately):

  • vercel-ai-gateway: maxTokens: 8192; github-copilot: 16000; vs 64000 on opencode/openrouter/prime-inference (Anthropic's spec).

Steps to reproduce

1. Select MoonshotAI: Kimi K2.5 via OpenRouter (or gpt-5.6 via Prime Inference).
2. Run a long coding task.
3. Observe responses ending at ~4k output tokens (kimi-k2.5/OpenRouter), or compaction starting at ~120k context with 8k-token outputs (gpt-5.6/Prime Inference).

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 > contextWindow pairs).

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions