介绍
# Agent Council
用于创建和管理自主 AI 代理的完整工具包,包含 OpenClaw 的 Discord 集成。
## What This Skill Does
**Agent Creation:** - 创建具有独立工作空间的自主 AI 代理 - 生成 SOUL.md(个性与职责) - 生成 HEARTBEAT.md(cron 执行逻辑) - 设置记忆系统(混合架构) - 自动配置网关 - 将代理绑定到 Discord 频道(可选) - 设置每日记忆 cron 任务(可选)
**Discord Channel Management:** - 通过 API 创建 Discord 频道 - 配置 OpenClaw 网关允许列表 - 设置特定于频道的系统提示词 - 重命名频道并更新引用 - 可选的工作空间文件搜索
## Installation
```bash # Install from ClawHub clawhub install agent-council
# Or manual install cp -r . ~/.openclaw/skills/agent-council/ openclaw gateway config.patch --raw '{ "skills": { "entries": { "agent-council": {"enabled": true} } } }' ```
## Part 1: Agent Creation
### Quick Start
```bash scripts/create-agent.sh \ --name "Watson" \ --id "watson" \ --emoji "🔬" \ --specialty "Research and analysis specialist" \ --model "anthropic/claude-opus-4-5" \ --workspace "$HOME/agents/watson" \ --discord-channel "1234567890" ```
### Workflow
#### 1. Gather Requirements
询问用户: - **Agent name**(例如,"Watson") - **Agent ID**(小写,带连字符,例如,"watson") - **Emoji**(例如,"🔬") - **Specialty**(代理的工作内容) - **Model**(使用的 LLM) - **Workspace**(创建代理文件的位置) - **Discord channel ID**(可选)
#### 2. Run Creation Script
```bash scripts/create-agent.sh \ --name "Agent Name" \ --id "agent-id" \ --emoji "🤖" \ --specialty "What this agent does" \ --model "provider/model-name" \ --workspace "/path/to/workspace" \ --discord-channel "1234567890" # Optional ```
脚本会自动: - ✅ 创建带有记忆子目录的工作空间 - ✅ 生成 SOUL.md 和 HEARTBEAT.md - ✅ 更新网关配置(保留现有代理) - ✅ 添加 Discord 频道绑定(如果指定) - ✅ 重启网关以应用更改 - ✅ 提示设置每日记忆 cron
#### 3. Customize Agent
创建后: - **SOUL.md** - 优化个性、职责、边界 - **HEARTBEAT.md** - 添加定期检查和 cron 逻辑 - **Workspace files** - 添加特定于代理的配置
### Agent Architecture
**Self-contained structure:** ``` agents/ ├── watson/ │ ├── SOUL.md # Personality and responsibilities │ ├── HEARTBEAT.md # Cron execution logic │ ├── memory/ # Agent-specific memory │ │ ├── 2026-02-01.md # Daily memory logs │ │ └── 2026-02-02.md │ └── .openclaw/ │ └── skills/ # Agent-specific skills (optional) ```
**Memory system:** - 特定于代理的记忆:`<workspace>/memory/YYYY-MM-DD.md` - 共享记忆访问:代理可以读取共享工作空间 - 每日更新:用于摘要的可选 cron 任务
**Cron jobs:** 如果您的代理需要计划任务: 1. 创建包含执行逻辑的 HEARTBEAT.md 2. 使用 `--session <agent-id>` 添加 cron 任务 3. 在 SOUL.md 中记录
### Examples
**Research agent:** ```bash scripts/create-agent.sh \ --name "Watson" \ --id "watson" \ --emoji "🔬" \ --specialty "Deep research and competitive analysis" \ --model "anthropic/claude-opus-4-5" \ --workspace "$HOME/agents/watson" \ --discord-channel "1234567890" ```
**Image generation agent:** ```bash scripts/create-agent.sh \ --name "Picasso" \ --id "picasso" \ --emoji "🎨" \ --specialty "Image generation and editing specialist" \ --model "google/gemini-3-flash-preview" \ --workspace "$HOME/agents/picasso" \ --discord-channel "9876543210" ```
**Health tracking agent:** ```bash scripts/create-agent.sh \ --name "Nurse Joy" \ --id "nurse-joy" \ --emoji "💊" \ --specialty "Health tracking and wellness monitoring" \ --model "anthropic/claude-opus-4-5" \ --workspace "$HOME/agents/nurse-joy" \ --discord-channel "5555555555" ```
## Part 2: Discord Channel Management
### Channel Creation
#### Quick Start
```bash python3 scripts/setup-channel.py \ --name research \ --context "Deep research and competitive analysis" ```
#### Workflow
1. Run setup script: ```bash python3 scripts/setup-channel.py \ --name <channel-name> \ --context "<channel-purpose>" \ [--category-id <discord-category-id>] ```
2. Apply gateway config (command shown by script): ```bash openclaw gateway config.patch --raw '{"channels": {...}}' ```
#### Options
**With category:** ```bash python3 scripts/setup-channel.py \ --name research \ --context "Deep research and competitive analysis" \ --category-id "1234567890" ```
**Use existing channel:** ```bash python3 scripts/setup-channel.py \ --name personal-finance \ --id 1466184336901537897 \ --context "Personal finance management" ```
### Channel Renaming
#### Quick Start
```bash python3 scripts/rename-channel.py \ --id 1234567890 \ --old-name old-name \ --new-name new-name ```
#### Workflow
1. Run rename script: ```bash python3 scripts/rename-channel.py \ --id <channel-id> \ --old-name <old-name> \ --new-name <new-name> \ [--workspace <workspace-dir>] ```
2. Apply gateway config if systemPrompt needs updating (shown by script)
3. Commit workspace file changes (if `--workspace` used)
#### With Workspace Search
```bash python3 scripts/rename-channel.py \ --id 1234567890 \ --old-name old-name \ --new-name new-name \ --workspace "$HOME/my-workspace" ```
这将: - 通过 API 重命名 Discord 频道 - 更新网关配置 systemPrompt - 搜索并更新工作空间文件 - 报告已更改的文件以便 git 提交
## Complete Multi-Agent Setup
**Full workflow from scratch:**
```bash # 1. Create Discord channel python3 scripts/setup-channel.py \ --name research \ --context "Deep research and competitive analysis" \ --category-id "1234567890"
# (Note the channel ID from output)
# 2. Apply gateway config for channel openclaw gateway config.patch --raw '{"channels": {...}}'
# 3. Create agent bound to that channel scripts/create-agent.sh \ --name "Watson" \ --id "watson" \ --emoji "🔬" \ --specialty "Deep research and competitive analysis" \ --model "anthropic/claude-opus-4-5" \ --workspace "$HOME/agents/watson" \ --discord-channel "1234567890"
# Done! Agent is created and bound to the channel ```
## Configuration
### Discord Category ID
**Option 1: Command line** ```bash python3 scripts/setup-channel.py \ --name channel-name \ --context "Purpose" \ --category-id "1234567890" ```
**Option 2: Environment variable** ```bash export DISCORD_CATEGORY_ID="1234567890" python3 scripts/setup-channel.py --name channel-name --context "Purpose" ```
### Finding Discord IDs
**Enable Developer Mode:** - Settings → Advanced → Developer Mode
**Copy IDs:** - 右键点击频道 → Copy ID - 右键点击分类 → Copy ID
## Scripts Reference
### create-agent.sh
**Arguments:** - `--name` (required) - 代理名称 - `--id` (required) - 代理 ID(小写,带连字符) - `--emoji` (required) - 代理表情符号 - `--specialty` (required) - 代理的工作内容 - `--model` (required) - 使用的 LLM(provider/model-name) - `--workspace` (required) - 创建代理文件的位置 - `--discord-channel` (optional) - 要绑定的 Discord 频道 ID
**Output:** - 创建代理工作空间 - 生成 SOUL.md 和 HEARTBEAT.md - 更新网关配置 - 可选地创建每日记忆 cron
### setup-channel.py
**Arguments:** - `--name` (required) - 频道名称 - `--context` (required) - 频道用途/上下文 - `--id` (optional) - 现有频道 ID - `--category-id` (optional) - Discord 分类 ID
**Output:** - 创建 Discord 频道(如果不存在) - 生成 gateway config.patch 命令
### rename-channel.py
**Arguments:** - `--id` (required) - 频道 ID - `--old-name` (required) - 当前频道名称 - `--new-name` (required) - 新频道名称 - `--workspace` (optional) - 要搜索的工作空间目录
**Output:** - 重命名 Discord 频道 - 更新网关 systemPrompt(如果需要) - 列出更新的文件(如果启用了工作空间搜索)
## Gateway Integration
此技能与 OpenClaw 的网关配置集成:
**Agents:** ```json { "agents": { "list": [ { "id": "watson", "name": "Watson", "workspace": "/path/to/agents/watson", "model": { "primary": "anthropic/claude-opus-4-5" }, "identity": { "name": "Watson", "emoji": "🔬" } } ] } } ```
**Bindings:** ```json { "bindings": [ { "agentId": "watson", "match": { "channel": "discord", "peer": { "kind": "channel", "id": "1234567890" } } } ] } ```
**Channels:** ```json { "channels": { "discord": { "guilds": { "YOUR_GUILD_ID": { "channels": { "1234567890": { "allow": true, "requireMention": false, "systemPrompt": "Deep research and competitive analysis" } } } } } } } ```
## Agent Coordination
您的主代理使用 OpenClaw 内置的会话管理工具与专业代理进行协调。
### List Active Agents
查看所有活动代理及其近期活动:
```typescript sessions_list({ kinds: ["agent"], limit: 10, messageLimit: 3 // Show last 3 messages per agent }) ```
### Send Messages to Agents
**Direct communication:** ```typescript sessions_send({ label: "watson", // Agent ID message: "Research the competitive landscape for X" }) ```
**Wait for response:** ```typescript sessions_send({ label: "watson", message: "What did you find about X?", timeoutSeconds: 300 // Wait up to 5 minutes }) ```
### Spawn Sub-Agent Tasks
对于复杂工作,在隔离会话中生成子代理:
```typescript sessions_spawn({ agentId: "watson", // Optional: use specific agent task: "Research competitive landscape for X and write a report", model: "anthropic/claude-opus-4-5", // Optional: override model runTimeoutSeconds: 3600, // 1 hour max cleanup: "delete" // Delete session after completion }) ```
子代理将: 1. 在隔离环境中执行任务 2. 向您的会话宣布完成 3. 自我删除(如果 `cleanup: "delete"`)
### Check Agent History
查看代理一直在处理的工作:
```typescript sessions_history({ sessionKey: "watson-session-key", limit: 50 }) ```
### Coordination Patterns
**1. Direct delegation (Discord-bound agents):** - 用户向代理的 Discord 频道发送消息 - 代理直接在该频道中回复 - 主代理无需协调
**2. Programmatic delegation (main agent → sub-agent):** ```typescript // Main agent delegates task sessions_send({ label: "watson", message: "Research X and update memory/research-X.md" })
// Watson works independently, updates files // Main agent checks later or Watson reports back ```
**3. Spawn for complex tasks:** ```typescript // For longer-running, isolated work sessions_spawn({ agentId: "watson", task: "Deep dive: analyze competitors A, B, C. Write report to reports/competitors.md", runTimeoutSeconds: 7200, cleanup: "keep" // Keep session for review }) ```
**4. Agent-to-agent communication:** 代理可以相互发送消息: ```typescript // In Watson's context sessions_send({ label: "picasso", message: "Create an infographic from data in reports/research.md" }) ```
### Best Practices
**When to use Discord bindings:** - ✅ 特定领域的代理(研究、健康、图像) - ✅ 用户希望直接访问代理 - ✅ 代理应该响应频道活动
**When to use sessions_send:** - ✅ 程序化协调 - ✅ 主代理委派给专业代理 - ✅ 需要在同一会话中响应
**When to use sessions_spawn:** - ✅ 长时间运行的任务(>5 分钟) - ✅ 复杂的多步骤工作 - ✅ 希望与主会话隔离 - ✅ 后台处理
### Example: Research Workflow
```typescript // Main agent receives request: "Research competitor X"
// 1. Check if Watson is active const agents = sessions_list({ kinds: ["agent"] })
// 2. Delegate to Watson sessions_send({ label: "watson", message: "Research competitor X: products, pricing, market position. Write findings to memory/research-X.md" })
// 3. Watson works independently: // - Searches web // - Analyzes data // - Updates memory file // - Reports back when done
// 4. Main agent retrieves results const results = Read("agents/watson/memory/research-X.md")
// 5. Share with user "Research complete! Watson found: [summary]" ```
### Communication Flow
**Main Agent (You) ↔ Specialized Agents:**
``` User Request ↓ Main Agent (Claire) ↓ sessions_send("watson", "Research X") ↓ Watson Agent ↓ - Uses web_search - Uses web_fetch - Updates memory files ↓ Responds to main session ↓ Main Agent synthesizes and replies ```
**Discord-Bound Agents:**
``` User posts in #research channel ↓ Watson Agent (bound to channel) ↓ - Sees message directly - Responds in channel - No main agent involvement ```
**Hybrid Approach:**
``` User: "Research X" (main channel) ↓ Main Agent delegates to Watson ↓ Watson researches and reports back ↓ Main Agent: "Done! Watson found..." ↓ User: "Show me more details" ↓ Main Agent: "@watson post your full findings in #research" ↓ Watson posts detailed report in #research channel ```
## Troubleshooting
**Agent Creation Issues:**
**"Agent not appearing in Discord"** - 验证频道 ID 是否正确 - 检查网关配置 bindings 部分 - 重启网关:`openclaw gateway restart`
**"Model errors"** - 验证模型名称格式:`provider/model-name` - 检查网关配置中是否包含该模型
**Channel Management Issues:**
**"Failed to create channel"** - 检查机器人是否具有“Manage Channels”权限 - 验证 OpenClaw 配置中的机器人令牌 - 确保分类 ID 正确(如果指定)
**"Category not found"** - 验证分类 ID 是否正确 - 检查机器人是否有权访问该分类 - 尝试不使用分类 ID(创建未分类的频道)
**"Channel already exists"** - 使用 `--id <channel-id>` 配置现有频道 - 或者脚本将自动检测并配置它
## Use Cases
- **Domain specialists** - 研究、健康、金融、编码代理 - **Creative agents** - 图像生成、写作、设计 - **Task automation** - 计划监控、报告、警报 - **Multi-agent systems** - 协调的专业代理团队 - **Discord organization** - 针对不同代理领域的结构化频道
## Advanced: Multi-Agent Coordination
对于更大的多代理系统:
**Coordination Patterns:** - 主代理将任务委派给专业代理 - 代理报告进度并请求帮助 - 用于公共信息的共享知识库 - 通过 `sessions_send` 进行跨代理通信
**Task Management:** - 与任务跟踪系统集成 - 根据代理专业领域路由工作 - 跟踪分配和完成情况
**Documentation:** - 在主工作空间中维护代理名册 - 记录委派模式 - 保留常见工作流程的操作手册
## Best Practices
1. **Organize channels in categories** - 将相关代理频道分组 2. **Use descriptive channel names** - 从名称中明确用途 3. **Set specific system prompts** - 为每个频道提供清晰的上下文 4. **Document agent responsibilities** - 保持 SOUL.md 更新 5. **Set up memory cron jobs** - 对于有持续工作的代理 6. **Test agents individually** - 在集成到团队之前 7. **Update gateway config safely** - 始终使用 config.patch,切勿手动编辑
## Requirements
**Bot Permissions:** - `Manage Channels` - 创建/重命名频道 - `View Channels` - 读取频道列表 - `Send Messages` - 在频道中发布消息
**System:** - 已安装并配置 OpenClaw - 通过 nvm 安装的 Node.js/npm - Python 3.6+(仅标准库) - Discord 机器人令牌(用于频道管理)
## See Also
- OpenClaw 文档: https://docs.openclaw.ai - Multi-agent patterns: https://docs.openclaw.ai/agents - Discord bot setup: https://docs.openclaw.ai/channels/discord