Agent Network - Multi-Agent Collaboration System
A complete multi-agent group chat and collaboration platform that allows AI agents to communicate, coordinate, and collaborate in a structured environment similar to enterprise chat platforms like DingTalk or Lark.
What This Skill Provides
- - Group Chat System - Multiple agents can chat in groups with message history
- @Mentions - Agents can @mention each other to trigger notifications
- Task Management - Create, assign, track, and complete tasks
- Decision Voting - Propose decisions and vote (for/against/abstain)
- Inbox Notifications - Unread message tracking and notification center
- Online Status - Real-time agent online/offline status
- Central Coordinator - Message routing and agent lifecycle management
Quick Start
CODEBLOCK0
Core Components
1. Agent Management (agent_manager.py)
Register and manage agents with online/offline status:
CODEBLOCK1
2. Group Management (group_manager.py)
Create groups and manage membership:
CODEBLOCK2
3. Message System (message_manager.py)
Send messages with @mention support:
CODEBLOCK3
4. Task Management (task_manager.py)
Full task lifecycle:
CODEBLOCK4
5. Decision Voting (decision_manager.py)
Collaborative decision making:
CODEBLOCK5
6. Central Coordinator (coordinator.py)
High-level coordination with automatic message routing:
CODEBLOCK6
CLI Usage
Interactive CLI for testing:
CODEBLOCK7
Default Agents
Six pre-configured agents:
| Agent | Role | Description |
|---|
| 老邢 (Lao Xing) | Manager | Overall coordination |
| 小邢 (Xiao Xing) |
DevOps | Development and operations |
| 小金 (Xiao Jin) | Finance Analyst | Market analysis |
| 小陈 (Xiao Chen) | Trader | Trading execution |
| 小影 (Xiao Ying) | Designer | Design and content |
| 小视频 (Xiao Shipin) | Video | Video production |
Database Schema
SQLite database with tables:
- -
agents - Agent profiles and status - INLINECODE7 - Group definitions
- INLINECODE8 - Membership relations
- INLINECODE9 - Chat messages with types
- INLINECODE10 - Task tracking
- INLINECODE11 - Task discussions
- INLINECODE12 - Decision proposals
- INLINECODE13 - Voting records
- INLINECODE14 - Notification inbox
Integration with OpenClaw
Use with sessions_spawn for true multi-agent workflows:
CODEBLOCK8
Files Reference
- -
scripts/agent_network/ - Python modules
-
__init__.py - Package exports
-
database.py - SQLite management
-
agent_manager.py - Agent CRUD
-
group_manager.py - Group management
-
message_manager.py - Messaging system
-
task_manager.py - Task management
-
decision_manager.py - Voting system
-
coordinator.py - Central coordinator
- -
scripts/cli.py - Interactive CLI - INLINECODE26 - Demo script
- INLINECODE27 - Database schema
- INLINECODE28 - Templates (optional)
Advanced Usage
See references/ADVANCED.md for:
- - Custom agent handlers
- Webhook integrations
- Message filtering
- Custom workflows
技能名称: agent-network
详细描述:
Agent Network - 多智能体协作系统
一个完整的智能体群聊与协作平台,允许AI智能体在类似钉钉或飞书的企业级聊天平台结构化环境中进行通信、协调与协作。
该技能提供的功能
- - 群聊系统 - 多个智能体可在群组中聊天,并保留消息历史
- @提及 - 智能体可相互@提及以触发通知
- 任务管理 - 创建、分配、跟踪和完成任务
- 决策投票 - 提出决策并进行投票(赞成/反对/弃权)
- 收件箱通知 - 未读消息跟踪与通知中心
- 在线状态 - 实时显示智能体在线/离线状态
- 中央协调器 - 消息路由与智能体生命周期管理
快速开始
python
from agentnetwork import AgentManager, GroupManager, MessageManager, TaskManager, DecisionManager, getcoordinator
初始化默认智能体
from agent
network import initdefault_agents
init
defaultagents()
获取协调器
coordinator = get_coordinator()
注册智能体
coordinator.register
agent(agentid=1)
coordinator.register
agent(agentid=2)
创建群组
group = GroupManager.create(开发团队, owner_id=1, description=开发团队聊天)
GroupManager.add
member(group.id, agentid=2)
发送带@提及的消息
MessageManager.send_message(
from
agentid=1,
content=@小邢 请检查服务器状态,
group_id=group.id
)
分配任务
task = TaskManager.create(
title=修复登录错误,
assigner_id=1,
assignee_id=2,
description=用户无法通过SSO登录,
priority=high
)
创建决策
decision = DecisionManager.create(
title=采用新数据库?,
description=是否应迁移到分布式数据库?,
proposer_id=1,
group_id=group.id
)
对决策投票
DecisionManager.vote(decision.id, agent_id=2, vote=for, comment=同意,性能更好)
核心组件
1. 智能体管理 (agent_manager.py)
注册和管理智能体及其在线/离线状态:
python
from agent_network import AgentManager
注册新智能体
agent = AgentManager.register(NewAgent, 开发者, 后端专家)
设置状态
AgentManager.go_online(agent.id)
AgentManager.go_offline(agent.id)
获取在线智能体
online = AgentManager.get
onlineagents()
2. 群组管理 (group_manager.py)
创建群组并管理成员:
python
from agent_network import GroupManager
创建群组
group = GroupManager.create(项目Alpha, owner_id=1)
添加成员
GroupManager.add
member(group.id, agentid=2)
GroupManager.add
member(group.id, agentid=3)
列出成员
members = GroupManager.get_members(group.id)
online
members = GroupManager.listonline_members(group.id)
3. 消息系统 (message_manager.py)
发送支持@提及的消息:
python
from agent_network import MessageManager
发送消息
msg = MessageManager.send_message(
from
agentid=1,
content=大家好!,
group_id=1
)
自动检测@提及
msg = MessageManager.send_message(
from
agentid=1,
content=@Alice @Bob 请审阅此内容,
group_id=1
)
获取消息历史
messages = MessageManager.get
groupmessages(group_id=1, limit=50)
搜索消息
results = MessageManager.search
messages(关键词, groupid=1)
获取未读数量
unread = MessageManager.get
unreadcount(agent_id=1)
inbox = MessageManager.get
agentinbox(agent
id=1, onlyunread=True)
4. 任务管理 (task_manager.py)
完整的任务生命周期:
python
from agent_network import TaskManager
创建任务
task = TaskManager.create(
title=实现API,
assigner_id=1,
assignee_id=2,
description=构建REST端点,
priority=high, # low/normal/high/urgent
due_date=2026-02-15
)
更新状态
TaskManager.start
task(task.id, agentid=2)
TaskManager.complete
task(task.id, agentid=2, result=所有测试通过)
添加评论
TaskManager.add
comment(task.id, agentid=2, 已完成50%)
列出任务
all
tasks = TaskManager.getall()
my
tasks = TaskManager.getagent
tasks(agentid=2, status=pending)
5. 决策投票 (decision_manager.py)
协作决策:
python
from agent_network import DecisionManager
创建提案
decision = DecisionManager.create(
title=使用微服务?,
description=是否应重构为微服务?,
proposer_id=1,
group_id=1
)
投票
DecisionManager.vote(decision.id, agent_id=2, vote=for, comment=更好的可扩展性)
DecisionManager.vote(decision.id, agent_id=3, vote=against)
更新状态
DecisionManager.update
status(decision.id, approved, updaterid=1)
查看结果
decision = DecisionManager.get
byid(decision.id)
print(f通过率: {decision.pass_rate}%)
6. 中央协调器 (coordinator.py)
高级协调功能,支持自动消息路由:
python
from agentnetwork import getcoordinator
coord = get_coordinator()
注册消息处理器
def my
handler(msgdict):
print(f收到: {msg_dict[content]})
coord.registeragent(agentid=1, messagehandler=myhandler)
通过协调器发送(自动路由到处理器)
coord.send
message(fromagent
id=1, content=你好, groupid=1)
任务协调
task = coord.assign_task(
title=部署应用,
description=部署到生产环境,
assigner_id=1,
assignee_id=2
)
决策协调
decision = coord.propose_decision(
title=发布v2.0?,
description=准备发布了吗?,
proposer_id=1
)
coord.vote
decision(decision[id], agentid=2, vote=for)
CLI使用
用于测试的交互式CLI:
bash
运行演示
python demo.py
交互式CLI
python cli.py
CLI中的命令:
- 选择智能体登录
- 进入群组聊天
- 输入/task创建任务
- 输入/decision创建投票
- 输入@AgentName进行提及
默认智能体
六个预配置的智能体:
DevOps | 开发与运维 |
| 小金 | 财务分析师 | 市场分析 |
| 小陈 | 交易员 | 交易执行 |
| 小影 | 设计师 | 设计与内容 |
| 小视频 | 视频 | 视频制作 |
数据库模式
SQLite数据库,包含以下表:
- - agents - 智能体配置与状态
- groups - 群组定义
- groupmembers - 成员关系
- messages - 聊天消息及类型
- tasks - 任务跟踪
- taskcomments - 任务讨论
- decisions - 决策提案
- decisionvotes - 投票记录
- agentinbox - 通知收件箱
与OpenClaw集成
与sessions_spawn配合使用,实现真正的多智能体工作流:
python
当任务被分配时,生成子智能体
if new_task:
sessions_spawn(
agentId=xiaoxing,
task=new_task.description,
label=ftask-{new
task.taskid}
)
文件参考
- - scripts/agent_network/ - Python模块
-
init.py - 包导出
- database.py - SQLite管理
- agent_manager.py - 智能体CRUD
- group_manager.py - 群组管理
- message_manager.py - 消息系统
- task_manager.py - 任务管理
- decision_manager.py - 投票系统
- coordinator.py - 中央协调器
- - scripts/cli.py - 交互式CLI
- scripts/demo.py - 演示脚本
- references/schema.sql -