kilocode icon indicating copy to clipboard operation
kilocode copied to clipboard

Z.AI model GLM-4.5 context token issue

Open maksudixsanov opened this issue 1 year ago • 11 comments

Description

Hello! I'm using Kilo CODE and the Z.AI model GLM-4.5 via the OpenAI Compitable with Z.AI API. The agent context window shows 128,000 contexts, but when the 65,000 threshold is reached, the agent starts throwing errors and glitches. I thought this was a provider and Z.AI error, so I tried the paid Claude-Sonnet-4 version with 1 million contexts from KILO CODE. And yes, there are no context limits even when reaching over 600,000. The question is, what is the reason for this context behavior for a third-party provider?

maksudixsanov avatar Sep 19 '25 09:09 maksudixsanov

The question is, what is the reason for this context behavior for a third-party provider?

I don't know, does GLM 4.5 have this behavior when used through Kilo Code provider?

You can also try the Z.ai provider (although I doubt it will make a difference).

What sort of errors do you get? If the error mentions the "apply_diff" tool, try disabling "Editing files through diffs". If the error mentions the "edit_file" tool, try disabling Morph fast apply (experimental feature).

chrarnoldus avatar Sep 19 '25 13:09 chrarnoldus

i can confirm that i have the same error when reaching the 33k context it just start failing permanently to use any tools esspecially filesystem tool or mcp UNTIL i condense the context down to anything less than 33k but later whenever i reach 33k agian it starts to fail to write anything !! its completelty unusuable now ! so annoying P.S. i am using z.ai provider with api.z.ai/api/coding/paas/v4 endpoint

ramires666 avatar Sep 23 '25 10:09 ramires666

I'm using the GLM Coding Lite subscription with the glm-4.5 model in cline, kilocode, and roocode via OpenAI Compatible in VS Code as an agent. In all plugins, the context window shows 128,000 tokens, but when the context window reaches 65,000+ tokens, the model starts to make errors, enters a cyclical loop, and can't perform actions such as reading a file or editing.

maksudixsanov avatar Sep 23 '25 14:09 maksudixsanov

I've contacted z.ai support and am waiting for a response.

maksudixsanov avatar Sep 23 '25 14:09 maksudixsanov

Hi, this is Z.ai Official, can you send you User ID with the issue to [email protected]. Thanks!

zixuanl4 avatar Sep 24 '25 01:09 zixuanl4

Hi, this is Z.ai Official, can you send you User ID with the issue to [email protected]. Thanks!

Hello. I sent what you asked for.

maksudixsanov avatar Sep 24 '25 05:09 maksudixsanov

aslo sent email waiting for answer now will update upon

ramires666 avatar Sep 24 '25 05:09 ramires666

just for a test i changed API provider to OpenAi Compatibleand got same 66k limit after which it start to fail using tools constantly ! So it is either 33k limit with original API provider z.ai or 66k limit with OpenAI compatible anyway it is completely unusable with such limits

ramires666 avatar Sep 25 '25 07:09 ramires666

the very similar for qwen cli

akpatternica avatar Sep 25 '25 07:09 akpatternica

The maximum output of glm-4.5 is 128k, so this is the largest token we can configure. We will see if we can modify the max_token in kilo code to 128 in the future.

maksudixsanov avatar Sep 25 '25 09:09 maksudixsanov

I customized the modes, created several new modes entirely, and updated the orchestrator. In the context settings, I enabled "Automatically run intelligent context compression" and set the "compression threshold" to 49%. The agent has been running for several hours now and there are no issues so far. The tools are not throwing any errors.

maksudixsanov avatar Sep 25 '25 12:09 maksudixsanov