Aligned with: OpenClaw v2026.3.8 | Skill v1.19.0 | Updated: 2026-03-09 | CLI-first advisor
Optimize and troubleshoot OpenClaw workspaces: cost-aware routing, provider configuration, context discipline, lean automation, multi-agent architectures, and error resolution.
Reference files (load when needed):
references/providers.md — all 40+ providers, custom provider schema, failover configThis skill tracks OpenClaw releases via two mechanisms:
CODEBLOCK0
CURRENT → note the version and proceed.STALE → inform the user: "OpenClaw v<new> is available (skill is at v<current>). Run update-skill.sh to review what changed."UNCHECKED → note "Version check unavailable (offline)" and proceed.CODEBLOCK1
Updates are deliberate — this skill never auto-modifies its own content or pushes to git without explicit user action.
Full audit (safe, no changes):
Audit my OpenClaw setup for cost, reliability, and context bloat. Prioritized plan with rollback. Do NOT apply changes.
Troubleshoot a specific problem:
[Describe your symptom or paste the error message]. Diagnose it and give me the exact fix.
Add or configure a provider:
Add [provider name] as a model provider. Walk me through the CLI steps and show me the exact config before applying.
Model routing optimization:
Propose a tiered routing plan: cheap for heartbeats/cron, mid for daily tasks, premium for coding/reasoning. Exact config + rollback. Do NOT apply.
Silent cron job:
Create a cron job that runs [task] every [interval]. Isolated session, NO_REPLY on nothing-to-do. Show me the command first.
Audit agent personality & identity:
Audit my agent's personality and identity files. Check for conflicts, bloat, and bad practices. Walk me through improvements.
config.apply, config.patch), cron jobs, or persistent settings without explicit user approval.Four backup layers exist — don't stack manual backups on top unnecessarily:
| Layer | What | Retention | When It's Enough |
|---|---|---|---|
CLI rolling .bak | Auto-created on every config set, models set, INLINECODE15 | Rolling (overwritten each write) | Single-command undo |
| Nightly GitHub backup |
openclaw backup create | Local state archive with manifest verification (v2026.3.8+) | Until manually deleted | Pre-upgrade safety net; use openclaw backup verify to validate |cp <file> <file>.YYYY-MM-DD-<reason> | Until next nightly covers it, then delete | Major upgrades, multi-file restructuring, direct JSON edits |
Rule: For routine CLI changes (model swaps, cron edits, config sets), do NOT create manual backups. The CLI .bak + nightly GitHub backup are sufficient. Only create a manual backup when: (1) upgrading OpenClaw versions, (2) editing multiple config files simultaneously (identity audits), or (3) editing JSON directly without the CLI. For upgrades, prefer openclaw backup create over manual copies.
40+ providers supported. For full docs (auth commands, config schemas, all model names, custom provider setup): read references/providers.md
Quick lookup — slug, auth env, primary model format:
| Provider | Slug | Auth Env | Model Format |
|---|---|---|---|
| Anthropic | INLINECODE22 | INLINECODE23 | INLINECODE24 |
| OpenAI (API key) |
openai | OPENAI_API_KEY | openai/gpt-5.4 |openai-codex | ChatGPT OAuth | openai-codex/gpt-5.4 |google | GEMINI_API_KEY | google/gemini-3.1-pro-preview |
WARNING — Provider Bans (Mar 2026):
Google: Actively cracking down on Gemini CLI OAuth and AntiGravity access through third-party tools. Accounts are being banned or rate-limited without warning or refunds. Use API key auth (google-gemini-cli/google-antigravity). Production API keys: 150-300 RPM, no ban risk. See GitHub Issue #14203.
Anthropic: Has banned users linking flat-rate Claude Code subscription tokens to OpenClaw. Using Claude Code OAuth tokens directly in OpenClaw may trigger account suspension. However, using Claude Code through the Agent SDK / ACP dispatch (where OpenClaw spawns Claude Code as a sub-agent via the ACP protocol) is the supported pattern and should not cause issues — this is how OpenClaw's built-inacpintegration works.
General: Always prefer pay-per-token API keys over subscription OAuth for third-party tool integrations. Subscription-based OAuth through third-party tools violates most providers' ToS except OpenAI, which explicitly permits Codex OAuth in third-party tools.
| Mistral | mistral | MISTRAL_API_KEY | mistral/mistral-large-latest |
| Groq | groq | GROQ_API_KEY | groq/<model-id> |
| xAI | xai | XAI_API_KEY | xai/grok-code-fast-1 |
| OpenRouter | openrouter | OPENROUTER_API_KEY | openrouter/anthropic/claude-sonnet-4-5 |
| Bedrock | amazon-bedrock | AWS env chain | amazon-bedrock/us.anthropic.claude-opus-4-6-v1:0 |
| Kilo Gateway | kilocode | KILOCODE_API_KEY | kilocode/anthropic/claude-opus-4.6 |
| Moonshot/Kimi | moonshot | MOONSHOT_API_KEY | moonshot/kimi-k2.5 |
| Kimi Coding | kimi-coding | KIMI_API_KEY | kimi-coding/k2p5 |
| Z.AI / GLM | zai | ZAI_API_KEY | zai/glm-5 |
| MiniMax | minimax | MINIMAX_API_KEY | minimax/MiniMax-M2.5-highspeed |
| MiniMax VL-01 | minimax-portal | MINIMAX_API_KEY | minimax-portal/MiniMax-VL-01 |
| Venice AI | venice | VENICE_API_KEY | venice/kimi-k2-5 |
| Hugging Face | huggingface | HF_TOKEN | huggingface/deepseek-ai/DeepSeek-R1 |
| Synthetic | synthetic | SYNTHETIC_API_KEY | synthetic/hf:MiniMaxAI/MiniMax-M2.1 |
| Together AI | together | TOGETHER_API_KEY | together/moonshotai/Kimi-K2.5 |
| Cerebras | cerebras | CEREBRAS_API_KEY | cerebras/zai-glm-4.7 |
| Ollama (local) | ollama | OLLAMA_API_KEY (any) | ollama/llama3.3 |
| vLLM (local) | vllm | VLLM_API_KEY (any) | vllm/<model-id> |
Add a provider (API key):
CODEBLOCK2
Add a provider (OAuth / subscription):
CODEBLOCK3
Some providers offer OAuth authentication tied to a consumer subscription (e.g., ChatGPT Plus/Pro) instead of — or in addition to — a pay-per-token API key. OpenClaw supports these via device-flow OAuth.
Currently supported OAuth providers:
| Provider | Slug | Subscription Required | Top Models |
|---|---|---|---|
| OpenAI Codex | INLINECODE90 | ChatGPT Plus ($20/mo) or Pro ($200/mo) | INLINECODE91 , gpt-5.3-codex, INLINECODE93 |
| GitHub Copilot |
github-copilot | Copilot subscription | github-copilot/gpt-4o |
OpenAI Codex setup (full walkthrough):
CODEBLOCK4
Headless / SSH gateway: The OAuth flow prints a URL. Open it in any browser (doesn't need to be on the gateway machine), complete sign-in, then paste the redirect URL back into the SSH terminal. Alternatively, complete OAuth on a machine with a browser and copy ~/.openclaw/credentials/oauth.json to the gateway.
Available Codex models:
| Model | Plan | Notes |
|---|---|---|
| INLINECODE97 | Plus, Pro, Business | Latest (Mar 2026), 1,050,000-token context, 128K max tokens |
| INLINECODE98 |
openai-codex/gpt-5.3-codex-spark | Pro only | Research preview, low-latency |openai-codex/gpt-5.2-codex | Plus, Pro | Previous gen, stable |openai-codex/codex-mini-latest | Plus, Pro | Lightweight, fast, cheapest |
Usage limits (per 5-hour window):
Gotchas:
OPENAI_API_KEY for text-embedding-3-small etc.~/.openclaw/credentials/oauth.json.gpt-5.3-codex on certain accounts. Fall back to gpt-5.2-codex if this happens.openai-completions) for gpt-5.3-codex. Must register manually in both models.json (API type: openai-codex-responses) AND openclaw.json (API type: openai-responses — openai-codex-responses is only valid in models.json per schema). v2026.2.26 includes a schema fix — verify with openclaw models status --probe after upgrade.openai-codex. OpenAI explicitly permits Codex OAuth in third-party tools, though fair-use limits still apply.Removing a provider requires cleaning 6 locations — config unset alone is not enough:
models.providers.<slug> in openclaw.json — INLINECODE117config unset)~/.openclaw/agents/main/agent/auth-profiles.json — edit with python3/jqopenclaw config unset each aliasusageStats.<slug>:* in auth-profiles.json — edit directlyFor providers with LaunchAgent env vars (Ollama, etc.), also clean:
launchctl unsetenv <KEY> — session-level env persists independently of plistlaunchctl bootstrap to pick up the clean plist (kickstart alone doesn't reload env from plist)Known CLI limitation: openclaw config unset cannot handle colons in config keys (e.g., auth.profiles.google-gemini-cli:email@gmail.com). The parser treats colons as path separators. Edit the JSON file directly for these entries.
Ollama for memory embeddings (v2026.3.2+):
openclaw config set memorySearch.provider ollama
openclaw config set memorySearch.fallback ollama
models.providers.ollama settings.
Custom OpenAI-compatible provider (LM Studio, LiteLLM, etc.): See references/providers.md
| Tier | Models | Use Cases |
|---|---|---|
| T1 Cheap | INLINECODE136 , google/gemini-3-flash-preview, google/gemini-3.1-flash-lite-preview, INLINECODE139 | Heartbeats, simple checks, greetings, cron |
| T2 Mid |
moonshot/kimi-k2.5, minimax/MiniMax-M2.5-highspeed | Daily chat, Q&A, calendar, scheduling |
| T3 Smart | anthropic/claude-sonnet-4-5, openai/gpt-5.4, openai-codex/gpt-5.4 (subscription) | Code, refactors, research |
| T4 Premium | anthropic/claude-opus-4-6, openai/gpt-5.2 | Complex reasoning, orchestration |
Model preference by task:
| Task | Model | Why |
|---|---|---|
| Heartbeats / cron | INLINECODE147 | Cheapest; reliable structured output |
| Calendar / scheduling |
moonshot/kimi-k2.5 | Community #1 for date/time reasoning |anthropic/claude-sonnet-4-5 or openai-codex/gpt-5.4 | Sonnet: community #1 for code quality; Codex: flat-rate via subscription |anthropic/claude-opus-4-6 | Best multi-step reasoning |google/gemini-3-flash-preview or openai-codex/gpt-5.4 | Gemini: 1M token window; Codex 5.4: 1.05M tokens |openai-codex/gpt-5.4 | Fixed cost via ChatGPT Plus/Pro; no per-token billing |venice/kimi-k2-5 or Ollama | Never logged/stored |google/gemini-3.1-flash-lite-preview | Minimal cost; good for lightweight cron/heartbeat |
Key rules:
anthropic direct (not through proxies) to preserve caching for Opus/Sonnet/new)| Alias | Resolves To |
|---|---|
| INLINECODE159 | INLINECODE160 |
| INLINECODE161 |
anthropic/claude-sonnet-4-6 |
| gpt | openai/gpt-5.4 |
| gpt-mini | openai/gpt-5-mini |
| gemini | google/gemini-3.1-pro-preview |
| gemini-flash | google/gemini-3-flash-preview |
| gemini-flash-lite | google/gemini-3.1-flash-lite-preview |
| Level | Behavior | Best For |
|---|---|---|
| INLINECODE173 | No extended thinking | Simple queries, heartbeats |
| INLINECODE174 |
low | Standard reasoning | Default for non-Claude-4.6 reasoning models |
| medium / high | Deeper reasoning | Complex tasks |
| xhigh | "Ultrathink+" | GPT-5.2 + Codex models only |
| adaptive | Provider-managed | Default for Claude 4.6 — auto-scales reasoning to task complexity |
CODEBLOCK6
In-chat: /think low · /think adaptive · INLINECODE182
CODEBLOCK7
CODEBLOCK8
In-chat model switch (no restart): /model list → INLINECODE184
Automatically trims stale tool results from conversation history to preserve cache and reclaim context:
CODEBLOCK9
Anthropic smart defaults auto-enable cache-ttl pruning when using API key auth with heartbeat enabled.
What burns tokens: System prompt (5–10K tokens/call) + bootstrap files + conversation history. Bootstrap files injected on every turn (source: docs.openclaw.ai/concepts/system-prompt): AGENTS.md, SOUL.md, TOOLS.md, IDENTITY.md, USER.md, HEARTBEAT.md, BOOTSTRAP.md (first-run only), plus MEMORY.md and/or memory.md when present. Daily memory/*.md files are NOT auto-injected (on-demand via memory tools). Bootstrap cap: 150K chars total, 20K per file (both configurable).
MEMORY.md warning (from docs): "Keep them concise — especially MEMORY.md, which can grow over time and lead to unexpectedly high context usage and more frequent compaction." MEMORY.md is the most common source of bootstrap bloat. Unlike AGENTS.md or SOUL.md which users actively edit, MEMORY.md tends to grow unchecked as the agent appends to it.
Check context: /status · /context list · /context detail · /usage tokens · INLINECODE201
| Mode | Bootstrap Files Loaded | Use Case |
|---|---|---|
| INLINECODE202 (default) | All — AGENTS, SOUL, TOOLS, IDENTITY, USER, HEARTBEAT, MEMORY | Main interactive sessions |
| INLINECODE203 (sub-agents) |
none | Base identity line only | Bare-minimum sessions |
Skip all workspace bootstrap files for automated runs:
CODEBLOCK10
CODEBLOCK11
Massive token savings for heartbeats and cron — eliminates 5-10K tokens/call of bootstrap overhead.
CODEBLOCK12
When a bootstrap file exceeds bootstrapMaxChars (default 20K), the agent receives a warning. Set to always during identity audits to catch truncated files.
CODEBLOCK13
CODEBLOCK14
Known bug — memory flush threshold gap (Issue #25880): Set reserveTokensFloor equal to reserveTokens (both 62500) to fix compaction firing before flush completes.
Known bug — compaction timeout (Issue #38233): Both /compact and auto compaction can timeout at ~300s with openai-codex/gpt-5.3-codex, freezing the session. Fix: override compaction model to google/gemini-3-flash-preview with thinking: "off". Tune: maxHistoryShare: 0.6, reserveTokensFloor: 40000, maxAttempts: 3.
Replace the built-in context assembly pipeline with a custom plugin:
CODEBLOCK15
Context Engine plugins get full lifecycle hooks: bootstrap, ingest, assemble, compact, afterTurn, prepareSubagentSpawn, onSubagentEnded. This enables alternative context management strategies (lossless context, semantic chunking, etc.) without modifying OpenClaw core.
These are optimization targets for keeping context lean, not hard limits. All files are subject to bootstrapMaxChars (default 20K) and bootstrapTotalMaxChars (default 150K).
| File | Target Size | Purpose | Injected? |
|---|---|---|---|
| INLINECODE226 | < 1K tokens (~4K chars) | Personality + absolute constraints | Always (main + full prompt mode) |
| INLINECODE227 |
TOOLS.md | < 2K tokens (~8K chars) | Tool-specific notes, local conventions | Always (main + sub-agents) |IDENTITY.md | < 500 tokens (~2K chars) | Name, vibe, emoji, presentation | Always (main only) |USER.md | < 1K tokens (~4K chars) | User profile, preferences, context | Always (main only) |HEARTBEAT.md | < 200 tokens (~800 chars) | Heartbeat checklist (keep minimal) | Always (main only); skipped with lightContext |MEMORY.md | < 5K tokens (~20K chars) | Curated long-term facts ONLY | Always in main sessions (auto-injected when present) |
Critical: MEMORY.md is auto-injected on every turn in main sessions, NOT loaded on-demand. It burns tokens continuously. Keep it as small as possible with only curated facts. Operational protocols belong in AGENTS.md. Tool notes belong in TOOLS.md.
Users commonly dump all content into SOUL.md because it feels like "who the agent is." This bloats the file (burns tokens every turn) and confuses lighter models that can't prioritize across a noisy instruction set. Place content in the correct file:
| Content Type | Correct File | Common Mistake |
|---|---|---|
| Personality, voice, humor, constraints | SOUL.md | - |
| Protocols, workflows, checklists, operational rules |
Cross-file duplication burns tokens silently. If the same protocol appears in both SOUL.md and AGENTS.md, it's injected twice on every turn. Deduplicate aggressively — pick one canonical location.
Stale model references are silent saboteurs. When you change models via CLI (openclaw models set), update any AGENTS.md sections that reference specific model names (e.g., Model Selection, Sub-Agent defaults). The agent follows bootstrap instructions and may try to use models that are no longer configured.
Persistence stack: SOUL.md → AGENTS.md → TOOLS.md → IDENTITY.md → USER.md → MEMORY.md (all auto-injected in main sessions) → memory/YYYY-MM-DD.md (on-demand via memory tools) → conversation-state.md → INLINECODE243
CODEBLOCK16
CODEBLOCK17
sessionTarget: "isolated" (recommended — fresh session) | "main" (injects as systemEvent)
payload.kind: "agentTurn" (isolated) | "systemEvent" (main session)
delivery.mode: "announce" | "webhook" | "none"
lightContext: true skips all workspace bootstrap files — massive token savings for automated runs (v2026.3.1+)
CODEBLOCK18
Skip main-session cron jobs when the user is actively chatting:
CODEBLOCK19
Prevents cron jobs from interrupting active conversations. Only affects sessionTarget: "main" jobs; isolated jobs always run.
On gateway startup, missed cron jobs are staggered to prevent gateway starvation. Top-of-hour cron expressions get up to 5 minutes of deterministic stagger. Use --exact or schedule.staggerMs: 0 to disable.
NO_REPLY — agent outputs this literal string when nothing to report; system suppresses delivery entirely.
HEARTBEAT_OK — heartbeat token; reply ≤300 chars after stripping it → silently dropped.
CODEBLOCK20
v2026.2.25 BREAKING: The heartbeat DM toggle was replaced with
directPolicy. Default is nowallow. If you had DMs blocked in v2026.2.24, explicitly setagents.defaults.heartbeat.directPolicy: "block"(or per-agent viaagents.list[].heartbeat.directPolicy).
Cost trap: 5-minute heartbeat loading full MEMORY.md = ~2.9M tokens/day. Keep heartbeat context minimal — use lightContext: true or extend intervals.
Redundant cron jobs: The built-in openclaw memory indexes sessions natively. Custom session archiver cron jobs that convert .jsonl to markdown for a separate RAG database are likely redundant. Check whether any cron job feeds a custom system that duplicates built-in functionality before assuming it's needed.
Known bugs: Cron current-day skip (Issue #25902) — restart the gateway with launchctl kickstart -k gui/$(id -u)/ai.openclaw.gateway to recompute (do NOT use openclaw gateway restart — it causes duplicate processes; see Section 10). Cron announce → Telegram failure (Issue #25906) — switch to directMessage mode.
v2026.2.25 fixes: Cron model override failures now auto-recover — if an isolated job's payload.model is no longer allowlisted, it gracefully falls back to the default model instead of failing the job. Cron announce duplicate sends are also fixed (duplicate guard tracks attempted vs confirmed delivery). Multi-account cron routing now properly honors delivery.accountId.
metadata.openclaw.requires — gates skill visibility:
CODEBLOCK21
disable-model-invocation: true — removes skill from model's tool list; user can still invoke manually. Use for high-impact or security-sensitive skills.
Skills directory: ~/.openclaw/workspace/skills/ — this is the filesystem path where all skills are stored. Each skill lives in its own subdirectory (e.g., ~/.openclaw/workspace/skills/my-skill/SKILL.md). When manually installing or copying skills, always use this path — not ~/.openclaw/skills/.
ClawHub:
CODEBLOCK22
Security: Before installing any skill, read its SKILL.md manually. Community scans found 341+ malicious skills (reverse shells, credential exfiltration, Atomic Stealer, crypto miners). New accounts with popular skills = red flag. The #1 most-downloaded ClawHub skill was confirmed malware.
Session watcher: Skills snapshot at session start. If skills.load.watch is disabled, start a new session after installing.
CODEBLOCK23
CODEBLOCK24
CODEBLOCK25
CODEBLOCK26
Community pattern: Orchestrator (opus-4-6) → Code sub-agent (sonnet-4-5) → Research sub-agent (kimi-k2.5) → Cron/monitoring (zai/glm-5, isolated)
Community insight — single agent with skills beats multiple agents for most use cases. Multiple agent instances multiply context costs (each agent loads its own bootstrap). Use one agent with good skills instead, and only split into multiple agents when you need genuinely different identity/personality/permissions (e.g., a public-facing agent vs an ops agent).
Sandbox isolation:
CODEBLOCK27
Agent Client Protocol enables OpenClaw to spawn external coding harnesses (Claude Code, Codex CLI, Gemini CLI, OpenCode) as sub-agents:
CODEBLOCK28
In-chat: /acp spawn · /acp status · /acp steer <message> · /acp close
| Lever | Impact | How |
|---|---|---|
| Tiered model routing | 50–95% cost reduction | T1 for cron/heartbeat, T4 only for orchestration |
| Prompt caching |
anthropic direct |lightContext: true on heartbeat; --light-context on cron |thinkingDefault: adaptive for Claude 4.6; minimal for routine |contextPruning.mode: cache-ttl with Anthropic |safeguard mode, reserveTokensFloor: 32000 |gemini-3-flash-preview |mode: enforce, maxDiskBytes: 500mb |sessionTarget: "isolated" on all cron jobs |gateway.bind: loopback; Tailscale for remote |/new boundaries |openclaw backup create before openclaw update |Best practice (v2026.2.25+): Before editing config or asking config-field questions, have the agent call the config.schema tool in-chat. This returns the current schema with valid keys, types, and defaults — avoids guessing or using stale field names. Note: this is an agent in-chat tool, NOT a CLI command.
Most common commands:
CODEBLOCK29
openclaw onboard --resetscope change (v2026.2.26): Default reset scope is nowconfig+creds+sessions. Workspace deletion (bootstrap files, skills, memory) now requires--reset-scope full. Do NOT runopenclaw onboard --resetwithout specifying--reset-scopeexplicitly — the default no longer wipes the workspace.
CODEBLOCK30
CODEBLOCK31
Gateway restart (macOS LaunchAgent):
CODEBLOCK32
Full CLI reference (all commands, flags, in-chat commands): Read references/cli-reference.md
Daily:
openclaw health --json via cron (→ HEARTBEAT_OK if clean)Weekly:
openclaw update --dry-run → review → INLINECODE310find ~/.openclaw -name "*.bak.*" -mtime +7 -not -name "*.bak" | xargs rm -v (preserves CLI's rolling .bak files, removes old named/dated backups)Quarterly:
scripts/) for redundancy with built-in OpenClaw features. Users often build custom solutions (RAG pipelines, session archivers, memory indexers) that become redundant when OpenClaw adds equivalent built-in functionality. Check whether each script and its associated cron job still serves a purpose that the platform doesn't already handle.Before/After Updates:
openclaw backup create (pre-change safety net — v2026.3.8+)openclaw doctor --fix (handles config migrations automatically)openclaw config validate --json (catch fail-closed config errors — v2026.3.2+)allowPrivateNetwork → dangerouslyAllowPrivateNetwork — auto-fixed by doctorv2026.3.x Breaking Changes:
gateway.auth.mode required (v2026.3.7): When both gateway.auth.token AND gateway.auth.password are configured, you must set gateway.auth.mode to "token" or "password". Gateway will not start without this.tools.profile defaults to "messaging" (v2026.3.2): New installs no longer start with coding/system tools. Existing installs are unaffected.acp.dispatch.enabled: false to disable.On Every System Assessment (mandatory data collection):
openclaw cron list + read ~/.openclaw/cron/jobs.json — capture full cron inventory: job IDs, names, schedules, model overrides (from payload.model), status, last run timeserror state — these are active problems(exact) instead of named timezones may fire at wrong timesisolated or main session target## Cron Jobs section before making recommendationsSecurity:
openclaw config get gateway.bind → must be INLINECODE342Log file paths (macOS):
~/.openclaw/logs/gateway.err.log — primary source for errors, 502s, plugin failures, tool errors/tmp/openclaw/openclaw-YYYY-MM-DD.log — verbose debug output (lane events, session activity)Always check gateway.err.log first when troubleshooting — it contains only errors and warnings, making root cause identification much faster than grepping the main log.
First — always run this triage sequence:
CODEBLOCK33
Quick fix by symptom:
| Symptom | First Command | Most Likely Fix |
|---|---|---|
| No response from agent | INLINECODE347 | Gateway not running or pairing pending |
| Gateway won't start |
openclaw logs --follow | EADDRINUSE or gateway.mode not set to local |ps aux \| grep openclaw-gateway | Duplicate processes from CLI restart vs LaunchAgent KeepAlive. Fix: launchctl bootout → kill orphans → launchctl bootstrap (see Section 8) |openclaw config get gateway.auth | Both token and password set but gateway.auth.mode missing. Fix: openclaw config set gateway.auth.mode token (v2026.3.7 breaking change) |launchctl getenv OPENCLAW_GATEWAY_TOKEN | Remove stale launchctl env override |openclaw.json. Use openclaw backup create before restarts. |openclaw cron status | Cron disabled or timezone mismatch |openclaw config get agents.defaults.heartbeat.activeHours | Wrong timezone, outside active hours, or directPolicy set to block (v2026.2.25 changed default to allow) |openclaw cron status | v2026.2.25+ auto-recovers by falling back to default model. On older versions: update payload.model in the job or re-add the model to the allowlist. |openclaw logs --follow | Mention required or sender not paired |openclaw gateway status --deep | Auth token mismatch or port conflict |openclaw doctor --fix | Automatic config migration |openclaw models status --probe | Token expired or wrong key type |openclaw browser status | Snap Chromium conflict → install Google Chrome .deb |kimi-coding/k2p5. Switch model. |/compact times out at ~300s with Codex models. Use compaction.model: google/gemini-3-flash-preview |grep "delivery-recovery" gateway.err.log | Not a provider issue. Two common causes: (A) Context bloat — contextTokens unset (unlimited), payload too large for any provider to process within timeoutSeconds. Fix: set contextTokens: 100000, timeoutSeconds: 180, reserveTokensFloor: 32000. See Section 10d. (B) Event loop overload — stuck delivery-queue, skills-remote probes, Gemini OAuth cycling, too many concurrent sessions. Fix: clear delivery queue, set cron.maxConcurrentRuns: 1. See Section 10b. |ls ~/.openclaw/delivery-queue/ | Stuck entries (wrong channel, message too long) retry forever on every restart. Move to ~/.openclaw/delivery-queue/failed/ to stop the loop. |Failed to discover Ollama models | Known bug: OpenClaw hardcodes 127.0.0.1:11434 for Ollama discovery (Issue #8663). On macOS, LaunchAgent processes are sandboxed and can't reach private LAN IPs like 192.168.x.x (Issue #21494). Fix: reverse SSH tunnel from Ollama machine to gateway (ssh -fN -R 127.0.0.1:11434:127.0.0.1:11434 user@gateway), set baseUrl to http://127.0.0.1:11434, add OLLAMA_HOST and OLLAMA_API_KEY to LaunchAgent env. See Section 10a below. |api from ollama to openai-completions changes the error message but doesn't fix it — the sandbox blocks all LAN connections. |curl http://host:11434/api/ps | Set OLLAMA_KEEP_ALIVE=0 on the Ollama machine so models unload immediately after probes. No OpenClaw config to disable probes per-provider. |openclaw logs \| grep rate | Google OAuth crackdown (Feb 2026). Switch to API key auth. See Section 1 warning. |config unset fails on auth profile keys | Edit JSON directly | Colons in keys break the config path parser. Use python3/jq. |models status --probe mass timeouts | Test individual providers with curl | Probe contention — 16+ simultaneous targets saturate the event loop. Not real failures. |
Problem: OpenClaw on macOS cannot connect to a remote Ollama server on the LAN. curl works, but the gateway process fails with "fetch failed" or "Connection error." This affects all API modes (ollama and openai-completions).
Root causes (two bugs stacking):
127.0.0.1:11434 for Ollama, ignoring baseUrl.EHOSTUNREACH for private network IPs (192.168.x.x, 10.x.x.x).Fix — reverse SSH tunnel:
CODEBLOCK34
Add to the gateway's LaunchAgent plist:
CODEBLOCK35
Important: Kill any local Ollama on the gateway first — it will conflict with the tunnel on port 11434. Make the tunnel persistent with a LaunchAgent on the Ollama machine.
Symptom: ALL providers (Kimi, KiloCode, Google, Anthropic, etc.) timeout simultaneously within a 30-90 minute window, even though they are independent services. FailoverError: LLM request timed out. on every model in the fallback chain. May cause gateway crash/restart.
Root cause: The gateway's Node.js event loop is saturated by a pile-up of concurrent operations. Outbound HTTPS responses arrive, but the process can't process them before its own timeout timer fires. The providers are NOT down — the gateway can't handle the responses.
Common overload contributors (check all of these):
~/.openclaw/delivery-queue/ that will never succeed (wrong channel, message too long) retry on every restart and periodically. Each retry burns event loop time.ls ~/.openclaw/delivery-queue/*.json | wc -l and grep "delivery-recovery" gateway.err.log | tail -20
- Fix: INLINECODE415
grep "skills-remote.*timed out" gateway.err.log | wc -l
- Fix: Remove offline nodes from paired devices, or ensure nodes have the node service running.
grep "google-gemini-cli.*timed out" gateway.err.log | tail -10
- Fix: Ensure OAuth tokens are fresh, or use the google (API key) provider instead of google-gemini-cli for fallbacks.
Recovery: After fixing underlying causes, restart gateway: INLINECODE421
launchctl setenv Persistence (macOS)Problem: Removing an env var from the LaunchAgent plist does NOT remove it from the launchd session environment. The gateway process still sees the old value after a kickstart -k restart.
Root cause: launchctl setenv sets variables at the launchd domain level, independent of any plist. These persist until the user logs out or they are explicitly unset. kickstart -k re-reads the plist for ProgramArguments and EnvironmentVariables, but the domain-level env set by setenv takes precedence.
Fix:
CODEBLOCK36
Key lesson: Always clean both plist AND launchctl unsetenv when removing provider env vars. Use launchctl getenv <KEY> to verify removal. If the command returns output (even empty), the var is still set. "Not set" means launchctl getenv exits with an error.
Symptom: ALL providers in the fallback chain timeout simultaneously on the same request. The same runId appears across multiple providers in 90-second intervals. Looks like a massive outage but providers are actually fine.
Pattern in logs:
CODEBLOCK37
Root cause: contextTokens is unset (defaults to unlimited). The main session accumulates conversation history until the payload is so large that no provider can respond within timeoutSeconds. Each provider in the fallback chain gets the same oversized payload, times out, and passes to the next one — creating a cascade that takes timeoutSeconds × number_of_providers to fully fail.
The deadly trio:
contextTokens — payload grows uncheckedtimeoutSeconds (e.g., 90) — not enough time for large payloadsFix — recommended baseline for any mixed-provider fallback chain:
CODEBLOCK38
How this works together:
contextTokens: 100000 — caps context so all providers can handle itTradeoff: Models with large context windows (Gemini: 1M, GPT-5.4: 1.05M) are capped at 100K. This is intentional — the cap must match the weakest provider in the fallback chain. For dedicated large-context sessions, temporarily increase contextTokens.
Full troubleshooting reference (7 failure categories, per-channel error tables, node error codes, GitHub issue workarounds): Read references/troubleshooting.md
This skill maintains system profiles — persistent knowledge files that capture everything learned about specific OpenClaw deployments. Each deployment gets a unique profile that grows over time, turning the skill into an expert on that particular system.
Directory: ~/.openclaw-optimizer/systems/ — one profile per deployment, plus TEMPLATE.md for new deployments. This is a centralized location outside the skill directory so that: (1) system profiles are never accidentally pushed to git, (2) multiple AI tools (Claude Code, OpenClaw, Gemini CLI, etc.) on the same machine can read/write the same profiles without drift. Cross-machine sync is still manual via SCP.
Deployment ID: Each deployment has a unique slug (e.g., jbd-home, prod-cluster-east, dev-standalone).
Profile formats (two supported):
~/.openclaw-optimizer/systems/<deployment-id>/ — directory containing INDEX.md (always-loaded summary, ~1-4K tokens) plus topic files loaded on-demand. Dramatically reduces session-start context cost.~/.openclaw-optimizer/systems/<deployment-id>.md — monolith file containing everything. Still supported for backwards compatibility.Topology types:
| Type | Description |
|---|---|
| INLINECODE450 | Single gateway, no remote nodes |
| INLINECODE451 |
multi-gateway | Multiple gateways, nodes may connect to different ones |mesh | Nodes interconnected, multiple gateways with cross-routing |
First-run setup (once per machine):
~/.openclaw-optimizer/systems/ exists~/.openclaw-optimizer/systems/ (centralized, outside git, shared across AI tools), confirm they're OK with creating it, then: mkdir -p ~/.openclaw-optimizer/systems/ and copy TEMPLATE.md from the skill's systems/ directory into itTEMPLATE.md from the skill's systems/ directoryAt session start (identify the deployment):
~/.openclaw-optimizer/systems/<deployment-id>/ directory existsINDEX.md only (~1-4K tokens). Use the File Manifest table at the bottom to load topic files on-demand during the session — do NOT read all files upfront.<deployment-id>.md file exists: read the monolith (legacy mode). Consider migrating to directory format.~/.openclaw-optimizer/systems/TEMPLATE.md during the sessionOn any system assessment or audit (mandatory — run before making recommendations):
openclaw cron list — capture full cron inventory: job IDs, names, schedules, status, last run timeserror state — these are active problems(exact) instead of named timezones may fire at wrong timesDuring the session (on-demand file loading):
lessons.md FIRST (check if it's already solved), then the relevant topic filecron.md for full job IDs, schedules, and observationsproviders.md and/or INLINECODE474channels.md for group API IDs and mappingissues/YYYY-MM.md for the relevant monthAt session end (update the profile):
For directory-based profiles:
routing.md if fallbacks were reordered)INDEX.md only if summary-level data changed (new provider added/removed, routing swap, cron status change, machine added/removed)issues/YYYY-MM.md (current month file, newest first) with: symptom, root cause, fix, rollback, lessonlessons.md (permanent, never archived)Last updated date in INDEX.md~/.openclaw-optimizer/systems/, NOT in the skill directory. Do not commit them to git.For legacy single-file profiles:
Last updated date| Topic | File (directory format) | Purpose |
|---|---|---|
| Machines, Network, Paired Devices | INLINECODE486 | Every machine: role, SSH, IPs, OS, paths, config. Tailnet, auth, connectivity. Device entries from paired.json. |
| Providers |
providers.md | Active model providers with slugs, auth details, notes. Removed providers with context. |
| Model Routing | routing.md | Tiered routing table, fallback chain, heartbeat config |
| Channels, Delivery Queue | channels.md | Messaging channels, Telegram group mapping, stuck delivery entries |
| Cron Jobs | cron.md | Full inventory: job ID, name, schedule, model, status, observations |
| Issues | issues/YYYY-MM.md | Every problem encountered: symptom → root cause → fix → rollback → lesson |
| Lessons Learned | lessons.md | Accumulated patterns and gotchas specific to this deployment (permanent) |
| Summary | INDEX.md | Always-loaded overview with key tables and file manifest |
issues/YYYY-MM.md (current month file, newest first)lessons.md (permanent, never archived)... for tokens, never store full API keysws:// for remote gateways — always use wss://".bak files on every config write, and the nightly GitHub backup cron captures the full config in git history. Manual dated backups (cp <file> <file>.YYYY-MM-DD-<reason>) are only needed for: (1) major version upgrades, (2) multi-file restructuring (identity audits), (3) direct JSON edits where the CLI isn't used. For routine CLI changes (model swaps, cron edits, config sets), the CLI .bak + GitHub nightly are sufficient. Clean up old manual backups after they're covered by the nightly backup.This skill is a living document. Every troubleshooting session, every CLI interaction, and every failure is an opportunity to make it more accurate. Future sessions must actively update the skill based on real-world experience.
| Trigger | Action |
|---|---|
| A CLI command in the skill doesn't work as documented | Fix the command, add a note about what changed |
| A troubleshooting step is missing or incomplete |
对齐版本:OpenClaw v2026.3.8 | 技能 v1.19.0 | 更新日期:2026-03-09 | CLI 优先顾问
优化和排查 OpenClaw 工作区问题:成本感知路由、提供商配置、上下文规范、精益自动化、多智能体架构和错误解决。
参考文件(需要时加载):
本技能通过两种机制追踪 OpenClaw 版本:
bash
python3 ~/.claude/skills/openclaw-optimizer/scripts/version-check.py --status
bash
更新是有意为之的——本技能从不会在没有明确用户操作的情况下自动修改自身内容或推送到 git。
完整审计(安全,无变更):
审计我的 OpenClaw 设置,关注成本、可靠性和上下文膨胀。提供带回滚的优先级计划。不要应用更改。
排查特定问题:
[描述你的症状或粘贴错误信息]。诊断问题并给出确切的修复方案。
添加或配置提供商:
添加 [提供商名称] 作为模型提供商。逐步指导我完成 CLI 步骤,并在应用前显示确切的配置。
模型路由优化:
提出一个分层路由计划:心跳/cron 用廉价模型,日常任务用中等模型,编码/推理用高级模型。提供确切配置 + 回滚方案。不要应用更改。
静默 cron 任务:
创建一个 cron 任务,每 [间隔] 运行 [任务]。使用隔离会话,无事可做时返回 NO_REPLY。先向我显示命令。
审计智能体个性与身份:
审计我的智能体的个性和身份文件。检查冲突、膨胀和不良实践。逐步指导我进行改进。
存在四个备份层——不要不必要地叠加手动备份:
| 层 | 内容 | 保留策略 | 何时足够 |
|---|---|---|---|
| CLI 滚动 .bak | 每次 config set、models set、cron edit 时自动创建 | 滚动(每次写入覆盖) | 单命令撤销 |
| 夜间 GitHub 备份 |
规则: 对于常规 CLI 更改(模型交换、cron 编辑、配置设置),不要创建手动备份。CLI .bak + 夜间 GitHub 备份就足够了。仅在以下情况下创建手动备份:(1)升级 OpenClaw 版本时,(2)同时编辑多个配置文件时(身份审计),(3)不使用 CLI 直接编辑 JSON 时。对于升级,优先使用 openclaw backup create 而不是手动复制。
支持 40+ 个提供商。完整文档(认证命令、配置架构、所有模型名称、自定义提供商设置):阅读 references/providers.md
快速查找——slug、认证环境变量、主要模型格式:
| 提供商 | Slug | 认证环境变量 | 模型格式 |
|---|---|---|---|
| Anthropic | anthropic | ANTHROPICAPIKEY | anthropic/claude-opus-4-6 |
| OpenAI(API 密钥) |
警告——提供商封禁(2026 年 3 月):
Google: 正在严厉打击通过第三方工具使用 Gemini CLI OAuth 和 AntiGravity 访问。账户正在被无警告或无退款地封禁或限速。使用 API 密钥认证(google 提供商)而不是 OAuth(google-gemini-cli / google-antigravity)。生产环境 API 密钥:150-300 RPM,无封禁风险。参见 GitHub Issue #14203。
Anthropic: 已封禁将固定费率的 Claude Code 订阅令牌链接到 OpenClaw 的用户。直接在 OpenClaw 中使用 Claude Code OAuth 令牌可能会触发账户暂停。但是,通过 Agent SDK / ACP 调度(OpenClaw 通过 ACP 协议生成 Claude Code 作为子智能体)使用 Claude Code 是受支持的模式,不应引起问题——这是 OpenClaw 内置 acp 集成的工作方式。
一般建议: 对于第三方工具集成,始终优先使用按令牌付费的 API 密钥,而不是订阅 OAuth。通过第三方工具使用基于订阅的 OAuth 违反了大多数提供商的服务条款,但 OpenAI 明确允许在第三方工具中使用 Codex OAuth。
| Mistral | mistral | MISTRALAPIKEY | mistral/mistral-large-latest |
| Groq | groq | GROQAPIKEY | groq/
| xAI | xai | XAIAPIKEY | xai/grok-code-fast-1 |
| OpenRouter | openrouter | OPENROUTERAPIKEY | openrouter/anthropic/claude-sonnet-4-5 |
| Bedrock | amazon-bedrock | AWS 环境变量链 | amazon-bedrock/us.anthropic.claude-opus-4-6-v1:0 |
| Kilo Gateway | kilocode | KILOCODEAPIKEY | kilocode/anthropic/claude-opus-4.6 |
| Moonshot/Kimi | moonshot | MOONSHOTAPIKEY | moonshot/kimi-k2.5 |
| Kimi Coding | kimi-coding | KIMIAPIKEY | kimi-coding/k2p5 |
| Z.AI / GLM | zai | ZAIAPIKEY | zai/glm-5 |
| MiniMax | minimax | MINIMAXAPIKEY | minimax/MiniMax-M2.5-highspeed |
| MiniMax VL-01 | minimax-portal
该技能支持在以下平台通过对话安装:
帮我安装 SkillHub 和 openclaw-optimizer-1776292926 技能
设置 SkillHub 为我的优先技能安装源,然后帮我安装 openclaw-optimizer-1776292926 技能
skillhub install openclaw-optimizer-1776292926
文件大小: 67.48 KB | 发布时间: 2026-4-16 18:24
多链集团旗下-闲社网
闲社在线客服
关注闲社网微信
闲社网APP
Archiver·手机版·闲社网·闲社论坛·智能体自动化市场· 多链控股集团有限公司 · 苏ICP备2025199260号-1
Powered by Discuz! X5.0 © 2024-2026 闲社网·AI智能体论坛·AI自动化解决方案·http://xianshe.com
