31. CLI backendlar (zaxira ijro muhiti)
- OpenClaw API provayderlari ishlamay qolganda, cheklanganda yoki vaqtincha nosoz bo‘lganda mahalliy AI CLIlarni faqat matnli zaxira sifatida ishga tushirishi mumkin. 33. Bu ataylab konservativ:
-
- Vositalar o‘chirilgan (tool chaqiriqlari yo‘q).
-
- Matn kiradi → matn chiqadi (ishonchli).
-
- Sessiyalar qo‘llab-quvvatlanadi (keyingi navbatlar izchil bo‘lib qoladi).
-
- Rasmlar uzatilishi mumkin, agar CLI rasm yo‘llarini qabul qilsa.
- Bu asosiy yo‘l emas, balki xavfsizlik tarmog‘i sifatida mo‘ljallangan. 39. Uni tashqi API’larga tayanmasdan “har doim ishlaydi” degan matnli javoblar xohlaganingizda ishlating.
40. Boshlovchilar uchun tezkor start
- Siz Claude Code CLI’dan hech qanday konfiguratsiyasiz foydalanishingiz mumkin (OpenClaw ichki standart bilan keladi):
- Codex CLI ham qutidan chiqishi bilan ishlaydi:
- Agar shlyuzingiz launchd/systemd ostida ishlasa va PATH minimal bo‘lsa, faqat buyruq yo‘lini qo‘shing:
- Shuning o‘zi kifoya. 48. CLI’ning o‘zidan tashqari hech qanday kalitlar yoki qo‘shimcha autentifikatsiya sozlamalari kerak emas.
49. Uni zaxira sifatida ishlatish
- Asosiy modellaringiz ishlamay qolgandagina ishga tushishi uchun zaxira ro‘yxatiga CLI backend qo‘shing:
- Agar siz
agents.defaults.models(allowlist) dan foydalansangiz,claude-cli/...ni kiritishingiz shart. - Agar asosiy provayder ishlamasa (auth, rate limitlar, timeouts), OpenClaw keyingi navbatda CLI backend’ni sinab ko‘radi.
Konfiguratsiya haqida umumiy ma’lumot
Barcha CLI backend’lar quyida joylashgan:claude-cli, my-cli).
The provider id becomes the left side of your model ref:
Konfiguratsiya namunasi
Qanday ishlaydi
- Backend’ni tanlaydi provayder prefiksi (
claude-cli/...) asosida. - Builds a system prompt using the same OpenClaw prompt + workspace context.
- Executes the CLI with a session id (if supported) so history stays consistent.
- Parses output (JSON or plain text) and returns the final text.
- Persists session ids per backend, so follow-ups reuse the same CLI session.
Sessions
- If the CLI supports sessions, set
sessionArg(e.g.--session-id) orsessionArgs(placeholder{sessionId}) when the ID needs to be inserted into multiple flags. - If the CLI uses a resume subcommand with different flags, set
resumeArgs(replacesargswhen resuming) and optionallyresumeOutput(for non-JSON resumes). sessionMode:always: always send a session id (new UUID if none stored).existing: only send a session id if one was stored before.none: never send a session id.
Images (pass-through)
If your CLI accepts image paths, setimageArg:
imageArg is set, those
paths are passed as CLI args. If imageArg is missing, OpenClaw appends the
file paths to the prompt (path injection), which is enough for CLIs that auto-
load local files from plain paths (Claude Code CLI behavior).
Inputs / outputs
output: "json"(default) tries to parse JSON and extract text + session id.output: "jsonl"parses JSONL streams (Codex CLI--json) and extracts the last agent message plusthread_idwhen present.output: "text"treats stdout as the final response.
input: "arg"(default) passes the prompt as the last CLI arg.input: "stdin"sends the prompt via stdin.- If the prompt is very long and
maxPromptArgCharsis set, stdin is used.
Defaults (built-in)
OpenClaw ships a default forclaude-cli:
command: "claude"args: ["-p", "--output-format", "json", "--dangerously-skip-permissions"]resumeArgs: ["-p", "--output-format", "json", "--dangerously-skip-permissions", "--resume", "{sessionId}"]modelArg: "--model"systemPromptArg: "--append-system-prompt"sessionArg: "--session-id"systemPromptWhen: "first"sessionMode: "always"
codex-cli:
command: "codex"args: ["exec","--json","--color","never","--sandbox","read-only","--skip-git-repo-check"]resumeArgs: ["exec","resume","{sessionId}","--color","never","--sandbox","read-only","--skip-git-repo-check"]output: "jsonl"resumeOutput: "text"modelArg: "--model"imageArg: "--image"sessionMode: "existing"
command path).
Limitations
- No OpenClaw tools (the CLI backend never receives tool calls). Some CLIs may still run their own agent tooling.
- No streaming (CLI output is collected then returned).
- Structured outputs depend on the CLI’s JSON format.
- Codex CLI sessions resume via text output (no JSONL), which is less
structured than the initial
--jsonrun. OpenClaw sessions still work normally.
Troubleshooting
- CLI not found: set
commandto a full path. - Wrong model name: use
modelAliasesto mapprovider/model→ CLI model. - No session continuity: ensure
sessionArgis set andsessionModeis notnone(Codex CLI currently cannot resume with JSON output). - Images ignored: set
imageArg(and verify CLI supports file paths).