zai, zhipuai: add missing limit.input for GLM-5.x models - #5617
Open
winstern1998-commits wants to merge 1 commit into
Open
zai, zhipuai: add missing limit.input for GLM-5.x models#5617winstern1998-commits wants to merge 1 commit into
winstern1998-commits wants to merge 1 commit into
Conversation
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).
Contributor
|
No actionable findings. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds the missing
limit.inputfor 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.inputis derived ascontext - output— the same convention already used for OpenAI entries inmodels/(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):
Changes
models/zhipuai/glm-5*(7 files): canonical metadata getslimit.input. This is the primary fix —zaiand coding-plan entries resolve these viabase_model, which is why editingproviders/*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.base_modelentries (24 files): entries whose owncontextis smaller than the inheritedinputget an explicitinput(= own context − own output) so they don't end up withinput > contextafter this change. Degenerate entries (output >= context, where the subtraction would go negative) usebase_model_omit = ["limit.input"]instead — the same pattern the sync tooling itself emits (baseModelOmitinsync/providers/openrouter.ts).sync.test.ts: the LLM Gateway factoring test now expectsbase_model_omit: ["limit.input"]since the base model gainedlimit.input— expectedbaseModelOmit()behavior, no product change.ambient/zai-org/GLM-5.1-FP8intentionally keeps the inherited input (68_928 ≤ context 202_752).Downstream motivation
opencode's
compaction.reservedis silently ignored for models withoutlimit.inputbecauseusable()only applies the reserved buffer on thelimit.inputbranch (anomalyco/opencode#38835). Withlimit.inputpresent in the catalog,compaction.reservedtakes effect with no opencode-side change.Validation
bun run validateexits 0bun test: all affected tests pass (8 pre-existing failures unrelated to this change, confirmed via clean-baseline stash on WSL)generateCatalog): 570 GLM entries across 203 providers, zeroinput > contextviolations; all first-party^glm-5entries haveinput; e.g.zai/glm-5.2resolves to{context: 1000000, input: 868928, output: 131072}A follow-up PR could extend
limit.inputto the GLM-4.x family (10 files, same shape).