← Back to Plugins
Tools

Psam

Ryandawson2019 By Ryandawson2019 👁 57 views ▲ 0 votes

OpenClaw PSAM - Parallel Sub-Agent Orchestrator with intelligent task decomposition, model selection, and real-time progress tracking

GitHub

Install

npm install
npm

Configuration Example

parallel_subagent_orchestrator_orchestrate({
  task_description: "Analyze Q1 sales data and create summary reports",
  priority: "high",
  subtask_count: 3
})

README

# ๐Ÿš€ OpenClaw PSAM - Parallel Sub-Agent Orchestrator

[![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT)
[![Version](https://img.shields.io/badge/version-0.2.0-green.svg)](https://github.com/Ryandawson2019/openclaw-psam)
[![OpenClaw](https://img.shields.io/badge/OpenClaw-Plugin-orange.svg)](https://openclaw.ai)
[![TypeScript](https://img.shields.io/badge/TypeScript-Ready-blue.svg)](https://www.typescriptlang.org/)

> **Break down complex tasks into parallel sub-agents with intelligent model selection and real-time progress tracking**

An OpenClaw plugin that orchestrates multiple AI sub-agents to work on complex tasks in parallel, with smart model selection, persistent state tracking, and automated resource management.

**[็ฎ€ไฝ“ไธญๆ–‡ๆ–‡ๆกฃ](README.zh-CN.md)** | English

---

## โœจ Key Features

- ๐Ÿงฉ **Intelligent Task Decomposition** - Automatically break down complex tasks into manageable subtasks
- ๐ŸŽฏ **Smart Model Selection** - Choose optimal AI models based on task complexity and cost
- ๐Ÿ“Š **Real-time Progress Tracking** - Monitor all sub-agents with detailed status updates
- ๐Ÿ”„ **Persistent State Management** - Task states survive system restarts
- ๐Ÿ“ **Complete Activity Logging** - JSONL format logs for debugging and analysis
- ๐Ÿงน **Auto Resource Cleanup** - Automatic cleanup of old tasks and progress files
- โš™๏ธ **Dynamic Configuration** - Add/remove models and adjust settings at runtime

---

## ๐ŸŽฏ Quick Start

### Installation

1. **Navigate to your OpenClaw extensions directory:**
```bash
cd ~/.openclaw/extensions
```

2. **Clone or copy the plugin:**
```bash
git clone https://github.com/Ryandawson2019/openclaw-psam.git
# or
cp -r /path/to/openclaw-psam ~/.openclaw/extensions/
```

3. **Build the plugin:**
```bash
cd openclaw-psam
npm install
npm run build
```

4. **Restart OpenClaw:**
```bash
openclaw gateway restart
```

### Your First Orchestrated Task

**Via Tool Call:**
```javascript
parallel_subagent_orchestrator_orchestrate({
  task_description: "Analyze Q1 sales data and create summary reports",
  priority: "high",
  subtask_count: 3
})
```

**Via Natural Language (Recommended):**
```
Please help me analyze Q1 sales data in parallel and create summary reports, split into 3 subtasks
```

Or simply:
```
Help me analyze Q1 sales data in parallel, split into 3 subtasks
```

The plugin will:
1. โœ… Break down your task into 3 subtasks
2. โœ… Select optimal models for each subtask
3. โœ… Return execution instructions
4. โœ… Track progress of all sub-agents
5. โœ… Report results back to you

---

## ๐Ÿ“š Documentation

### Available Tools

#### 1. ๐ŸŽฌ `parallel_subagent_orchestrator_orchestrate`

Create and launch a new orchestrated task with multiple sub-agents.

**Parameters:**

| Parameter | Type | Required | Description |
|-----------|------|----------|-------------|
| `task_description` | `string` | โœ… | Clear description of what needs to be done |
| `priority` | `string` | โŒ | `high` \| `medium` \| `low` (default: medium) |
| `models` | `string` | โŒ | Comma-separated list of specific models to use |
| `subtask_count` | `number` | โŒ | Number of subtasks: 1-5 (default: 1) |

**Example:**
```json
{
  "task_description": "Research and summarize latest AI trends in 2024",
  "priority": "high",
  "subtask_count": 4
}
```

**Returns:**
- `task_id` - Unique identifier for tracking
- `subtasks` - Array of generated subtasks
- `spawn_instructions` - Ready-to-use execution commands

---

#### 2. ๐Ÿ“Š `parallel_subagent_orchestrator_orchestrate_status`

Query the current status of any orchestrated task or subtask.

**Parameters:**

| Parameter | Type | Required | Description |
|-----------|------|----------|-------------|
| `task` | `string` | โŒ | Filter by main task ID |
| `session` | `string` | โŒ | Filter by sub-agent session ID |
| `status_filter` | `string` | โŒ | `pending` \| `running` \| `completed` \| `failed` \| `aborted` |

**Examples:**
```javascript
// Get all tasks
{}

// Get specific task
{ "task": "task-abc-123" }

// Get only running tasks
{ "status_filter": "running" }
```

---

#### 3. โš™๏ธ `parallel_subagent_orchestrator_orchestrate_config`

Manage available AI models for task orchestration.

**Actions:** `list` | `add` | `remove` | `replace` | `reset` | `prefer`

**Examples:**
```javascript
// List all available models
{ "action": "list" }

// Add a new model
{
  "action": "add",
  "model_id": "anthropic/claude-sonnet-4-5"
}

// Set model preference with note
{
  "action": "prefer",
  "model_id": "anthropic/claude-sonnet-4-5",
  "note": "Best for complex reasoning tasks"
}

// Replace entire model list
{
  "action": "replace",
  "models": "anthropic/claude-sonnet-4-5,gemini-2.0-flash,gpt-4o-mini"
}

// Reset to default models
{ "action": "reset" }
```

---

#### 4. ๐Ÿ›‘ `parallel_subagent_orchestrator_orchestrate_abort`

Terminate a specific sub-agent session.

**Parameters:**

| Parameter | Type | Required | Description |
|-----------|------|----------|-------------|
| `session_id` | `string` | โœ… | The sub-agent session to terminate |

---

#### 5. ๐Ÿ’‰ `parallel_subagent_orchestrator_orchestrate_inject`

Send a message to a running sub-agent session.

**Parameters:**

| Parameter | Type | Required | Description |
|-----------|------|----------|-------------|
| `session_id` | `string` | โœ… | Target sub-agent session ID |
| `message` | `string` | โœ… | Message content to inject |

---

#### 6. ๐Ÿ“œ `parallel_subagent_orchestrator_orchestrate_history`

Retrieve message history from a sub-agent session.

**Parameters:**

| Parameter | Type | Required | Description |
|-----------|------|----------|-------------|
| `session_id` | `string` | โœ… | Sub-agent session ID |
| `include_tools` | `boolean` | โŒ | Include tool calls (default: false) |
| `limit` | `number` | โŒ | Max messages to return (default: 50) |

---

### Resource Management Tools

#### 7. โฐ `parallel_subagent_orchestrator_check_timeouts`

Identify and optionally abort long-running sub-agent sessions.

**Parameters:**

| Parameter | Type | Required | Description |
|-----------|------|----------|-------------|
| `timeout_minutes` | `number` | โŒ | Threshold in minutes, 5-1440 (default: 120) |
| `auto_abort` | `boolean` | โŒ | Auto-abort timed-out sessions (default: false) |

---

#### 8. ๐Ÿงน `parallel_subagent_orchestrator_cleanup`

Manual cleanup of old tasks, progress files, and zombie session detection.

**Parameters:**

| Parameter | Type | Required | Description |
|-----------|------|----------|-------------|
| `older_than_days` | `number` | โŒ | Delete tasks older than N days (default: 7) |
| `include_completed` | `boolean` | โŒ | Clean completed progress files (default: true) |
| `report_only` | `boolean` | โŒ | Preview without cleanup (default: false) |

---

## ๐ŸŽฏ Model Configuration

The plugin includes a **default model list** that works out of the box. You can customize models at runtime using the `orchestrate_config` tool.

### Default Models (Included)

| Model | Speed | Cost | Context | Best For |
|-------|--------|-------|----------|------------|
| `anthropic/claude-sonnet-4-5` | Medium | Medium | 200K | Complex reasoning, analysis |
| `anthropic/claude-haiku-4-5` | Fast | Low | 200K | Quick tasks, summaries |
| `gemini-2.0-flash` | Very Fast | Very Low | 1M | High-volume parallel tasks |
| `gemini-2.0-pro` | Medium | Medium | 2M | Advanced reasoning, coding |

**Note**: This is a **built-in default list**. You don't need to configure it unless you want to customize it.

---

## ๐Ÿ“‚ File Structure

```
openclaw-psam/
โ”œโ”€โ”€ state/
โ”‚   โ””โ”€โ”€ tasks.json           # Persistent task state
โ”œโ”€โ”€ logs/
โ”‚   โ””โ”€โ”€ task_activity.jsonl   # Activity log (JSONL format)
โ”œโ”€โ”€ models.json               # Model capabilities config (auto-created)
โ”œโ”€โ”€ config.json              # Plugin settings (optional)
โ”œโ”€โ”€ index.ts                 # Main plugin code
โ””โ”€โ”€ package.json
```

---

## โš™๏ธ Configuration

Create `config.json` in the plugin directory to customize behavior:

```json
{
  "enableAutoCleanup": true,
  "cleanupIntervalMs": 21600000,
  "sessionTimeoutMs": 7200000,
  "autoAbortTimeout": false
}
```

**Settings:**

| Setting | Type | Default | Required | Description |
|---------|------|----------|----------|-------------|
| `enableAutoCleanup` | boolean | `true` | โŒ | Enable periodic resource cleanup |
| `cleanupIntervalMs` | number | `21600000` | โŒ | Cleanup interval (6 hours) |
| `sessionTimeoutMs` | number | `7200000` | โŒ | Session timeout (2 hours) |
| `autoAbortTimeout` | boolean | `false` | โŒ | Auto-abort timed-out sessions |
| `wecomSenderSkillName` | string | `"wecom-sender"` | โŒ | **Optional**: Skill for notifications (requires wecom-sender plugin) |
| `monitoringAgentModel` | string | `"gemini-2.0-flash"` | โŒ | **Optional**: Model for status reports (must be available) |

**Notes:**
- All configuration fields are **optional** - the plugin works without any config
- `wecomSenderSkillName`: Only needed if you have the `wecom-sender` plugin installed and want notifications
- `monitoringAgentModel`: Only needed if you want to override the default monitoring model

---

## ๐Ÿ”„ Progress Reporting

Sub-agents report progress using `sessions_send` tool with formatted messages:

**Format:** `[PSAM-PROGRESS] subtask-id | Step N/M | Description`

**Examples:**
```
[PSAM-PROGRESS] sub-abc-123 | Step 2/5 | Analyzing user data...
[PSAM-PROGRESS] sub-abc-123 | Step 4/5 | Generating visualizations...
[PSAM-COMPLETE] sub-abc-123 | Result: Analysis complete, 3 insights found
[PSAM-FAILED] sub-xyz-789 | Reason: Data source unavailable
```

---

## ๐Ÿ“– Usage Examples

### Natural Language (Recommended)

You can simply describe what you need in plain language:

```
Please help me analyze this project's code and find potential security issues
```

```
Please research the latest AI frameworks in parallel and generate a comparison report
```

```
Help me analyze sales data, split into 3 subtasks
```

OpenClaw will automatically call the orchestrate t

... (truncated)
tools

Comments

Sign in to leave a comment

Loading comments...