OpenClaw Local Coordinator + Telegram Remote Ordering + Codex/Claude Execution Flow
Environment: Mac Studio M4 Max / 36GB RAM. Local model: Ollama + qwen3:8b. Execution engines: OpenAI Codex CLI and Claude Code CLI.
Goal: mobile Telegram order -> automatic execution on Mac -> result report to Telegram with auditability and control.
message read; the stable production path is hook-based event triggering.System Architecture
Core Components
- OpenClaw Gateway:
ws://127.0.0.1:18789 - OpenClaw Agent(main): Ollama
qwen3:8b - Telegram channel via Bot API polling + DM pairing
run_task.sh/dispatch_task.sh/tg_send.sh- Hook pack:
tg-execlistening tomessage:received
Execution Chain
- Telegram receives
/execjob - Hook triggers
dispatch_task.sh - Task file is generated and routed to
run_task.sh - Codex/Claude executes work
tg_send.shreturns result to Telegram
Timeline Summary (From Issues to Success)
1) Gateway pairing-required loop (1008)
App was repeatedly kicked with pairing required until pending device requests were approved as operator.
openclaw devices list
openclaw devices approve <request-id>
2) Cloud model switched to local Ollama
DeepSeek 32b failed tool support; qwen3:8b became stable after provider config was correctly registered.
Verification: TUI shows ollama/qwen3:8b and no OpenAI/Claude token burn.
3) Telegram replaced iMessage integration
Fixed plugin enablement, JSON syntax, token validity, and pairing flow to reach ping/pong reliability.
4) Local execution pipeline wired
Codex/Claude execution stabilized only after converting script calls to absolute paths due to launchd PATH gaps.
5) Polling dropped, hooks adopted
Because Telegram provider does not support read, the final reliable path is event-driven hook triggering.
Final Usage Method (Only /execjob)
Send this in Telegram:
/execjob
run: codex
repo: /Users/macstudio_alexxon/dev/Kircerta
task:
<Your task text...>
- Supported engines:
codex,claude repomust exist locally and include.git- Outputs are returned via Telegram and persisted under
~/.openclaw/workspace/reports/
Key Files and Directories
Main config: ~/.openclaw/openclaw.json
Agent workspace: ~/.openclaw/agents/main/agent/ + USER.md
Tools: ~/.openclaw/workspace/tools/{run_task.sh,dispatch_task.sh,tg_send.sh}
Task queue: ~/.openclaw/workspace/tasks/
Reports: ~/.openclaw/workspace/reports/
Managed hooks: ~/.openclaw/hooks/openclaw-hook-tg-exec/
Key Command List
Basic health checks
openclaw gateway status
openclaw gateway health
openclaw channels status --probe
openclaw hooks list
openclaw hooks check
Telegram pairing
openclaw channels list
openclaw channels status --probe
openclaw pairing approve telegram <CODE>
Allowlist hardening
openclaw approvals allowlist add --agent main "~/.openclaw/workspace/tools/run_task.sh"
openclaw approvals allowlist add --agent main "~/.openclaw/workspace/tools/dispatch_task.sh"
openclaw approvals allowlist add --agent main "~/.openclaw/workspace/tools/tg_send.sh"
openclaw approvals allowlist add --agent main "/usr/bin/git"
openclaw approvals allowlist add --agent main "~/.nvm/versions/node/v24.13.1/bin/codex"
openclaw approvals allowlist add --agent main "~/.local/bin/claude"
Hook and web search
openclaw hooks install ~/.openclaw/hooks/tg-exec
openclaw hooks enable tg-exec
openclaw gateway restart
openclaw configure --section web
openclaw gateway restart
Common Pitfalls and Fixes
pairing required / 1008
Approve pending device requests and role-upgrade before debugging anything else.
Unknown channel: telegram
Verify channels.telegram and plugins.entries.telegram in config.
deleteWebhook 404
Token is wrong/expired; validate with Telegram getMe first.
message read unsupported
Do not use cron polling for Telegram. Use hooks only.
Codex/Claude command not found
launchd may not inherit shell PATH. Use absolute binary paths.
Claude login issue
Run ~/.local/bin/claude, then execute interactive /login.
Current Capability Boundaries
Done
- Telegram remote ordering
- Ollama qwen3:8b local coordinator
- Codex/Claude CLI execution
- Telegram callback + local report auditing
- Brave Search + web_fetch
Next
- iMessage provider support (missing imsg)
- Cursor full integration into dispatch scripts
- Auto PR/commit with approval gate
- Parallel
codex+claudeorchestration and comparison - Repo allowlist and dangerous-command approvals
docs/OPENCLAW_RUNBOOK.md and attach a one-click self-check script for gateway, Telegram, hooks, allowlist, codex, and claude.