multiclaws 0.4.16 → 0.4.18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/service/a2a-adapter.js +23 -8
- package/package.json +1 -1
- package/skills/multiclaws/SKILL.md +68 -28
|
@@ -152,11 +152,16 @@ class OpenClawAgentExecutor {
|
|
|
152
152
|
// Respect explicit completion flag from gateway
|
|
153
153
|
if (details.isComplete === false)
|
|
154
154
|
return null;
|
|
155
|
+
// Check for session-level error/status from gateway
|
|
156
|
+
const sessionError = details.error;
|
|
157
|
+
const sessionStatus = details.status;
|
|
155
158
|
const messages = (details.messages ?? []);
|
|
156
|
-
if (messages.length === 0)
|
|
159
|
+
if (messages.length === 0 && !details.isComplete)
|
|
157
160
|
return null;
|
|
158
161
|
// If no explicit isComplete flag, use heuristic: check if the session is still executing
|
|
159
162
|
if (details.isComplete === undefined) {
|
|
163
|
+
if (messages.length === 0)
|
|
164
|
+
return null;
|
|
160
165
|
const lastMsg = messages[messages.length - 1];
|
|
161
166
|
if (lastMsg && Array.isArray(lastMsg.content)) {
|
|
162
167
|
const content = lastMsg.content;
|
|
@@ -167,8 +172,7 @@ class OpenClawAgentExecutor {
|
|
|
167
172
|
return null;
|
|
168
173
|
}
|
|
169
174
|
// If the last message is a user message, the agent hasn't responded yet
|
|
170
|
-
|
|
171
|
-
if (lastMsg2?.role === "user")
|
|
175
|
+
if (lastMsg?.role === "user")
|
|
172
176
|
return null;
|
|
173
177
|
}
|
|
174
178
|
// Session is complete — collect ALL assistant text messages in order
|
|
@@ -180,12 +184,23 @@ class OpenClawAgentExecutor {
|
|
|
180
184
|
if (text)
|
|
181
185
|
allTexts.push(text);
|
|
182
186
|
}
|
|
183
|
-
//
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
+
// If we have assistant text, return it (even if there's also an error)
|
|
188
|
+
if (allTexts.length > 0) {
|
|
189
|
+
// Append error info if present so the delegating agent sees both
|
|
190
|
+
if (sessionError) {
|
|
191
|
+
allTexts.push(`[session error: ${sessionError}]`);
|
|
192
|
+
}
|
|
193
|
+
return allTexts.join("\n\n");
|
|
194
|
+
}
|
|
195
|
+
// No assistant text — check if the session reported an error
|
|
196
|
+
if (sessionError) {
|
|
197
|
+
return `Error: ${sessionError}`;
|
|
198
|
+
}
|
|
199
|
+
if (sessionStatus === "failed" || sessionStatus === "error") {
|
|
200
|
+
return `Error: session ended with status "${sessionStatus}"`;
|
|
187
201
|
}
|
|
188
|
-
|
|
202
|
+
// Session truly completed with no output at all
|
|
203
|
+
return "(task completed with no text output)";
|
|
189
204
|
}
|
|
190
205
|
/** Extract text content from a single history message. */
|
|
191
206
|
extractTextFromHistoryMessage(msg) {
|
package/package.json
CHANGED
|
@@ -157,48 +157,88 @@ multiclaws_profile_show()
|
|
|
157
157
|
|
|
158
158
|
适用于需要协商、确认、多次沟通才能完成的任务(如约会议、对需求、联合调试)。
|
|
159
159
|
|
|
160
|
-
|
|
160
|
+
**默认使用异步子 agent 模式。** 主 agent 启动子 agent 后立即返回,子 agent 自主完成全部沟通并通过 `message` 工具实时汇报进展。
|
|
161
161
|
|
|
162
|
-
####
|
|
162
|
+
#### 工作流程
|
|
163
163
|
|
|
164
|
-
|
|
164
|
+
```
|
|
165
|
+
用户: "帮我和小明、小红约明天下午的会议"
|
|
165
166
|
|
|
167
|
+
1. multiclaws_agents() — 列出智能体,读 bio
|
|
168
|
+
2. sessions_spawn(task="<协作任务 prompt>", mode="run")
|
|
169
|
+
3. → 立即告诉用户: "已启动协作任务,会实时汇报进展"
|
|
170
|
+
4.(子 agent 在后台自主完成全部沟通,通过 message 实时汇报)
|
|
171
|
+
5. 子 agent 完成 → announce 回主 agent → 最终结果自动通知用户
|
|
166
172
|
```
|
|
167
|
-
用户: "帮我和小明约明天下午的会议"
|
|
168
173
|
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
174
|
+
#### 子 agent 的 task prompt 模板
|
|
175
|
+
|
|
176
|
+
spawn 子 agent 时,task 必须包含以下要素:
|
|
177
|
+
|
|
178
|
+
```
|
|
179
|
+
sessions_spawn(task="
|
|
180
|
+
## 任务
|
|
181
|
+
联系小明和小红,协商明天下午的会议时间。我这边下午 2-5 点都可以。
|
|
182
|
+
|
|
183
|
+
## 可用工具
|
|
184
|
+
- `multiclaws_agents()` — 查看所有智能体
|
|
185
|
+
- `multiclaws_delegate(agentUrl, task)` — 向智能体发送任务
|
|
186
|
+
|
|
187
|
+
## 执行步骤
|
|
188
|
+
1. 调用 multiclaws_agents() 获取智能体列表
|
|
189
|
+
2. 依次用 multiclaws_delegate 联系每个相关智能体
|
|
190
|
+
3. 每完成一个智能体的沟通,立即用 message 工具向用户汇报进展
|
|
191
|
+
4. 全部沟通完成后,汇总结果
|
|
192
|
+
|
|
193
|
+
## 中间汇报
|
|
194
|
+
每次 multiclaws_delegate 返回后,立即调用 message 工具告知用户当前进展。
|
|
195
|
+
例如:'已联系小明,他说明天下午 3 点和 4 点都可以。正在联系小红...'
|
|
196
|
+
|
|
197
|
+
## 完成条件
|
|
198
|
+
所有相关智能体都已回复,汇总最终结果。
|
|
199
|
+
", mode="run")
|
|
175
200
|
```
|
|
176
201
|
|
|
177
|
-
|
|
178
|
-
- 每次 `multiclaws_delegate` 返回后,**立即向用户汇报结果**,不要等全部完成
|
|
179
|
-
- 如果能自行判断下一步(如对方给了选项,用户已表达偏好),直接继续
|
|
180
|
-
- 如果需要用户决策(如对方提出多个方案),暂停并询问用户
|
|
181
|
-
- 协商未达成一致时,继续发 `multiclaws_delegate`,最多 5 轮
|
|
202
|
+
#### 关键规则
|
|
182
203
|
|
|
183
|
-
|
|
204
|
+
- **主 agent 不做多轮沟通。** 所有多轮协作都交给子 agent。
|
|
205
|
+
- **子 agent 用 `message` 工具实时汇报。** 子 agent 继承了父 agent 的频道上下文,`message` 发出的消息用户能直接看到。
|
|
206
|
+
- 每次 `multiclaws_delegate` 返回后,子 agent 必须立即用 `message` 汇报,不要等全部完成。
|
|
207
|
+
- 如果某个智能体没有回复或返回错误,子 agent 应在汇报中说明,继续联系其他智能体。
|
|
208
|
+
- 协商未达成一致时,子 agent 可继续发 `multiclaws_delegate`,最多 5 轮。
|
|
209
|
+
- 涉及多个智能体时,依次联系(串行),每个完成后立即汇报。
|
|
184
210
|
|
|
185
|
-
|
|
211
|
+
#### 示例场景
|
|
186
212
|
|
|
213
|
+
**约多人会议:**
|
|
187
214
|
```
|
|
188
|
-
用户: "
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
215
|
+
用户: "帮我和小明、小红约明天下午的会议"
|
|
216
|
+
|
|
217
|
+
主 agent:
|
|
218
|
+
1. multiclaws_agents() → 找到小明、小红
|
|
219
|
+
2. sessions_spawn(task="联系小明和小红...(按模板)", mode="run")
|
|
220
|
+
3. 回复用户: "已启动协作任务,正在联系小明和小红,会实时汇报进展。"
|
|
221
|
+
|
|
222
|
+
子 agent(后台执行):
|
|
223
|
+
1. multiclaws_delegate(小明, "明天下午 2-5 点开会,你什么时候有空?")
|
|
224
|
+
→ 小明回复: "3 点和 4 点都行"
|
|
225
|
+
→ message("已联系小明,他明天下午 3 点和 4 点都可以。正在联系小红...")
|
|
226
|
+
2. multiclaws_delegate(小红, "明天下午 2-5 点开会,小明 3 点和 4 点都行,你呢?")
|
|
227
|
+
→ 小红回复: "3 点可以"
|
|
228
|
+
→ message("小红也确认明天下午 3 点可以。")
|
|
229
|
+
3. multiclaws_delegate(小明, "确认明天下午 3 点开会")
|
|
230
|
+
4. multiclaws_delegate(小红, "确认明天下午 3 点开会")
|
|
231
|
+
5. 完成 → announce: "会议已确认:明天下午 3 点,参与人:小明、小红"
|
|
195
232
|
```
|
|
196
233
|
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
234
|
+
**简单单人协作:**
|
|
235
|
+
```
|
|
236
|
+
用户: "问一下小明他那个 API 接口的参数格式"
|
|
200
237
|
|
|
201
|
-
|
|
238
|
+
(单轮任务,不需要多轮 → 直接用智能委派)
|
|
239
|
+
1. multiclaws_delegate(小明, "你那个 API 接口的参数格式是什么?")
|
|
240
|
+
2. 把结果返回给用户
|
|
241
|
+
```
|
|
202
242
|
|
|
203
243
|
---
|
|
204
244
|
|