#[OpenClaw] Local Model works in TUI/WebUI, but fails ONLY via WhatsApp with "Context window too smal

1 messages · Page 1 of 1 (latest)

steady trenchBOT
#

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

polar whaleBOT
#

That error is coming from the embedded reply agent (the thing that handles inbound chat channels like WhatsApp). It has a hard minimum context window check (min=16000), and it decides your model’s context window from OpenClaw’s model metadata, not from what KoboldCpp is configured to allow.

So if it logs:

blocked model (context window too small) … ctx=4096

it basically means: “for the provider/model I resolved, the model definition I’m looking at says contextWindow: 4096”.

There isn’t a special “WhatsApp-only 4096 limit” cache — what’s usually happening is one of these:

1) WhatsApp is routed to a different agent than WebUI/TUI

WebChat can be attached to a selected agent; WhatsApp routing is controlled by bindings and defaults (see docs: https://docs.openclaw.ai/channels/channel-routing). If WhatsApp lands on agentId=main but you tweaked a different agent’s models.json, you’ll see exactly this kind of mismatch.

2) You have multiple “custom-*” providers (localhost vs 127.0.0.1)

OpenClaw auto-generates custom provider IDs from the base URL host/port (so localhost:5001 and 127.0.0.1:5001 become different providers). Your log shows it’s using:

  • custom-127-0-0-1-5001/<modelId>
#

If you set contextWindow under custom-localhost-5001 (or edited the wrong place), WhatsApp will still see 4096.

3) agents.defaults.contextTokens is capping you

contextTokens is a cap (it can force the effective window down). If it’s set to 4096 anywhere in the config the gateway is actually running with, the embedded agent will report 4096 even if the model supports more.


The most reliable fix

Put an explicit model definition in your main config under models.providers.<that exact provider>.models[] (this overrides the discovered/registry metadata):

Docs: https://docs.openclaw.ai/gateway/local-models and https://docs.openclaw.ai/gateway/configuration-reference

Example shape (adjust api to whatever your KoboldCpp endpoint supports):

{
#
  models: {
    mode: "merge",
    providers: {
      "custom-127-0-0-1-5001": {
        baseUrl: "http://127.0.0.1:5001/v1",
        apiKey: "local", // any non-empty string if your server doesn’t enforce auth
        api: "openai-completions",
        models: [
          {
            id: "Qwen2.5-32B-Q3_K_M",
            contextWindow: 20480,
            maxTokens: 4096
          }
        ]
      }