#Context limit exceeded. I've reset our conversation to start fresh - please try again.

1 messages · Page 1 of 1 (latest)

kind heron
#

Context limit exceeded. I've reset our conversation to start fresh - please try again.

To prevent this, increase your compaction buffer by setting agents.defaults.compaction.reserveTokensFloor to 20000 or higher in your config.

civic rockBOT
#

To help others find answers, you can mark your question as solved via Right click solution message -> Apps -> ✅ Mark Solution

old knotBOT
junior axleBOT
#

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 20000 is still too low for a long, tool-heavy session, try 24000 or 32000.

Docs:

kind heron
#

when i apply 9router to openclaw AI, it has forgotten the chat history

junior axleBOT
#

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,
      },
    },
  },
}
kind heron
#

how to comeback to model default

junior axleBOT
#

Use /model, not /new.

Fastest ways back to default:

  • Discord/chat: run /model and 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.

kind heron
#

how to change api key

junior axleBOT
#

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.

kind heron
#

change openai api key

junior axleBOT
#

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_KEY in 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
kind heron
#

change new openai api key

junior axleBOT
#

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