
1. OpenClaw 2026.7.2 在 WSL2 下到底卡在哪OpenClaw 2026.7.2 是一個(gè)跑在本地、能讀寫文件并執(zhí)行工具調(diào)用的開源個(gè)人助理框架它自帶 gateway 網(wǎng)關(guān)進(jìn)程和 SQLite 狀態(tài)存儲(chǔ)適合愿意自己掌控?cái)?shù)據(jù)、又想讓 Codex 這類編碼助手接入統(tǒng)一模型通道的人。如果你在 Windows 上直接跑onboard 向?qū)?huì)明確提示「Windows detected - OpenClaw runs great on WSL2」因?yàn)?gateway 的進(jìn)程模型、SQLite 的 STRICT 表遷移、以及文件鎖行為在原生 Windows 下容易出岔子。我實(shí)測(cè)下來最省心的路徑就是 WSL2 Ubuntu把 gateway 和 SQLite 都放在 Linux 文件系統(tǒng)里再通過 TaoToken 統(tǒng)一 Key 接入模型通道。很多人第一次跑node scripts/run-node.mjs gateway會(huì)直接撞上這段報(bào)錯(cuò)[gateway] loading configuration… [gateway] resolving authentication… Gateway start blocked: existing config is missing gateway.mode. Treat this as suspicious or clobbered config. Re-run openclaw onboard --mode local or openclaw setup, set gateway.modelocal manually, or pass --allow-unconfigured. [ELIFECYCLE] Command failed with exit code 78.exit code 78 是配置校驗(yàn)失敗不是崩潰。根因是 settings.json 里缺少gateway.mode字段而 2026.7.2 把 gateway 模式從「隱式默認(rèn)」改成了「必須顯式聲明」。同時(shí) onboard 階段還會(huì)做一次 SQLite 狀態(tài)遷移把舊的 audit event ledger 遷到 versioned message lifecycle schema并把共享狀態(tài)表切成 SQLite STRICT typing我這邊看到遷移了 71 張表。如果這一步在 WSL2 的掛載盤比如/mnt/c/...上執(zhí)行SQLite 的 WAL 鎖經(jīng)常失敗遷移記錄會(huì)寫不完整下一次啟動(dòng)就報(bào) config clobbered。所以這篇的路線是WSL2 里建工作區(qū) → 寫一份帶 gateway 和 SQLite 的 settings.json 骨架 → 用 TaoToken 的 Key 填模型通道 → 跑 gateway 驗(yàn)證 → 排掉幾個(gè)高頻錯(cuò)。全程命令可直接復(fù)制。2. TaoToken 前置一把 Key 打通 Codex 與 gatewayOpenClaw 的模型調(diào)用走的是 OpenAI 兼容協(xié)議Codex 也是。與其給每個(gè)工具單獨(dú)配一套憑證不如用 TaoToken 做統(tǒng)一入口一個(gè) API Key一個(gè) base URLgateway 和 Codex 共用。這樣 settings.json 里只需要維護(hù)一處apiKey和baseUrl換模型時(shí)改model字段就行。你需要先拿到 Key。打開控制臺(tái)創(chuàng)建https://taotoken.net/console?utm_sourcetaotoken_aicg_blog_endutm_contentconsoleutm_campaignrewrite創(chuàng)建完在 API Keys 頁面復(fù)制形如sk-...。接入文檔在這里遇到字段對(duì)不上時(shí)對(duì)照查https://taotoken.net/doc?utm_sourcetaotoken_aicg_blog_endutm_contentdocutm_campaignrewriteAPI 基地址統(tǒng)一用https://taotoken.net/api注意這個(gè)地址不帶任何查詢參數(shù)直接填進(jìn)配置。如果你只是想先確認(rèn) Key 能用、模型能回話不用急著配 OpenClaw先去模型對(duì)話頁發(fā)一條消息驗(yàn)證https://taotoken.net/model-chat?utm_sourcetaotoken_aicg_blog_endutm_contentmodel-chatutm_campaignrewrite長(zhǎng)期跑編碼任務(wù)、想讓 Codex 和 OpenClaw 共享額度與調(diào)用記錄的話Coding Plan 更合適后面第 6 節(jié)會(huì)講怎么把兩者指到同一個(gè)通道。注意Key 只存在 WSL2 的 Linux 文件系統(tǒng)里別放到/mnt/c/Users/...下也別提交進(jìn) git。OpenClaw 的工具能讀文件密鑰放在 agent 可達(dá)目錄等于敞開。3. 可復(fù)制配置WSL2 下的 settings.json 骨架先確認(rèn)你在 WSL2 里而不是 PowerShelluname -a # 期望看到 ... microsoft-standard-WSL2 ...然后建工作區(qū)和配置目錄。OpenClaw 默認(rèn)讀~/.openclaw/我們把它固定在 Linux 家目錄mkdir -p ~/.openclaw/workspace mkdir -p ~/.openclaw/state cd ~/.openclaw接下來是核心的settings.json。這份骨架覆蓋 gateway 模式、監(jiān)聽地址、SQLite 路徑與 STRICT 遷移開關(guān)、以及模型通道。把sk-你的Key替換成上一步復(fù)制的值{ gateway: { mode: local, host: 127.0.0.1, port: 8787, allowUnconfigured: false, auth: { provider: taotoken, apiKey: sk-你的Key, baseUrl: https://taotoken.net/api } }, model: { provider: openai-compatible, name: gpt-5-codex, baseUrl: https://taotoken.net/api, apiKey: sk-你的Key, timeoutMs: 120000 }, state: { driver: sqlite, path: /home/你的用戶名/.openclaw/state/openclaw.db, strictTyping: true, journalMode: WAL, busyTimeoutMs: 5000, migrations: { autoMigrate: true, auditLedgerToLifecycle: true, matrixInboundDedupe: true } }, session: { dmScope: per-channel-peer }, tools: { sandbox: true, leastPrivilege: true } }幾個(gè)字段值得單獨(dú)說。gateway.mode必須是local這就是 exit code 78 的直接解藥allowUnconfigured設(shè) false 是為了讓配置缺失時(shí)立刻報(bào)錯(cuò)而不是靜默降級(jí)。state.path用絕對(duì)路徑且必須在 Linux 文件系統(tǒng)內(nèi)/mnt/c下的 SQLite 會(huì)因?yàn)?9p 文件系統(tǒng)不支持可靠的鎖而隨機(jī)損壞。journalMode: WAL配合busyTimeoutMs能顯著減少 gateway 與遷移進(jìn)程并發(fā)寫時(shí)的database is locked。strictTyping: true對(duì)應(yīng) 2026.7.2 的 STRICT 表遷移保持開啟才能讓遷移記錄完整落庫。把用戶名替換成實(shí)際值可以用命令自動(dòng)填sed -i s#/home/你的用戶名#/home/$USER# ~/.openclaw/settings.json確認(rèn) JSON 合法別讓一個(gè)逗號(hào)毀掉整個(gè)啟動(dòng)python3 -m json.tool ~/.openclaw/settings.json /dev/null echo JSON OK4. 驗(yàn)證請(qǐng)求從 gateway 啟動(dòng)到 Codex 連通配置寫完先跑一次 setup 讓 SQLite 完成遷移再啟 gateway。順序很重要反了會(huì)因?yàn)楸斫Y(jié)構(gòu)未就緒而報(bào)錯(cuò)cd ~/openclaw # 你的 OpenClaw 源碼目錄 node scripts/run-node.mjs setup正常會(huì)看到遷移日志類似[state-migrations] Auto-migrated legacy state: - Migrated shared state audit event ledger → versioned message lifecycle schema - Migrated shared state tables to SQLite STRICT typing (71) - Recorded Matrix inbound dedupe migration completion然后啟動(dòng) gatewaynode scripts/run-node.mjs gateway期望輸出[gateway] loading configuration… [gateway] resolving authentication… [gateway] listening on 127.0.0.1:8787 (modelocal)不再出現(xiàn) exit code 78 就說明gateway.mode生效了。另開一個(gè) WSL2 終端做連通性檢查先探端口curl -s -o /dev/null -w %{http_code}\n http://127.0.0.1:8787/healthz # 期望 200再驗(yàn)證模型通道是否真的能回話。用 TaoToken 的兼容端點(diǎn)直接打一次確認(rèn) Key 和 baseUrl 沒問題curl -s https://taotoken.net/api/v1/chat/completions \ -H Authorization: Bearer sk-你的Key \ -H Content-Type: application/json \ -d { model: gpt-5-codex, messages: [{role: user, content: reply with OK only}] } | python3 -c import sys,json;print(json.load(sys.stdin)[choices][0][message][content])返回OK就說明統(tǒng)一通道打通了。最后確認(rèn) SQLite 狀態(tài)庫真的建起來了并且是 STRICT 表sqlite3 ~/.openclaw/state/openclaw.db .tables sqlite3 ~/.openclaw/state/openclaw.db PRAGMA journal_mode; # 期望輸出 wal如果.tables里能看到 message lifecycle 相關(guān)的表說明遷移成功。到這一步gateway 在跑、SQLite 在寫、模型通道能回話Codex 側(cè)只要把 base URL 指到https://taotoken.net/api、Key 填同一個(gè)就能和 OpenClaw 共享通道。5. 本篇常見錯(cuò)排查exit code 78 反復(fù)出現(xiàn)。九成是gateway.mode沒寫或?qū)懗闪藙e的值。檢查python3 -c import json;print(json.load(open(/home/$USER/.openclaw/settings.json))[gateway][mode])輸出必須是local。如果你之前用--allow-unconfigured啟動(dòng)過配置可能被標(biāo)記為 clobbered刪掉~/.openclaw/state/下的臨時(shí)鎖文件再跑 setup。database is locked或遷移卡住。通常是 state.path 落在了/mnt/c。確認(rèn)路徑python3 -c import json;print(json.load(open(/home/$USER/.openclaw/settings.json))[state][path])只要出現(xiàn)/mnt/就搬回 Linux 家目錄。另外確認(rèn)沒有兩個(gè) gateway 進(jìn)程同時(shí)跑pgrep -af run-node.mjs有多個(gè)就 kill 掉多余的SQLite 單寫者模型不允許并發(fā)寫。模型調(diào)用 401 或 404。401 是 Key 錯(cuò)或沒帶Bearer404 多半是 baseUrl 多寫了/v1。TaoToken 的基地址就是https://taotoken.net/api路徑由客戶端補(bǔ)/v1/chat/completions別自己拼重復(fù)。用第 4 節(jié)的 curl 單獨(dú)測(cè)一次能定位是配置問題還是網(wǎng)絡(luò)問題。Codex 連不上但 gateway 正常。Codex 讀的是它自己的配置不是 OpenClaw 的 settings.json。把 Codex 的 base URL 和 Key 手動(dòng)指到同一組值別指望它自動(dòng)繼承。兩邊都指向https://taotoken.net/api后調(diào)用記錄才會(huì)匯總到同一個(gè) Key 下。onboard 里 AI check failed: Codex completion failed。這是 onboard 階段探測(cè) Codex 時(shí)模型通道還沒配好導(dǎo)致的屬于預(yù)期現(xiàn)象。先跳過按本文把 settings.json 寫全再回頭跑openclaw onboard補(bǔ) AI 配置即可。6. 把 Codex 和 gateway 收斂到一條通道配置穩(wěn)定后建議把 Codex 的長(zhǎng)期編碼任務(wù)和 OpenClaw 的 gateway 都收斂到 TaoToken 的同一個(gè) Key 上。這樣調(diào)用額度、模型切換、審計(jì)記錄都在一處排障時(shí)不用在兩個(gè)后臺(tái)之間來回跳。Codex 側(cè)改 base URL 和 Key 后跑一次真實(shí)補(bǔ)全確認(rèn)codex --version # 然后在 Codex 里發(fā)一條需要讀文件的指令確認(rèn)能正常返回如果你打算讓 OpenClaw 長(zhǎng)期掛著跑、Codex 也高頻用Coding Plan 比按量更劃算開通入口https://taotoken.net/coding-plan?utm_sourcetaotoken_aicg_blog_endutm_contentcoding-planutm_campaignrewriteKey 管理和新建入口在控制臺(tái)換 Key 時(shí)記得同步更新 settings.json 里的兩處apiKeygateway.auth 和 model 各一處改完重啟 gateway 生效https://taotoken.net/console?utm_sourcetaotoken_aicg_blog_endutm_contentconsoleutm_campaignrewrite字段含義對(duì)不上時(shí)查接入文檔里面有完整的兼容端點(diǎn)說明https://taotoken.net/api-keys?utm_sourcetaotoken_aicg_blog_endutm_contentapi-keysutm_campaignrewrite最后提醒一句OpenClaw 的工具默認(rèn)能讀文件、執(zhí)行動(dòng)作tools.sandbox和leastPrivilege別關(guān)。密鑰放在 Linux 家目錄、別進(jìn) git、別放/mnt/c這三條守住本地環(huán)境基本就穩(wěn)了。