#Context limit exceeded. I've reset our conversation to start fresh - please try again.
1 messages · Page 1 of 1 (latest)
Yep, that’s the right setting.
First, paste openclaw --version, since version mismatch causes a lot of weird behavior.
On current builds, you can set it with:
openclaw config set agents.defaults.compaction.reserveTokensFloor 20000 --strict-json
Or in ~/.openclaw/openclaw.json:
{
agents: {
defaults: {
compaction: {
reserveTokensFloor: 20000,
},
},
},
}
A few notes:
- Config is JSON5.
- Config usually hot-reloads, but if it still keeps resetting, restart the gateway.
- If
20000is still too low for a long, tool-heavy session, try24000or32000.
Docs:
- https://docs.openclaw.ai/gateway/configuration-reference#agentsdefaultscompaction
- https://docs.openclaw.ai/concepts/compaction
If it still happens after that, paste:
openclaw --version- your
agents.defaults.compactionblock - the exact error/log line
when i apply 9router to openclaw AI, it has forgotten the chat history
If you mean OpenRouter, it usually did not erase the history by itself.
In this thread, OpenClaw says it hit a context limit and reset the session, so it looks like the chat was forgotten.
Two important gotchas:
/new <model>starts a fresh session/model <model>keeps the current session and just switches models
So if you changed to OpenRouter with /new, that would explain it immediately.
What I’d check first:
openclaw --version
openclaw status
openclaw config set agents.defaults.compaction.reserveTokensFloor 24000 --strict-json
If you prefer editing config directly, set:
{
agents: {
defaults: {
compaction: {
reserveTokensFloor: 24000,
},
},
},
}
Also, the old transcript may still exist on the gateway, even if the live session reset.
Please paste:
openclaw --version- how you switched to OpenRouter (
/new,/model, Control UI, config edit, etc.) openclaw status
Docs:
- https://docs.openclaw.ai/help/faq
- https://docs.openclaw.ai/concepts/session
- https://docs.openclaw.ai/concepts/compaction
- https://docs.openclaw.ai/tools/slash-commands
If you paste those 3 bits, I can tell you which one it is pretty quickly.
how to comeback to model default
Use /model, not /new.
Fastest ways back to default:
- Discord/chat: run
/modeland pick the default model again - If you know the default model name,
/model <that-model>also resets the session override back to default behavior - Control UI: choose inherit in the model picker/session override
Important: /new <model> starts a fresh session, so that’s the one that makes it feel like history disappeared.
If you want to keep the same chat history and just switch back, use /model.
Docs:
If you want, paste what /model shows and I’ll tell you exactly which option to pick.
how to change api key
Easiest way:
openclaw configure --section model
That lets you replace the model provider key interactively.
If it’s a web/search provider key instead, use:
openclaw configure --section web
If your key is coming from an env var instead of the wizard, update that env var where the Gateway actually runs, then restart:
openclaw gateway restart
A few notes:
- Model auth/API keys are stored per-agent, usually in
~/.openclaw/agents/<agentId>/agent/auth-profiles.json - I’d use the wizard instead of editing that file by hand
- For plugin/provider login flows, OpenClaw also supports:
openclaw models auth login --provider <id>
Docs:
If you tell me which provider you want to change the key for, I can give the exact command.
change openai api key
For OpenAI specifically, easiest path is:
openclaw configure --section model
Then replace the OpenAI key there.
If you’re using an env var instead, update OPENAI_API_KEY where the Gateway runs, then restart:
openclaw gateway restart
openclaw models status
Common setups:
- Stored in OpenClaw auth/config → use
openclaw configure --section model - Stored as env var → change
OPENAI_API_KEYin the service environment or~/.openclaw/.env, then restart
OpenClaw also supports the OpenAI provider config path models.providers.openai.apiKey, but I’d use the wizard unless you really want to edit config manually.
Docs:
If you want, I can give you the exact steps for your setup:
- Docker
- local npm install
- system service / daemon
change new openai api key
If you just want to replace the OpenAI key with a new one, do this:
openclaw configure --section model
openclaw gateway restart
openclaw models status
That’s the cleanest path. In the wizard, pick OpenAI and paste the new API key.
If you use env vars instead, replace OPENAI_API_KEY in your service env or ~/.openclaw/.env, then run:
openclaw gateway restart
openclaw models status