A laptop computer sitting on top of a wooden desk

Running OpenClaw with default config will hit two problems after a while: quota burns too fast and long sessions crash from timeouts. This post logs 8 parameters I actually tuned, and the reasoning behind each.

Architecture First

Here’s my setup:

  • GitHub Copilot Pro+: $19/month, 1500 premium requests/month quota
  • Claude Opus 4.6: accessed via Copilot’s model routing, model ID github-copilot/claude-opus-4.6
  • OpenClaw: handles Telegram interactions, Skill calls, scheduled tasks

Quota math: each AI assistant reply = 1 premium request (including replies after tool calls). 1500 sounds like plenty, but without optimization it dries up fast.

8 Standard Optimizations

1. Keep Only Copilot, Clear All Fallbacks

Problem: Default config has multiple model providers set as fallbacks. When the primary times out, it tries each fallback in sequence, and each attempt burns quota.

Optimization:

{
  "agents": {
    "defaults": {
      "model": {
        "primary": "github-copilot/claude-opus-4.6",
        "fallbacks": []
      }
    }
  }
}

With empty fallbacks, failures fail fast instead of triggering 2-3 wasted retries. Saves ~50 requests/month.


2. Drop Timeout from 600s to 300s

Problem: Default 600-second timeout means a stuck request waits 10 minutes to error out, and all subsequent messages queue up behind it.

Optimization:

{
  "agents": {
    "defaults": {
      "timeoutSeconds": 300
    }
  }
}

300 seconds is more than enough for normal tasks, gets you faster error detection, and cuts down retries from timeout cascades.


3. Session Compaction: Safeguard Mode

Problem: Long-running ops sessions (like debugging a server problem with dozens of SSH back-and-forths) balloon context until the API rejects it, then triggers retries.

Optimization:

{
  "compaction": {
    "mode": "safeguard",
    "reserveTokensFloor": 120000
  }
}

safeguard mode automatically compresses history when context nears the model limit, keeping key content while preventing API rejection from oversized context. reserveTokensFloor is your output token buffer.


4. Context Pruning: 30-Minute TTL

This is the single most impactful optimization.

Problem: Tool call outputs (SSH results, file contents, API responses) are usually huge, but after 30 minutes they’re basically useless references yet still eat up context space.

Optimization:

{
  "contextPruning": {
    "mode": "cache-ttl",
    "ttl": "30m",
    "keepLastAssistants": 5,
    "minPrunableToolChars": 30000,
    "softTrim": {
      "maxChars": 3000,
      "headChars": 1000,
      "tailChars": 1000
    },
    "hardClear": {
      "enabled": true,
      "placeholder": "[old tool output cleared]"
    }
  }
}

Key parameters:

  • ttl: "30m": tool outputs older than 30 minutes become pruning candidates
  • keepLastAssistants: 5: preserve the last 5 AI replies (keeps conversation coherent)
  • minPrunableToolChars: 30000: only prune tool outputs exceeding 30k characters (avoids over-pruning)
  • softTrim: keep first and last 1000 chars, collapse the middle to a placeholder
  • hardClear: when space-critical, fully replace with placeholder text

Real impact: context size drops 50%+, long sessions become stable.


5. Disable Discord

Problem: Discord WebSocket connections are unstable. Frequent disconnects trigger gateway errors, which cascade into retries that burn quota.

{
  "channels": {
    "discord": {
      "enabled": false
    }
  }
}

My workflow only uses Telegram, so Discord goes straight off. Saves ~100 requests/month.


6. Disable Heartbeat

Problem: Heartbeat is OpenClaw’s liveness check—it pings every 30 minutes by default, and each ping = 1 API call.

{
  "agents": {
    "defaults": {
      "heartbeat": {
        "every": ""
      }
    }
  }
}

Turning it off saves 48 calls/day, or about 1440 requests/month. This is the single largest saving.


7. Clean Up Unused Model Providers

Problem: If you’ve configured multiple model providers (openrouter, various API proxies), the gateway health-checks all of them on startup, burning quota on each check.

{
  "models": {
    "providers": {}
  }
}

Keep only github-copilot, delete the rest. Saves 20-50 requests/month.


8. Disable Exec Approval (New in 4.5+)

Problem: New versions default to elevated privilege approval—the AI has to wait for user confirmation on shell commands, blocking automation workflows.

In your openclaw.json exec config:

{
  "exec": {
    "requireApproval": false
  }
}

Fine for trusted personal ops. Skip this if sharing the instance or automating untrusted tasks.


One-Shot Configuration Script

All 8 can be applied with this Python script:

import json, os

path = os.path.expanduser("~/.openclaw/openclaw.json")
with open(path) as f:
    c = json.load(f)

d = c.setdefault("agents", {}).setdefault("defaults", {})

# 1. Model + clear fallbacks
d["model"] = {"primary": "github-copilot/claude-opus-4.6", "fallbacks": []}

# 2. Timeout 300s
d["timeoutSeconds"] = 300

# 3. Session Compaction
d["compaction"] = {
    "mode": "safeguard",
    "reserveTokensFloor": 120000
}

# 4. Context Pruning
d["contextPruning"] = {
    "mode": "cache-ttl",
    "ttl": "30m",
    "keepLastAssistants": 5,
    "minPrunableToolChars": 30000,
    "softTrim": {"maxChars": 3000, "headChars": 1000, "tailChars": 1000},
    "hardClear": {"enabled": True, "placeholder": "[old tool output cleared]"}
}

# 6. Disable Heartbeat
d["heartbeat"] = {"every": ""}

# 5. Disable Discord
c.setdefault("channels", {}).setdefault("discord", {})["enabled"] = False

# 7. Clean up providers
c.setdefault("models", {})["providers"] = {}

with open(path, "w") as f:
    json.dump(c, f, indent=2, ensure_ascii=False)

print("Config updated. Restart openclaw gateway to apply.")

Then restart the gateway:

openclaw gateway restart

Version Compatibility Notes

Some parameters only work in newer versions (4.5+); writing them to older versions breaks gateway startup:

ParameterOld ≤3.28New 4.5+
compaction.notifyUser❌ unsupported✅
compaction.memoryFlush❌ unsupported✅
auth.cooldowns❌ unsupported✅
discord config keyallowenabled

If gateway restart fails, check openclaw gateway logs for the exact error—usually a version mismatch on some field.


Post-Optimization Monthly Usage

Before: Heartbeat + Discord + fallbacks + context bloat could burn 150+ requests/day.

After (1500 requests/month budget):

PurposeDaily avgMonthly est
Daily ops chats30-50 requests600-800 requests
Quant strategy audits0 (direct cron, no AI)0
Scheduled reports/weather2 requests60 requests
Total~660-860 requests

With 1500 allocated, you’ve got solid headroom. Even a day of intensive ops eating 200 requests won’t blow the monthly budget.


Have OpenClaw config issues or running over quota? Drop by Telegram.

Further reading:


📷 Cover image · generated with Flux Schnell AI · panshi.io brand style