返回顶部
a

agent-swarm智能代理集群

IMPORTANT: OpenRouter is required. Routes tasks to the right model and always delegates work through sessions_spawn. Rejects prompt-injection patterns in task strings (v1.7.6+).

作者: admin | 来源: ClawHub
源自
ClawHub
版本
V 1.7.19
安全检测
已通过
2,007
下载量
免费
免费
3
收藏
概述
安装方式
版本历史

agent-swarm

Agent Swarm | OpenClaw Skill

Description

IMPORTANT: OpenRouter is required. Routes tasks to the right model and always delegates work through sessions_spawn.

Before installing

  • - OPENCLAW_HOME: Not required. The skill uses OPENCLAW_HOME only if set; otherwise it defaults to ~/.openclaw. This is consistent in both metadata (_meta.json: listed in optionalEnv, not in env) and behavior.
  • openclaw.json read access: The skill reads the local file openclaw.json (at $OPENCLAW_HOME/openclaw.json or ~/.openclaw/openclaw.json). Only the fields tools.exec.host and tools.exec.node are used; no gateway secrets or API keys are read. Verify you are comfortable granting read access to that file before installing.

Examples

Single task

Router output:
INLINECODE10

Then call:
INLINECODE11

Parallel tasks

CODEBLOCK0

This returns multiple spawn configs. Start one sub-agent per config.

Commands

Manual/CLI use only. The examples below pass the task as a single argument; for programmatic use with untrusted user input, always invoke the router via subprocess.run(..., [..., user_message], ...) with a list of arguments (see Security). Do not build a shell command string from user input.

CODEBLOCK1

What this skill does

Agent Swarm is a traffic cop for AI models.
It picks the best model for each task, then starts a sub-agent to do the work.

IMPORTANT: OpenRouter is required

Required Platform Configuration:

  • - OpenRouter API key: Must be configured in OpenClaw platform settings (not provided by this skill)
  • OPENCLAW_HOME (optional): Environment variable pointing to OpenClaw workspace root. If not set, defaults to INLINECODE13
  • openclaw.json access: The router reads tools.exec.host and tools.exec.node from openclaw.json (located at $OPENCLAW_HOME/openclaw.json or ~/.openclaw/openclaw.json). Only these two fields are accessed; no gateway secrets or API keys are read.

Model Requirements:

  • - Model IDs must use openrouter/... prefix
  • If OpenRouter is not configured in OpenClaw, delegation will fail

Why this helps

  • - Faster replies (cheap orchestrator, smart sub-agent routing)
  • Better quality (code tasks go to code models, writing tasks go to writing models)
  • Lower cost (you do not run every task on the most expensive model)

Core rule (non-negotiable)

For user tasks, the orchestrator must delegate.
It must NOT answer the task itself.

Use this flow every time:

  1. 1. Run router. From orchestrator code, use subprocess with a list of arguments (never shell interpolation with user input):
   import subprocess
   result = subprocess.run(
       ["python3", "/path/to/workspace/skills/agent-swarm/scripts/router.py", "spawn", "--json", user_message],
       capture_output=True,
       text=True
   )
   data = json.loads(result.stdout) if result.returncode == 0 else {}
   
CLI only (manual testing; do not use from code with untrusted user input): python3 workspace/skills/agent-swarm/scripts/router.py spawn --json "your task here" Use OPENCLAW_HOME or absolute path for the script when not in workspace root.
  1. 2. If needs_config_patch is true: stop and report that patch to the user.
  2. Otherwise call:
sessions_spawn(task=..., model=..., sessionTarget=...)
  1. 4. Wait for sessions_spawn result.
  2. Return the sub-agent result to the user.

If sessions_spawn fails, return only a delegation failure message.
Do not do the task yourself.

Config basics

Edit config.json in the skill root (parent of scripts/) to change routing.

What you can change

WhatKeyPurpose
Orchestrator / session defaultINLINECODE28Main agent and new sessions (e.g. Gemini 2.5 Flash)
Task-specific model per tier
routing_rules.<TIER>.primary | Model used when a task matches that tier | | Backup models if primary fails | routing_rules.<TIER>.fallback | Array of model IDs to try next |

All task-specific tiers (change the model for each)

TierKey to change primaryTypical use
FASTINLINECODE31Simple tasks: check, list, status, fetch
REASONING
routing_rules.REASONING.primary | Logic, math, step-by-step analysis | | CREATIVE | routing_rules.CREATIVE.primary | Writing, stories, UI/UX, design | | RESEARCH | routing_rules.RESEARCH.primary | Research, search, fact-finding | | CODE | routing_rules.CODE.primary | Code, debug, refactor, implement | | QUALITY | routing_rules.QUALITY.primary | Complex/architecture tasks | | COMPLEX | routing_rules.COMPLEX.primary | Multi-step / complex system tasks | | VISION | routing_rules.VISION.primary | Image analysis, screenshots, visual |

To change all task-specific models: edit each routing_rules.<TIER>.primary above. Use model IDs from the models array in config.json (must start with openrouter/).

Simple config examples

Orchestrator only (keep defaults for tiers):

{
  "default_model": "openrouter/google/gemini-2.5-flash"
}

(Other keys like routing_rules and models can stay as in the shipped config.json.)

Change one tier (e.g. CODE to MiniMax):
CODEBLOCK4

Change multiple tiers (primaries only):

"routing_rules": {
  "CREATIVE": { "primary": "openrouter/moonshotai/kimi-k2.5", "fallback": [] },
  "CODE":     { "primary": "openrouter/z-ai/glm-4.7-flash", "fallback": ["openrouter/minimax/minimax-m2.5"] },
  "RESEARCH": { "primary": "openrouter/x-ai/grok-4.1-fast", "fallback": [] }
}

Only include tiers you want to override; the rest are read from the full config.json.

Security

Input Validation

The router validates and sanitizes all inputs to prevent injection attacks:

  • - Task strings: Validated for length (max 10KB), null bytes; rejects prompt-injection patterns (script tags, javascript: protocol, event-handler attributes). Invalid tasks raise ValueError with a clear message.
  • Config patches: Only allows modifications to tools.exec.host and tools.exec.node (whitelist approach)
  • Labels: Validated for length and null bytes

Safe Execution

Critical: When calling router.py from orchestrator code, always use subprocess with a list of arguments, never shell string interpolation:

CODEBLOCK6

The router uses Python's argparse, which safely handles arguments when passed as a list. Shell string interpolation is vulnerable to command injection if the user message contains shell metacharacters.

Config Patch Safety

The recommended_config_patch only modifies safe fields:

  • - tools.exec.host (must be 'sandbox' or 'node')
  • INLINECODE56 (only when host is 'node')

All config patches are validated before being returned. The orchestrator should validate patches again before applying them to openclaw.json.

Prompt Injection Mitigation

The router rejects task strings that contain prompt-injection patterns (e.g. <script>, javascript:, onclick=). Rejected tasks raise ValueError; the orchestrator should surface a clear message and not pass the task to sub-agents. Additional layers:

  1. 1. The orchestrator (validating task strings and handling rejections)
  2. The sub-agent LLM (resisting prompt injection)
  3. The OpenClaw platform (sanitizing sessions_spawn inputs)

File Access

Required File Access:

  • - Read: openclaw.json (located via OPENCLAW_HOME environment variable or ~/.openclaw/openclaw.json)

- Fields accessed: tools.exec.host and tools.exec.node only
- Purpose: Determine execution environment for spawned sub-agents
- Security: The router does NOT read gateway secrets, API keys, or any other sensitive configuration

Write Access:

  • - Write: None (no files are written by this skill)
  • Config patches: The skill may return recommended_config_patch JSON that the orchestrator can apply, but the skill itself does not write to INLINECODE69

Security Guarantees:

  • - The router does not persist, upload, or transmit any tokens or credentials
  • Only tools.exec.host and tools.exec.node are accessed from INLINECODE72
  • All file access is read-only except for validated config patches (whitelisted to tools.exec.* only)

Other Security Notes

  • - This skill does not expose gateway secrets.
  • Use gateway-guard separately for gateway/auth management.
  • The router does not execute arbitrary code or modify files outside of config patches.
  • The phrase "saves tokens" in documentation refers to cost savings (using cheaper models for simple tasks), not token storage or collection.

标签

skill ai

通过对话安装

该技能支持在以下平台通过对话安装:

OpenClaw WorkBuddy QClaw Kimi Claude

方式一:安装 SkillHub 和技能

帮我安装 SkillHub 和 agent-swarm-1775920090 技能

方式二:设置 SkillHub 为优先技能安装源

设置 SkillHub 为我的优先技能安装源,然后帮我安装 agent-swarm-1775920090 技能

通过命令行安装

skillhub install agent-swarm-1775920090

下载

⬇ 下载 agent-swarm v1.7.19(免费)

文件大小: 26.13 KB | 发布时间: 2026-4-12 08:43

v1.7.19 最新 2026-4-12 08:43
No file changes detected in this release.

- Version number updated to 1.7.19; no code or documentation changes found.
- Behavior and features remain the same as the previous version.

Archiver·手机版·闲社网·闲社论坛·羊毛社区· 多链控股集团有限公司 · 苏ICP备2025199260号-1

Powered by Discuz! X5.0   © 2024-2025 闲社网·线报更新论坛·羊毛分享社区·http://xianshe.com

p2p_official_large
返回顶部