kilocode icon indicating copy to clipboard operation
kilocode copied to clipboard

GLM-4.6 context window inconsistent.

Open AngDrew opened this issue 1 year ago • 25 comments

Plugin Type

VSCode Extension

App Version

4.99.2

Description

the context window is very limited 72k sometimes 64k the model supports up to 200k tried on opencode works fine

also in kilo tried to use openai compatible version of z.ai but still stuck at certain context around 65k+ but sometimes the bug are vanished.. i don't understand, and need someone to reproduce similar bug..

try on windows and mac. the kilo code on mac is more unstable compared to in my windows laptop..

Image

Reproduction steps

  1. use kilo code
  2. select provider: Z.AI Coding Plan
  3. select model: GLM-4.6
  4. chat, fill up context window

Provider

Z.AI

Model

GLM-4.6

System Information

mac mini & Windows 11 CPU: m2 & i7 8gb ram & 40gb ram

AngDrew avatar Oct 04 '25 05:10 AngDrew

I encountered a similar problem. "kilo said" showed a large piece of raw HTML, and finally reported the error "kilocode is having trouble..."

nokaka avatar Oct 06 '25 09:10 nokaka

i am finding a work around for this.. some people on discord said setting context to 400k solved the issue, but for me it's causes new issue.

what i do now? i set custom endpoint with openai compatible, then set coding plan url my current setting that works:

https://api.z.ai/api/coding/paas/v4 glm-4.6

Image

AngDrew avatar Oct 07 '25 05:10 AngDrew

make sure set max output token 128k and context size 200k this helps me so far.. no issue.. (not yet) maybe my work aren't as heavy as few days ago.

AngDrew avatar Oct 07 '25 05:10 AngDrew

I think there is something wrong here. The probability of failure when editing the file is obviously much higher than other models.

nokaka avatar Oct 07 '25 05:10 nokaka

make sure set max output token 128k and context size 200k this helps me so far.. no issue.. (not yet) maybe my work aren't as heavy as few days ago.

This can greatly reduce the probability of failure.

nokaka avatar Oct 08 '25 04:10 nokaka

I have the same problem

eduardosilvaleroy-hash avatar Oct 15 '25 02:10 eduardosilvaleroy-hash

The issue appears to have been resolved in v4.106.0.

nokaka avatar Oct 17 '25 15:10 nokaka

Still have the same issue. It gets stuck at 104.6k, and I can't change it.

eduardosilvaleroy-hash avatar Oct 25 '25 11:10 eduardosilvaleroy-hash

Still have the same issue. It gets stuck at 104.6k, and I can't change it.

Yes, this annoying problem has appeared again.

nokaka avatar Oct 25 '25 11:10 nokaka

Any workaround yet ?

0Shard avatar Oct 25 '25 12:10 0Shard

https://github.com/RooCodeInc/Roo-Code/issues/8833

nokaka avatar Oct 26 '25 13:10 nokaka

i don't think that is it. In the ui if you hover over it it says it reserves 40.0k tokens for output regardless if it is actually 100k. i found that using the method of @AngDrew works still

0Shard avatar Oct 26 '25 20:10 0Shard

i don't think that is it. In the ui if you hover over it it says it reserves 40.0k tokens for output regardless if it is actually 100k. i found that using the method of @AngDrew works still我觉得不是这样。在用户界面上,如果你把鼠标悬停在上面,它会显示预留了 4 万个代币用于输出,不管实际是不是 10 万个。我发现使用 的方法仍然有效。

204.8k is written in the official documentation. The real problem is that the context window is limited to 128k.

Image

nokaka avatar Oct 27 '25 00:10 nokaka

i don't think that is it. In the ui if you hover over it it says it reserves 40.0k tokens for output regardless if it is actually 100k. i found that using the method of @AngDrew works still

i posted workaround in the discord check it out

AngDrew avatar Oct 27 '25 06:10 AngDrew

i don't think that is it. In the ui if you hover over it it says it reserves 40.0k tokens for output regardless if it is actually 100k. i found that using the method of @AngDrew works still

https://discord.com/channels/1346756824233148527/1432188990596841532

AngDrew avatar Oct 27 '25 06:10 AngDrew

That link is broken, it leads to a blank page on Discord. Can you post the workaround here?

eduardosilvaleroy-hash avatar Oct 28 '25 11:10 eduardosilvaleroy-hash

That link is broken, it leads to a blank page on Discord. Can you post the workaround here?

sure.

you must set up with this:

  • use openai compatible
  • endpoint: https://api.z.ai/api/coding/paas/v4
  • GLM 4.6
  • un-check enable reasoning effort (they claim this is the cause of error but not only this!)
  • max output token 32k (you can leave it -1)
  • context window 128k (i know. but trust me this is the only config works. for best compatibility i found out that using 110k window works best. 128k ok but sometimes it fails, if you found another issue reduce it further to 100k/110k/120k/etc.. try what fits the best for you)
  • ETC:
    • use prompt caching (improve speed), uncheck image support, use stream, include max outputs tokens
  • save
  • go to context tab on the left
  • scroll to bottom, auto compact / condensing. enable it for all profile set the value around 75% or so..

with this config you can use kilo in my screenshot i ran it smoothly and it calls 500 tool calling without fail.. enjoy!

AngDrew avatar Oct 29 '25 04:10 AngDrew

https://github.com/Kilo-Org/kilocode/issues/3301 The problem is very, very clear: the context length is stuck at 128k (This model supports 200k). However, many days have passed and it still hasn't been fixed. @chrarnoldus

nokaka avatar Oct 29 '25 04:10 nokaka

from https://github.com/RooCodeInc/Roo-Code/issues/8833

Thanks for the detailed investigation and screenshots. This isn’t an actual hard cap on context length — the issue occurs because once the session reaches around ~128k tokens, the model becomes unable to reliably execute tool calls (like editFile or readFile). In other words, it’s not that the context limit is enforced at 128k, but that the model’s ability to use tools degrades sharply beyond that point.

We’re working on some architectural changes that should help mitigate this longer-term, but there’s no short-term fix. For now, the best workaround is to keep context condensation or truncation thresholds below ~60% to avoid hitting this behavior.

nokaka avatar Oct 30 '25 00:10 nokaka

Why doesn't this issue occur in Claude Code or other agent tools? Is it because ANTHROPIC uses BASE_URL=https://open.bigmodel.cn/api/anthropic, while other tools use BASE_URL=https://open.bigmodel.cn/api/coding/paas/v4? Do these two addresses have different specific capabilities?

sth4me avatar Oct 31 '25 09:10 sth4me