← Back to Plugins
Tools

Org

itomtangme By itomtangme 👁 105 views ▲ 0 votes

Hierarchical multi-agent architecture framework with automated enforcement for OpenClaw. Skill + Plugin bundle: agents understand the hierarchy AND it's auto-enforced on workspace files.

GitHub

Configuration Example

{
  "plugins": {
    "allow": ["architecture-enforcer"],
    "config": {
      "architecture-enforcer": {
        "dryRun": false,
        "forceOverwrite": false,
        "skipAgents": ["my-special-agent"]
      }
    }
  }
}

README

# ๐Ÿ›๏ธ OpenClaw Subagent Architecture

Hierarchical multi-agent architecture framework with **automated enforcement** for [OpenClaw](https://openclaw.com).

> **Skill + Plugin bundle**: Agents *understand* the hierarchy (skill) AND it's *auto-enforced* (plugin).

## The Problem

OpenClaw supports multiple agents, but when you add a new one, nothing automatically:
- Tells it who its parent agent is
- Sets its layer/depth/tier in SOUL.md
- Creates AGENTS.md with the hierarchy registry format
- Creates AGENT-MANIFEST.md with escalation policies
- Updates the central org registry

You end up with agents that don't know their place in the hierarchy.

## The Solution

This package combines:

| Component | What It Does |
|-----------|-------------|
| **Skill** | Agents read the architecture spec, understand layers/protocols/delegation |
| **Plugin** | Gateway hooks auto-write hierarchy files when agents are added or on startup |

## Features

- ๐Ÿ—๏ธ **6-Layer Hierarchy** โ€” L0 Orchestrator โ†’ L1 Director โ†’ L2 Manager โ†’ L3 Specialist โ†’ L4 Operator โ†’ L5 Worker
- ๐Ÿ”„ **Auto-Enforcement** โ€” patches SOUL.md, AGENTS.md, AGENT-MANIFEST.md on gateway start and agent spawn
- ๐Ÿง  **Smart SOUL.md Patching** โ€” injects hierarchy section without destroying custom persona content
- ๐Ÿ›ก๏ธ **Idempotent** โ€” only writes when files are missing or incorrect
- ๐Ÿ“Š **4-Tier Model System** โ€” cost-efficient model allocation per layer
- ๐Ÿ”Œ **Plug-and-Play Departments** โ€” add/remove domain directors anytime
- ๐Ÿ“ˆ **Observability** โ€” STATUS.md dashboard, heartbeat protocol
- ๐Ÿงฉ **Result Caching** โ€” shared cache prevents redundant work across branches

## Quick Start

### 1. Clone
```bash
git clone https://github.com/itomtangme/openclaw-org.git \
  ~/.openclaw/skills/openclaw-org
```

### 2. Symlink plugin
```bash
ln -s ~/.openclaw/skills/openclaw-org \
  ~/.openclaw/workspace/plugins/architecture-enforcer
```

### 3. Enable
```bash
openclaw config set plugins.allow '["architecture-enforcer"]'
openclaw gateway restart
```

That's it. The plugin will audit all agent workspaces on startup and patch any missing hierarchy files.

## How It Works

```
openclaw.json (agents.list + subagents.allowAgents)
        โ”‚
        โ–ผ
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚  Hierarchy Resolution       โ”‚
โ”‚  Derive parent/child/layer  โ”‚
โ”‚  from config relationships  โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
           โ”‚
           โ–ผ
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚  Per-Agent Enforcement      โ”‚
โ”‚  Check workspace files      โ”‚
โ”‚  Write missing/incorrect    โ”‚
โ”‚  Preserve custom content    โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
           โ”‚
           โ–ผ
    workspace-<agent>/
    โ”œโ”€โ”€ SOUL.md         (hierarchy section injected)
    โ”œโ”€โ”€ AGENTS.md       (v2.2 registry format)
    โ””โ”€โ”€ AGENT-MANIFEST.md (parent, capabilities, escalation)
```

### Hierarchy Resolution

The plugin reads `openclaw.json` and derives hierarchy:
- `agents.list[].id` โ†’ agent identity
- `agents.list[].subagents.allowAgents` โ†’ parentโ†’child relationships
- `main` = L0, `sysadmin`/`full-power` = L1-C (by convention)
- Depth = walk parent chain โ†’ determines layer (L1-D, L2, L3, etc.)

### Enforcement Triggers

| Trigger | Scope |
|---------|-------|
| Gateway starts | All agent workspaces |
| Sub-agent spawned | Newly spawned agent |
| `/enforce` command | All or specific agent |
| CLI `enforce-architecture` | Scriptable, supports `--dry-run` |

## Architecture Overview

```
L0  Orchestrator (main) โ€” CEO, routes & synthesizes
โ”œโ”€โ”€ L1-C  Core: sysadmin โ€” CTO, manages OpenClaw itself
โ”œโ”€โ”€ L1-C  Core: full-power โ€” Emergency override
โ”œโ”€โ”€ L1-D  Department Director (pluggable)
โ”‚   โ”œโ”€โ”€ L2  Manager
โ”‚   โ”‚   โ”œโ”€โ”€ L3  Specialist
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ L4  Operator
โ”‚   โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ L5  Worker (ephemeral)
```

### Model Tiers

| Tier | Layer | Purpose |
|------|-------|---------|
| Tier-1 | L0, L1 | Max intelligence (Opus/GPT-5) |
| Tier-2 | L1-D, L2 | Strong (Sonnet/Gemini Pro) |
| Tier-3 | L3, L4 | Fast (Flash/Haiku) |
| Tier-4 | L4, L5 | Cheapest |

**Rule**: Children inherit or downgrade tier. Never upgrade beyond parent.

## Configuration

```json
{
  "plugins": {
    "allow": ["architecture-enforcer"],
    "config": {
      "architecture-enforcer": {
        "dryRun": false,
        "forceOverwrite": false,
        "skipAgents": ["my-special-agent"]
      }
    }
  }
}
```

| Option | Type | Default | Description |
|--------|------|---------|-------------|
| `dryRun` | boolean | `false` | Log changes without writing |
| `forceOverwrite` | boolean | `false` | Overwrite even if v2.2 markers present |
| `skipAgents` | string[] | `[]` | Agent IDs to exclude from enforcement |
| `templateDir` | string | auto | Custom template directory path |

## Commands

### Slash Commands
```
/enforce              โ€” Full audit of all agents
/enforce planner      โ€” Enforce specific agent
```

### CLI
```bash
openclaw plugins cli architecture-enforcer enforce-architecture
openclaw plugins cli architecture-enforcer enforce-architecture --dry-run
openclaw plugins cli architecture-enforcer enforce-architecture --agent planner
openclaw plugins cli architecture-enforcer enforce-architecture --force
```

## File Structure

```
openclaw-org/
โ”œโ”€โ”€ package.json                    # Plugin entry + metadata
โ”œโ”€โ”€ openclaw.plugin.json            # OpenClaw plugin manifest
โ”œโ”€โ”€ plugin/
โ”‚   โ”œโ”€โ”€ index.ts                    # Lifecycle hooks & commands
โ”‚   โ””โ”€โ”€ src/
โ”‚       โ””โ”€โ”€ enforcer.ts             # Core enforcement engine
โ”œโ”€โ”€ skill/
โ”‚   โ”œโ”€โ”€ SKILL.md                    # Skill entry point
โ”‚   โ”œโ”€โ”€ assets/templates/           # Workspace file templates
โ”‚   โ”‚   โ”œโ”€โ”€ SOUL-template.md
โ”‚   โ”‚   โ”œโ”€โ”€ AGENTS-template.md
โ”‚   โ”‚   โ”œโ”€โ”€ MANIFEST-template.md
โ”‚   โ”‚   โ””โ”€โ”€ STATUS-template.md
โ”‚   โ””โ”€โ”€ references/
โ”‚       โ””โ”€โ”€ ARCHITECTURE.md         # Complete v2.2 specification
โ”œโ”€โ”€ docs/
โ”‚   โ””โ”€โ”€ DESIGN.md                   # Design rationale
โ”œโ”€โ”€ README.md
โ””โ”€โ”€ LICENSE
```

## Prior Art

This package supersedes [openclaw-architecture](https://github.com/itomtangme/openclaw-architecture) (skill-only, no enforcement). If you're using the old skill, migrate to this one for automated enforcement.

## License

MIT
tools

Comments

Sign in to leave a comment

Loading comments...