← Back to Plugins
Voice

Intent Routing

EchoOfZion By EchoOfZion ⭐ 1 stars 👁 15 views ▲ 0 votes

Intent-based automatic routing plugin for OpenClaw โ€” classifies message complexity using local heuristics (zero LLM calls) and routes complex tasks to open-multi-agent running in AIO sandbox

GitHub

Install

npm install
npm

README

<p align="center">
  <img src="assets/logo.png" width="280" />
</p>

# OpenClaw Intent Routing

**Stop using one brain for every task.**

---

## The Problem

The OpenClaw ecosystem already has a wealth of harnesses โ€” Claude Code, Codex, Aider, open-multi-agent, ACPXโ€ฆ each excelling at different things.

But OpenClaw currently operates as **single-thread + single-harness path**: every message takes the same route, goes to the same harness, processed by the same model.

This leads to three direct consequences:

| Scenario | What happens | What should happen |
|----------|-------------|-------------------|
| User says "Hello" | Opus processes it, seconds of latency, heavy token cost | Lightweight model responds instantly, near-zero cost |
| User says "Translate this" | Full harness pipeline | Fast model returns directly |
| User says "Design the schema, then build the API, then write tests" | Single agent, serial execution, limited quality | Multi-agent parallel collaboration |

**Simple tasks are over-processed** โ€” wasting tokens. **Complex tasks are under-served** โ€” quality suffers. **Multiple harnesses sit idle** โ€” capabilities wasted.

The root cause: **no dispatch layer.**

---

## What This Plugin Does

It adds a dispatch layer to OpenClaw. It solves two things:

### 1. One-Click Multi-Harness Integration

Different harnesses have different runtime requirements โ€” some need Node.js, some depend on Docker, some communicate via MCP. Manually setting up the integration (pulling images, configuring ports, installing dependencies, registering backends) is a high barrier.

This plugin has built-in environment management:

```
Install plugin โ†’ Enable โ†’ On first complex task, auto-completes:

  Docker image pull โ†’ Container start โ†’ Health check โ†’
  open-multi-agent clone โ†’ Dependency install โ†’ Build โ†’
  ACP Backend registration โ†’ Ready
```

- **Docker container self-management** โ€” Auto-pulls AIO sandbox image, starts container, maps ports, continuous health monitoring
- **open-multi-agent self-deployment** โ€” Auto-clones repo, detects package manager, installs dependencies, builds
- **ACP Backend self-registration** โ€” Registers as a standard ACP runtime backend, seamless integration with existing system

No manual image pulls. No port configuration. No startup scripts.

### 2. Automatic Routing by Task Complexity

Once the environment is ready, before each message reaches a harness, the plugin uses pure local rules (**zero LLM calls, zero latency, zero extra tokens**) to classify and route:

```
User message โ†’ Intent classification (local < 1ms) โ†’ Routing decision
                                                      โ”œโ”€ Simple โ†’ Lightweight model (configurable)
                                                      โ”œโ”€ Complex โ†’ AIO sandbox / Multi-agent
                                                      โ””โ”€ Default โ†’ Original binding route (unchanged)
```

---

## Classification Rules

16 built-in rules covering English and Chinese, evaluated by priority:

**Complex task signals (priority 10):**

| Rule | Example matches |
|------|----------------|
| Sequential execution | "First do X, then do Y" |
| Numbered steps | "Step 1: ..." / "Phase 1: ..." |
| Stage planning | "Phase 1: design" / "Stage 2: implement" |
| Numbered lists | "1. Do X\n2. Do Y" |
| Collaboration language | "collaborate" / "coordinate" / "work together" |
| Parallel execution | "in parallel" / "concurrently" / "at the same time" |
| Multiple deliverables | "build X and then implement Y" |
| Chinese sequence markers | "first...then...finally..." patterns |

**Long message rule (priority 15):** Over 500 characters

**Simple task rule (priority 20):** Under 200 characters with no complexity signals

The rule engine supports four matcher types: `regex`, `keyword`, `length`, `negation` โ€” freely composable and extensible.

---

## Install

```bash
git clone https://github.com/EchoOfZion/openclaw-intent-routing.git
cd openclaw-intent-routing
npm install
npm run build
npm test
```

---

## Configuration

Add to `~/.openclaw/config.json5`:

```json5
{
  intentRouting: {
    enabled: true,

    // Routing rules
    routes: {
      "complex": {
        agentId: "orchestrator",
        executionMode: "acp",
        acpBackend: "aio-oma"
      },
      "simple": {
        modelOverride: "claude-3-5-haiku-20241022"
      }
    },

    // AIO sandbox (optional, defaults shown)
    aioSandbox: {
      baseUrl: "http://localhost:8330",
      autoStart: true,
      containerName: "openclaw-aio-sandbox"
    },

    // open-multi-agent (optional)
    openMultiAgent: {
      repoUrl: "https://github.com/JackChen-me/open-multi-agent.git",
      branch: "main"
    }
  }
}
```

To disable: set `enabled: false`. Zero side effects.

---

## Architecture

```
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚  User Message  โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
        โ”‚
        โ–ผ
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚  Intent Classifier (local)  โ”‚  โ† Zero LLM calls
โ”‚  16 built-in + custom rules โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
        โ”‚
        โ”œโ”€ simple โ”€โ”€โ†’ Model override (configurable) โ”€โ”€โ†’ Fast response
        โ”‚
        โ”œโ”€ complex โ”€โ†’ AIO Sandbox โ”€โ”€โ†’ open-multi-agent โ”€โ”€โ†’ Multi-agent collaboration
        โ”‚                 โ”‚
        โ”‚                 โ”œโ”€ Docker auto-management
        โ”‚                 โ”œโ”€ OMA auto-deployment
        โ”‚                 โ””โ”€ ACP Backend registration
        โ”‚
        โ””โ”€ default โ”€โ”€โ†’ Original binding route (unchanged)
```

**Modules:**

| Module | Responsibility |
|--------|---------------|
| `intent-classifier` | Message classification engine, pure sync, no side effects |
| `intent-router` | Classification โ†’ routing decision mapping |
| `aio-manager` | AIO sandbox Docker lifecycle management |
| `oma-installer` | open-multi-agent auto-install and build |
| `aio-backend` | ACP runtime backend implementation |
| `index` | Plugin entry point, hook registration |

---

## Project Structure

```
โ”œโ”€โ”€ openclaw.plugin.json          # Plugin manifest + config schema
โ”œโ”€โ”€ package.json
โ”œโ”€โ”€ tsconfig.json
โ”œโ”€โ”€ skills/
โ”‚   โ””โ”€โ”€ intent-router/
โ”‚       โ””โ”€โ”€ SKILL.md              # Agent instructions
โ””โ”€โ”€ src/
    โ”œโ”€โ”€ index.ts                  # Plugin entry
    โ”œโ”€โ”€ index.test.ts
    โ”œโ”€โ”€ integration-test.ts       # End-to-end integration tests
    โ”œโ”€โ”€ routing/
    โ”‚   โ”œโ”€โ”€ intent-classifier.ts  # Classification engine (16 rules)
    โ”‚   โ”œโ”€โ”€ intent-classifier.test.ts
    โ”‚   โ”œโ”€โ”€ intent-router.ts      # Route mapping
    โ”‚   โ””โ”€โ”€ intent-router.test.ts
    โ”œโ”€โ”€ sandbox/
    โ”‚   โ”œโ”€โ”€ aio-manager.ts        # AIO sandbox management
    โ”‚   โ”œโ”€โ”€ aio-manager.test.ts
    โ”‚   โ”œโ”€โ”€ oma-installer.ts      # OMA auto-installer
    โ”‚   โ””โ”€โ”€ oma-installer.test.ts
    โ””โ”€โ”€ backend/
        โ”œโ”€โ”€ aio-backend.ts        # ACP runtime backend
        โ””โ”€โ”€ aio-backend.test.ts
```

---

## Testing

```bash
# Unit tests (158)
npm test

# Integration tests (requires running AIO sandbox)
npx tsx src/integration-test.ts [baseUrl]
```

---

## Custom Rules

Add custom classification rules via config:

```json5
{
  intentRouting: {
    enabled: true,
    routing: {
      customRules: [
        {
          id: "custom:deploy",
          category: "complex",
          priority: 5,
          matchers: [
            { type: "keyword", keywords: ["deploy", "rollback", "migration"] }
          ]
        }
      ]
    }
  }
}
```

Rules are evaluated by `priority` (ascending). First rule where all matchers pass wins.

---

## Key Features

- **Zero LLM calls** โ€” Classification is entirely local, no token cost, no added latency
- **Lightweight** โ€” < 2500 lines of code (including tests), no runtime dependencies
- **Low intrusion** โ€” Plugin-based, does not modify OpenClaw core, disable to revert
- **One-click ready** โ€” Docker + OMA environment fully auto-provisioned
- **Fully configurable** โ€” Rules, routes, models all customizable
- **Well tested** โ€” 158 unit tests + 9 integration tests, verified on real AIO sandbox

---

## Docker & Remote Sandbox

The plugin auto-detects your Docker environment:

| Situation | What happens |
|-----------|-------------|
| Docker installed and running | Container auto-starts, zero manual steps |
| Docker installed but not running | Clear error: "Start Docker Desktop or run `sudo systemctl start docker`" |
| Docker not installed | Clear error with install link + remote sandbox alternative |

**No Docker? No problem.** Point to a remote AIO sandbox instead:

```json5
{
  aioSandbox: {
    baseUrl: "http://your-server:8330",   // remote sandbox address
    autoStart: false                       // skip local Docker
  }
}
```

Simple task routing (model override) works without Docker โ€” it only needs Docker when routing complex tasks to AIO sandbox.

---

## Compatibility

- OpenClaw pluginApi >= 2026.3.24-beta.2
- Node.js >= 22
- Docker (local AIO sandbox) or a remote AIO sandbox URL

---

---

<p align="center">
  <img src="assets/logo.png" width="280" />
</p>

# OpenClaw Intent Routing

**่ฎฉไฝ ็š„ Agent ไธๅ†็”จๅŒไธ€ไธช่„‘ๅญๅšๆ‰€ๆœ‰ไบ‹**

---

## ้—ฎ้ข˜

OpenClaw ็”Ÿๆ€ๅทฒ็ปๆœ‰ไบ†ๅคง้‡ไผ˜็ง€็š„ Harness โ€”โ€” Claude Codeใ€Codexใ€Aiderใ€open-multi-agentใ€ACPXโ€ฆโ€ฆ ๅฎƒไปฌๆ“…้•ฟไธๅŒ็š„ไบ‹ๆƒ…ใ€‚

ไฝ† OpenClaw ๅฝ“ๅ‰ๆ˜ฏ **ๅ•็บฟ็จ‹ + ๅ• Harness ่ทฏๅพ„**๏ผšๆ‰€ๆœ‰ๆถˆๆฏ่ตฐๅŒไธ€ๆก่ทฏ็”ฑ๏ผŒๅ‘็ป™ๅŒไธ€ไธช Harness๏ผŒ็”จๅŒไธ€ไธชๆจกๅž‹ๅค„็†ใ€‚

่ฟ™ๅธฆๆฅไธ‰ไธช็›ดๆŽฅๅŽๆžœ๏ผš

| ๅœบๆ™ฏ | ๅ‘็”Ÿไบ†ไป€ไนˆ | ๆœฌ่ฏฅๆ€Žๆ ท |
|------|-----------|---------|
| ็”จๆˆท่ฏด "ไฝ ๅฅฝ" | Opus ๅค„็†๏ผŒๆ•ฐ็ง’ๅ“ๅบ”๏ผŒๆถˆ่€—ๅคง้‡ token | ่ฝป้‡ๆจกๅž‹ๆฏซ็ง’็บง่ฟ”ๅ›ž๏ผŒๅ‡ ไนŽ้›ถๆˆๆœฌ |
| ็”จๆˆท่ฏด "็ฟป่ฏ‘่ฟ™ๆฎต่ฏ" | ๅฎŒๆ•ด Harness ๆต็จ‹ | ๅฟซ้€Ÿๆจกๅž‹็›ดๆŽฅๅฎŒๆˆ |
| ็”จๆˆท่ฏด "ๅ…ˆ่ฎพ่ฎก schema๏ผŒๅ†ๅ†™ API๏ผŒๆœ€ๅŽๅ†™ๆต‹่ฏ•" | ๅ• Agent ไธฒ่กŒๅค„็†๏ผŒ่ดจ้‡ๅ—้™ | ๅคš Agent ๅนถ่กŒๅไฝœ๏ผŒๅ„ๅธๅ…ถ่Œ |

**็ฎ€ๅ•ไปปๅŠก่ขซ่ฟ‡ๅบฆๅค„็†** โ€”โ€” ๆตช่ดน tokenใ€‚**ๅคๆ‚ไปปๅŠกๅค„็†่ƒฝๅŠ›ไธ่ถณ** โ€”โ€” ่ดจ้‡ๆ‰“ๆŠ˜ใ€‚**ๅคšไธช Harness ๆ— ๆณ•ๅๅŒ** โ€”โ€” ่ƒฝๅŠ›่ขซ้—ฒ็ฝฎใ€‚

ๆœฌ่ดจ้—ฎ้ข˜๏ผš**ๆฒกๆœ‰่ฐƒๅบฆๅฑ‚ใ€‚**

---

## ่ฟ™ไธชๆ’ไปถๅšไป€ไนˆ

็ป™ OpenClaw ๅŠ ไธ€ไธช่ฐƒๅบฆๅฑ‚ใ€‚่งฃๅ†ณไธคไปถไบ‹๏ผš

### 1. ๅคš Harness ไธ€้”ฎๆŽฅๅ…ฅ

ไธๅŒ็š„ Harness ่ฟ่กŒ็Žฏๅขƒๅ„ๅผ‚ โ€”โ€” ๆœ‰็š„้œ€่ฆ Node.js๏ผŒๆœ‰็š„ไพ่ต– Docker๏ผŒๆœ‰็š„่ตฐ MCP ๅ่ฎฎใ€‚ๆ‰‹ๅŠจๆญๅปบๆŽฅๅ…ฅๆต็จ‹๏ผˆๆ‹‰้•œๅƒใ€้…็ซฏๅฃใ€่ฃ…ไพ่ต–ใ€ๆณจๅ†Œ backend๏ผ‰้—จๆง›ๅพˆ้ซ˜ใ€‚

ๆœฌๆ’ไปถๅ†…็ฝฎไบ†ๅฎŒๆ•ด็š„็Žฏๅขƒ็ฎก็†๏ผš

```
ๅฎ‰่ฃ…ๆ’ไปถ โ†’ ๅฏ็”จ โ†’ ้ฆ–ๆฌก้‡ๅˆฐๅคๆ‚ไปปๅŠกๆ—ถ่‡ชๅŠจๅฎŒๆˆ๏ผš

  Docker ้•œๅƒๆ‹‰ๅ– โ†’ ๅฎนๅ™จๅฏๅŠจ โ†’ ๅฅๅบทๆฃ€ๆŸฅ โ†’
  open-multi-agent ๅ…‹้š† โ†’ ไพ่ต–ๅฎ‰่ฃ… โ†’ ๆž„ๅปบ โ†’
  ACP Backend ๆณจๅ†Œ โ†’ ๅฐฑ็ปช
```

- **Docker ๅฎนๅ™จ่‡ช็ฎก็†** โ€”โ€” ่‡ชๅŠจๆ‹‰ๅ– AIO ๆฒ™็ฎฑ้•œๅƒใ€ๅฏๅŠจใ€็ซฏๅฃๆ˜ ๅฐ„ใ€ๆŒ็ปญๅฅๅบท็›‘ๆŽง
- **open-multi-agent ่‡ช้ƒจ็ฝฒ** โ€”โ€” ่‡ชๅŠจๅ…‹้š†ใ€ๆฃ€ๆต‹ๅŒ…็ฎก็†ๅ™จใ€ๅฎ‰่ฃ…ไพ่ต–ใ€ๆž„ๅปบ
- **ACP Backend ่‡ชๆณจๅ†Œ** โ€”โ€” ๆณจๅ†Œไธบๆ ‡ๅ‡† ACP ่ฟ่กŒๆ—ถๅŽ็ซฏ๏ผŒไธŽ็Žฐๆœ‰ไฝ“็ณปๆ— ็ผ้›†ๆˆ

ไฝ ไธ้œ€่ฆๆ‰‹ๅŠจๆ‹‰้•œๅƒ๏ผŒไธ้œ€่ฆ้…็ซฏๅฃ๏ผŒไธ้œ€่ฆๅ†™ๅฏๅŠจ่„šๆœฌใ€‚

### 2. ๆŒ‰ไปปๅŠกๅคๆ‚ๅบฆ่‡ชๅŠจ่ทฏ็”ฑ

็Žฏๅขƒๅฐฑ็ปชๅŽ๏ผŒๆฏๆกๆถˆๆฏๅˆฐ่พพ Harness ไน‹ๅ‰

... (truncated)
voice

Comments

Sign in to leave a comment

Loading comments...