When I add a local model to openclaw through the openclaw config or openclaw onboard for some reason it defaults to 16000 tokens. When i talk to the bot it does count the tokens then almost immediately starts compacting. If I go into openclaw.json and change the context window to 262144 like it is set in LM Studio, it stops counting tokens in /status so I have to guess how many tokens I have used. I don't understand why it works when it is set to the default 16000 but doesn't count tokens once I set it to the proper value.
#Token counting not working.
1 messages · Page 1 of 1 (latest)
This is probably two separate things:
-
Why it defaults to 16k
- If you added the model through the generic custom/OpenAI-compatible path, OpenClaw uses a conservative fallback context window instead of LM Studio’s real one.
- So
16000is usually not “LM Studio says 16k”, it is “OpenClaw couldn’t reliably infer the real limit on that path”.
-
Why
/statusstops showing token usage at 262144/statustoken counting depends on usage metadata returned by the backend (or transcript fallback).- A lot of local OpenAI-compatible backends do not return reliable usage counters, so OpenClaw can run the model fine but still show token usage as unknown.
-
Why it compacts almost immediately at 16k
- 16k is just too small for OpenClaw’s normal agent overhead, tools, system prompt, etc.
- So with that tiny effective window, auto-compaction kicks in very fast.
A few practical notes:
- If you’re using LM Studio, prefer the built-in
lmstudioprovider over a generic custom provider.
- If you stay on the custom-provider path, setting the real
contextWindowmanually is the right move, but/statusmay still be inaccurate if the backend doesn’t emit usage.
Please paste these so I can tell you if this is expected behavior or a version-specific bug:
openclaw --version
openclaw status --all
Also, if you can, paste the model block from openclaw.json and say whether you configured it as:
lmstudio/...- or a generic custom/OpenAI-compatible provider
Docs:
Ok I am an idiot. I didn't realize there was a LM Studio provider choice let me try actually setting it up proper
Thank you that fixed it!
Glad that helped! 🎉
If this fixed it, please right-click the solution message → Apps → ✅ Mark Solution.
That helps Answer Overflow index it for the next person who hits the same weird token-counting issue.
If the local-model /status counters get weird again, drop the version + model block here and I can take another look.