From 4084917cab9c8f96b93fc0f4139b52c996c6261e Mon Sep 17 00:00:00 2001 From: Concedo <39025047+LostRuins@users.noreply.github.com> Date: Sun, 12 Apr 2026 15:29:22 +0800 Subject: [PATCH] fixed token counting limit (+1 squashed commits) Squashed commits: [314528eb2] fixed token counting limit, set to max supported ctx of 256k --- koboldcpp.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/koboldcpp.py b/koboldcpp.py index d415bd706..7c341b201 100755 --- a/koboldcpp.py +++ b/koboldcpp.py @@ -2828,7 +2828,11 @@ def music_generate_audio(genparams): def tokenize_ids(countprompt,tcaddspecial): rawcountdata = handle.token_count(countprompt.encode("UTF-8"),tcaddspecial) - countlimit = rawcountdata.count if (rawcountdata.count>=0 and rawcountdata.count<50000) else 0 + count = rawcountdata.count + hardlimit = (2**31) - 1 + countlimit = count if (count>=0 and count<=hardlimit) else 0 + if count > hardlimit: + utfprint("Warning: TokenCount exceeds max limit.") # the above protects the server in case the count limit got corrupted countdata = [rawcountdata.ids[i] for i in range(countlimit)] return countdata