multiclaws 0.4.19 → 0.4.20

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.
@@ -71,6 +71,9 @@ class OpenClawAgentExecutor {
71
71
  try {
72
72
  this.logger.info(`[a2a-adapter] executing task ${taskId}: ${taskText.slice(0, 100)}`);
73
73
  // 1. Spawn the subagent
74
+ // Use a dedicated session key to avoid inheriting the main session's
75
+ // thinking blocks, which would cause "thinking blocks cannot be modified"
76
+ // errors from the Claude API.
74
77
  const spawnResult = await (0, gateway_client_1.invokeGatewayTool)({
75
78
  gateway: this.gatewayConfig,
76
79
  tool: "sessions_spawn",
@@ -78,6 +81,7 @@ class OpenClawAgentExecutor {
78
81
  task: taskText,
79
82
  mode: "run",
80
83
  },
84
+ sessionKey: `a2a-${taskId}`,
81
85
  timeoutMs: 15_000,
82
86
  });
83
87
  // Extract details from gateway response: { content: [...], details: { childSessionKey, ... } }
@@ -87,8 +91,9 @@ class OpenClawAgentExecutor {
87
91
  throw new Error("sessions_spawn did not return a childSessionKey");
88
92
  }
89
93
  // 2. Poll for completion
94
+ const gatewaySessionKey = `a2a-${taskId}`;
90
95
  this.logger.info(`[a2a-adapter] task ${taskId} spawned as ${childSessionKey}, waiting for result...`);
91
- const output = await this.waitForCompletion(childSessionKey, 180_000);
96
+ const output = await this.waitForCompletion(childSessionKey, 180_000, gatewaySessionKey);
92
97
  // 3. Return result
93
98
  this.taskTracker.update(taskId, { status: "completed", result: output });
94
99
  this.logger.info(`[a2a-adapter] task ${taskId} completed`);
@@ -106,7 +111,7 @@ class OpenClawAgentExecutor {
106
111
  * Poll sessions_history until the subagent session completes.
107
112
  * Collects ALL assistant text messages and returns them joined.
108
113
  */
109
- async waitForCompletion(sessionKey, timeoutMs) {
114
+ async waitForCompletion(sessionKey, timeoutMs, gatewaySessionKey) {
110
115
  const gateway = this.gatewayConfig;
111
116
  const startTime = Date.now();
112
117
  let attempt = 0;
@@ -124,6 +129,7 @@ class OpenClawAgentExecutor {
124
129
  limit: 50,
125
130
  includeTools: false,
126
131
  },
132
+ sessionKey: gatewaySessionKey,
127
133
  timeoutMs: 8_000,
128
134
  });
129
135
  const result = this.extractCompletedResult(histResult);
@@ -633,6 +633,11 @@ class MulticlawsService extends node_events_1.EventEmitter {
633
633
  else if (state === "failed") {
634
634
  this.taskTracker.update(trackId, { status: "failed", error: output || "remote task failed" });
635
635
  }
636
+ else {
637
+ // For any other state (unknown, working, etc.), mark as failed to avoid
638
+ // tasks stuck in "running" forever until TTL prune.
639
+ this.taskTracker.update(trackId, { status: "failed", error: `unexpected remote state: ${state}` });
640
+ }
636
641
  return { taskId: task.id, output, status: state };
637
642
  }
638
643
  const msg = result;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "multiclaws",
3
- "version": "0.4.19",
3
+ "version": "0.4.20",
4
4
  "description": "MultiClaws plugin for OpenClaw collaboration via A2A protocol",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",