openclaw - ๐Ÿ’ก(How to fix) Fix [Feature]: Unixsocket Provider plugin

Official PRs (โ€ฆ)
ON THIS PAGE

Recommended Tools

ร—6

Utilities matched from this issueโ€™s tags and category โ€” try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful ยท Quick feedback

Loadingโ€ฆ

Add a new unixsocket provider plugin (extensions/unixsocket/) that implements the provider contract via createStreamFn, replacing HTTP with direct Unix Socket communication

Error Message

  • Chinese-friendly validation error messages for invalid socketPath
  • Socket error guard (prevents uncaught 'error' crash)

Root Cause

DimensionDetail
Affected usersAll mobile/edge device users who want to run OpenClaw gateway with local on-device models. Also affects llama.cpp and embedded daemon users who rely on UDS transport.
Affected systemsMobile phones (ARM64, Android/HarmonyOS), embedded devices, edge gateways running local AI daemons over Unix Domain Socket.
SeverityBlocks workflow โ€” OpenClaw cannot be used at all on platforms that prohibit HTTP model calls. The gateway simply cannot communicate with the local model daemon.
FrequencyAlways โ€” 100% of requests to Unix Socket daemons fail because there is no transport path. This is not intermittent; it's a missing capability.
ConsequenceUsers are forced to either (a) run a separate HTTP proxy layer between the daemon and OpenClaw, adding latency and complexity, or (b) abandon OpenClaw entirely in favor of custom solutions. This blocks adoption on mobile platforms where local inference is the only viable option.

Code Example

Agent.streamFn()
  โ†’ registerProviderStreamForModel()
    โ†’ resolveProviderStreamFn()
      โ†’ plugin.createStreamFn(ctx)  โ† returns custom StreamFn
        โ†’ connectSocket() โ†’ encodeFrame() โ†’ socket.write()
        โ†’ readFrame() โ†’ JSON.parse โ†’ handleStreaming()
        โ†’ push text_delta/toolcall_delta/done events

---

{
  "models": {
    "providers": {
      "unixsocket": {
        "api": "openai-completions",
        "params": {
          "socketPath": "/var/run/ai-daemon.sock",
          "modelId": "local-model",
          "connectTimeoutMs": 10000,
          "readTimeoutMs": 120000,
          "maxRetries": 3
        }
      }
    }
  }
}

---

extensions/unixsocket/
โ”œโ”€โ”€ index.ts          # plugin entry, definePluginEntry()
โ”œโ”€โ”€ api.ts            # public API surface
โ”œโ”€โ”€ runtime-api.ts    # runtime API surface
โ”œโ”€โ”€ openclaw.plugin.json  # manifest
โ”œโ”€โ”€ src/
โ”‚   โ”œโ”€โ”€ frame.ts      # frame codec + auto-detection
โ”‚   โ”œโ”€โ”€ stream.ts     # custom StreamFn (core)
โ”‚   โ”œโ”€โ”€ transport.ts  # socket connect/retry
โ”‚   โ”œโ”€โ”€ models.ts     # model config resolution + validation
โ”‚   โ”œโ”€โ”€ runtime.ts    # config value resolvers
โ”‚   โ”œโ”€โ”€ setup.ts      # setup wizard + catalog
โ”‚   โ””โ”€โ”€ defaults.ts   # shared constants
โ””โ”€โ”€ test/             # 53 tests across 5 test files
RAW_BUFFERClick to expand / collapse

Summary

Add a new unixsocket provider plugin (extensions/unixsocket/) that implements the provider contract via createStreamFn, replacing HTTP with direct Unix Socket communication

Problem to solve

1. Mobile platforms are blocking HTTP model calls

More and more mobile OS vendors (Android, HarmonyOS, etc.) are enforcing strict network policies that prohibit AI model inference over HTTP on-device. This makes it impossible to use OpenClaw's existing HTTP-based providers (ollama, lmstudio, vllm) to call models running locally on phones.

2. On-device models are the future

Running models directly on-device offers major advantages over cloud-based inference:

BenefitDescription
Privacy & securityData never leaves the device โ€” conversations, files, and images are processed locally. No cloud upload, no data leakage, stronger compliance.
Offline capableWorks without internet connectivity โ€” no cellular, no Wi-Fi, no base station required.
Faster responseZero network round-trip latency. Local compute delivers smoother interaction.
Cost efficientNo API call fees, no data egress charges. Zero per-call cost long-term.
Full controlCustomize model versions, parameters, and behavior without platform restrictions or API lock-in.
Low-latency interactionReal-time conversation, local plugin integration, streaming output โ€” ideal for device-local workflows.

As on-device compute grows more capable, we expect an explosion of local model deployments.

3. On-device daemons use Unix Socket โ€” but OpenClaw doesn't support it

The vast majority of on-device AI daemons communicate over Unix Domain Socket (UDS) with raw JSON โ€” not HTTP. This is the natural IPC choice for local services: zero network stack overhead, filesystem-based access control, no port conflicts.

However, OpenClaw's provider transport layer is entirely HTTP-based. There is no way to connect to:

  • On-device model daemons on phones / edge devices that expose a Unix socket
  • llama.cpp in its UDS mode
  • Ollama early UDS mode
  • Custom embedded daemons that skip HTTP for latency and security reasons

This gap blocks OpenClaw from being used as the agent gateway on mobile devices with local AI inference.

Proposed solution

How it works

Agent.streamFn()
  โ†’ registerProviderStreamForModel()
    โ†’ resolveProviderStreamFn()
      โ†’ plugin.createStreamFn(ctx)  โ† returns custom StreamFn
        โ†’ connectSocket() โ†’ encodeFrame() โ†’ socket.write()
        โ†’ readFrame() โ†’ JSON.parse โ†’ handleStreaming()
        โ†’ push text_delta/toolcall_delta/done events

The plugin auto-detects two response formats without configuration:

  • Binary frame: [4B big-endian length header][UTF-8 JSON]
  • Newline-delimited JSON: {json}\n (used by llama.cpp and others)

It also supports both streaming (choices[0].delta) and non-streaming (choices[0].message) responses.

Config surface

{
  "models": {
    "providers": {
      "unixsocket": {
        "api": "openai-completions",
        "params": {
          "socketPath": "/var/run/ai-daemon.sock",
          "modelId": "local-model",
          "connectTimeoutMs": 10000,
          "readTimeoutMs": 120000,
          "maxRetries": 3
        }
      }
    }
  }
}

Features

  • Retry with exponential backoff on connection failure
  • Auto-truncation of context + tools for small-context-window models (4K)
  • Hot-reload support (re-reads config from disk at request time)
  • Chinese-friendly validation error messages for invalid socketPath
  • Streaming + non-streaming auto-detection
  • Socket error guard (prevents uncaught 'error' crash)

Plugin architecture

Follows the standard bundled provider pattern (similar to ollama/lmstudio):

extensions/unixsocket/
โ”œโ”€โ”€ index.ts          # plugin entry, definePluginEntry()
โ”œโ”€โ”€ api.ts            # public API surface
โ”œโ”€โ”€ runtime-api.ts    # runtime API surface
โ”œโ”€โ”€ openclaw.plugin.json  # manifest
โ”œโ”€โ”€ src/
โ”‚   โ”œโ”€โ”€ frame.ts      # frame codec + auto-detection
โ”‚   โ”œโ”€โ”€ stream.ts     # custom StreamFn (core)
โ”‚   โ”œโ”€โ”€ transport.ts  # socket connect/retry
โ”‚   โ”œโ”€โ”€ models.ts     # model config resolution + validation
โ”‚   โ”œโ”€โ”€ runtime.ts    # config value resolvers
โ”‚   โ”œโ”€โ”€ setup.ts      # setup wizard + catalog
โ”‚   โ””โ”€โ”€ defaults.ts   # shared constants
โ””โ”€โ”€ test/             # 53 tests across 5 test files

Alternatives considered

No response

Impact

DimensionDetail
Affected usersAll mobile/edge device users who want to run OpenClaw gateway with local on-device models. Also affects llama.cpp and embedded daemon users who rely on UDS transport.
Affected systemsMobile phones (ARM64, Android/HarmonyOS), embedded devices, edge gateways running local AI daemons over Unix Domain Socket.
SeverityBlocks workflow โ€” OpenClaw cannot be used at all on platforms that prohibit HTTP model calls. The gateway simply cannot communicate with the local model daemon.
FrequencyAlways โ€” 100% of requests to Unix Socket daemons fail because there is no transport path. This is not intermittent; it's a missing capability.
ConsequenceUsers are forced to either (a) run a separate HTTP proxy layer between the daemon and OpenClaw, adding latency and complexity, or (b) abandon OpenClaw entirely in favor of custom solutions. This blocks adoption on mobile platforms where local inference is the only viable option.

Evidence/examples

No response

Additional information

No response

Vote matrix ยท Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loadingโ€ฆ

Still need to ship something?

ร—6

Another batch ranked right after the header list โ€” different links, same matching logic.

Back to top recommendations

TRENDING