Skip to content

zai, zhipuai: add missing limit.input for GLM-5.x models - #5617

Open
winstern1998-commits wants to merge 1 commit into
anomalyco:devfrom
winstern1998-commits:add-glm5-limit-input
Open

zai, zhipuai: add missing limit.input for GLM-5.x models#5617
winstern1998-commits wants to merge 1 commit into
anomalyco:devfrom
winstern1998-commits:add-glm5-limit-input

Conversation

@winstern1998-commits

Copy link
Copy Markdown

Summary

Adds the missing limit.input for the GLM-5.x family, superseding #3739 (closed as stale) and incorporating the review bot's action items from that PR.

Zhipu does not publish a separate max-input figure; the official docs define the context window as the combined total of input and output tokens (concept-param), so limit.input is derived as context - output — the same convention already used for OpenAI entries in models/ (e.g. gpt-5.5: 1_050_000 = 922_000 + 128_000).

Per-model values (official context/output from docs.bigmodel.cn model pages, cross-checked with docs.z.ai where available):

Model context output input
GLM-5 204_800 131_072 73_728
GLM-5.1 / GLM-5-turbo / GLM-5v-turbo 200_000 131_072 68_928
GLM-5.2 / GLM-5.3 / GLM-5.3-Flash 1_000_000 131_072 868_928

Changes

  • models/zhipuai/glm-5* (7 files): canonical metadata gets limit.input. This is the primary fix — zai and coding-plan entries resolve these via base_model, which is why editing providers/* alone (as zai, zhipuai: add missing limit.input for GLM models #3739 did) never propagated.
  • providers/{zai,zhipuai,zai-coding-plan,zhipuai-coding-plan} (9 files): first-party entries that carry their own [limit] block.
  • Third-party base_model entries (24 files): entries whose own context is smaller than the inherited input get an explicit input (= own context − own output) so they don't end up with input > context after this change. Degenerate entries (output >= context, where the subtraction would go negative) use base_model_omit = ["limit.input"] instead — the same pattern the sync tooling itself emits (baseModelOmit in sync/providers/openrouter.ts).
  • sync.test.ts: the LLM Gateway factoring test now expects base_model_omit: ["limit.input"] since the base model gained limit.input — expected baseModelOmit() behavior, no product change.

ambient/zai-org/GLM-5.1-FP8 intentionally keeps the inherited input (68_928 ≤ context 202_752).

Downstream motivation

opencode's compaction.reserved is silently ignored for models without limit.input because usable() only applies the reserved buffer on the limit.input branch (anomalyco/opencode#38835). With limit.input present in the catalog, compaction.reserved takes effect with no opencode-side change.

Validation

  • bun run validate exits 0
  • bun test: all affected tests pass (8 pre-existing failures unrelated to this change, confirmed via clean-baseline stash on WSL)
  • Full-catalog invariant scan (via generateCatalog): 570 GLM entries across 203 providers, zero input > context violations; all first-party ^glm-5 entries have input; e.g. zai/glm-5.2 resolves to {context: 1000000, input: 868928, output: 131072}

A follow-up PR could extend limit.input to the GLM-4.x family (10 files, same shape).

Zhipu defines the context window as the combined total of input and
output tokens (docs.bigmodel.cn/cn/guide/start/concept-param) and does
not publish a separate max-input figure, so limit.input is derived as
context - output. This follows the existing convention for OpenAI
entries in models/ (e.g. gpt-5.5: 1_050_000 = 922_000 + 128_000).

- models/zhipuai/glm-5*: canonical metadata. This is the primary fix;
  zai / coding-plan entries resolve these via base_model.
- providers/{zai, zhipuai, zai-coding-plan, zhipuai-coding-plan}:
  first-party files that carry their own [limit] block.
- third-party base_model entries with a smaller context: set explicit
  input so they do not inherit input > context after this change.
  Degenerate entries (output >= context) use
  base_model_omit = ["limit.input"] instead, matching the pattern the
  sync tooling itself emits (baseModelOmit in sync/providers/openrouter.ts).
- sync.test.ts: the LLM Gateway factoring test now expects
  base_model_omit: ["limit.input"] since the base model gained
  limit.input (matches baseModelOmit() behavior, no product change).

Downstream effect: opencode's compaction.reserved is silently ignored
for models without limit.input (anomalyco/opencode#38835); with
limit.input present it takes effect with no opencode-side change.

ambient/zai-org/GLM-5.1-FP8 intentionally keeps the inherited
input (68_928 <= context 202_752).
@github-actions

Copy link
Copy Markdown
Contributor

No actionable findings.

@github-actions github-actions Bot added the reviewer: ready Automated review found no actionable items label Aug 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

reviewer: ready Automated review found no actionable items

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant