Skip to content

BYOK model catalogs return limits: null, so clients default to 128K context / 4096 output #238

Open

Description

@khaosoi

TL;DR https://llm.int.exe.xyz/models.json returns "limits": null for every BYOK
provider, even when the upstream model card it proxies plainly reports the context window
and max output tokens. Clients that trust limits (pi's pi-exe-dev extension among them)
silently invent defaults, so a 1M-context model is displayed and budgeted as 128K.

Reproduce

curl -s https://llm.int.exe.xyz/models.json \
  | jq '.models[] | select(.provider == "deepseek" or .provider == "kimi-coding")
        | {id, limits, upstream_ctx: (.upstream.context_window // .upstream.context_length),
           upstream_max_out: .upstream.max_output_tokens}'

Observed (abridged):

{"id":"deepseek/deepseek-flash",     "limits":null, "upstream_ctx":1048576, "upstream_max_out":393216}
{"id":"deepseek/deepseek-v4-pro",    "limits":null, "upstream_ctx":1048576, "upstream_max_out":393216}
{"id":"kimi-coding/k3",              "limits":null, "upstream_ctx":1048576, "upstream_max_out":null}
{"id":"kimi-coding/k3-256k",         "limits":null, "upstream_ctx":262144,  "upstream_max_out":null}
{"id":"kimi-coding/k3.1-pro",        "limits":null, "upstream_ctx":1048576, "upstream_max_out":null}
{"id":"kimi-coding/k3.1-pro-highspeed","limits":null,"upstream_ctx":1048576,"upstream_max_out":null}
{"id":"kimi-coding/kimi-for-coding", "limits":null, "upstream_ctx":1048576, "upstream_max_out":null}
{"id":"kimi-coding/kimi-for-coding-highspeed","limits":null,"upstream_ctx":262144,"upstream_max_out":null}

For contrast, managed providers are normalised correctly:

{"id":"fireworks/deepseek-v4p1-flash", "limits":{"context_window":1048576,"max_output_tokens":131072}}

Impact

pi (~/.pi/agent/extensions/exe-dev/integration_catalog.ts:369-370) reads only
model.limits, then falls back to 128000 / 4096:

contextWindow: model.limits?.context_window ?? fallback?.contextWindow ?? 128000,
maxTokens:     model.limits?.max_output_tokens ?? fallback?.maxTokens ?? 4096,

So pi --list-models reports:

exe-dev-deepseek   deepseek-flash@llm      128K   4.1K      (actual 1.0M / 393.2K)
exe-dev-kimi-coding k3@llm                 128K   4.1K      (actual 1.0M / 131.1K)
exe-dev-kimi-coding k3-256k@llm            128K   4.1K      (actual 262.1K / 131.1K)

This is not cosmetic: the context window drives the visible context meter, when automatic
compaction kicks in, and the per-request output cap. A 1M-token model mislabelled as 128K
compacts around 8x too early, and shows a permanently wrong usage bar.

Root cause

The gateway normalises upstream /models responses into a fixed shape with limits
(context_window / max_output_tokens), and it does so successfully for providers whose
upstream already uses those field names (Fireworks, OpenAI, Anthropic shapes). BYOK
providers use different names and are passed through without normalisation:

  • DeepSeek: context_window, max_output_tokens (both present, so fully recoverable)
  • Kimi Coding: context_length plus limit.context; no output limit advertised

The data is present in the same payload under upstream, just not copied into limits.
On this VM, 8 conversational models are affected; 4 more non-chat entries (transcription,
embeddings, reranker) also carry limits: null, which is harmless.

Suggested fixes (either is sufficient)

  1. Gateway (preferred). Populate limits for BYOK entries by reading the upstream
    card, accepting both shapes:
    context_window = upstream.context_window ?? upstream.context_length ?? upstream.limit.context
    max_output_tokens = upstream.max_output_tokens ?? upstream.limit.max_output_tokens
    Leave null only when the upstream genuinely does not advertise a value.

  2. Client. In pi-exe-dev, extend the fallback chain to the already-parsed upstream
    card before defaulting: model.limits?.context_window ?? model.upstream?.context_window ?? model.upstream?.context_length ?? ... ?? 128000. This also protects other clients
    reading limits.

Related: #233 (add peer/custom LLM integrations to roadmap) — a fix there could
subsume this.

Either way, a short note in the integration docs ("BYOK catalogs may not advertise
limits; set client-side overrides") would save the next person the 128K mystery.

Environment

  • VM: boxing-tuba (BYOK/API-key providers configured: deepseek, kimi-coding)
  • VM integration: exe-dev-llm-integration.json (useExeIntegration: true), keyless gateway
  • pi 1.5.0 with the exe.dev integration extension (~/.pi/agent/extensions/exe-dev)
  • Gateway catalog: https://llm.int.exe.xyz/models.json (schema_version 1, 71 models)

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