vault: update Trading Agents with WebSocket fix, sessions_spawn solution, and final verification
This commit is contained in:
@@ -182,7 +182,118 @@ trade-analyze 流程:
|
||||
|
||||
---
|
||||
|
||||
## 六、Session 文件位置
|
||||
## 六、Gateway WebSocket 超时修复(根本问题)
|
||||
|
||||
### 问题
|
||||
|
||||
`sessions_send` 和 `sessions_spawn` 全部报错:
|
||||
```
|
||||
gateway timeout after 10000ms
|
||||
Gateway target: ws://127.0.0.1:18789
|
||||
Source: local loopback
|
||||
```
|
||||
|
||||
所有 session 工具、`openclaw status --deep`、`openclaw gateway call` 都超时。
|
||||
|
||||
### 根因分析
|
||||
|
||||
1. Gateway 配置 `bind: "lan"`,监听 `0.0.0.0:18789`
|
||||
2. 但 **`127.0.0.1:18789` 实际连不通**(`curl http://127.0.0.1:18789/` 超时,但 `curl http://192.168.68.108:18789/` 成功)
|
||||
3. OpenClaw 内部工具默认连 `ws://127.0.0.1:18789`,导致所有 RPC 超时
|
||||
4. 同时存在 [v2026.3.13 WebSocket handshake bug](https://github.com/openclaw/openclaw/issues/48167):handshake timeout 只有 3 秒
|
||||
|
||||
### 修复
|
||||
|
||||
**修复 1:Systemd 环境变量**
|
||||
|
||||
在 `~/.config/systemd/user/openclaw-gateway.service` 中添加:
|
||||
```ini
|
||||
Environment=OPENCLAW_GATEWAY_URL=ws://192.168.68.108:18789
|
||||
Environment=OPENCLAW_ALLOW_INSECURE_PRIVATE_WS=1
|
||||
```
|
||||
|
||||
然后 `systemctl --user daemon-reload`。
|
||||
|
||||
这让 gateway 内部工具通过 LAN IP(而非 localhost)连接,绕过了 loopback 不通的问题。
|
||||
|
||||
**修复 2:Patch handshake timeout(来自 [PR #47388](https://github.com/openclaw/openclaw/pull/47388))**
|
||||
|
||||
文件:`~/.nvm/versions/node/v24.13.1/lib/node_modules/openclaw/dist/gateway-cli-CuZs0RlJ.js`(和 `Ol-vpIk7.js`)
|
||||
|
||||
```javascript
|
||||
// 原始(第 7588 行)
|
||||
const DEFAULT_HANDSHAKE_TIMEOUT_MS = 3e3;
|
||||
// 修改为
|
||||
const DEFAULT_HANDSHAKE_TIMEOUT_MS = 10e3;
|
||||
```
|
||||
|
||||
**修复 3:Patch scope grant(来自 [PR #47388](https://github.com/openclaw/openclaw/pull/47388))**
|
||||
|
||||
同一文件,第 22605 行附近:
|
||||
|
||||
```javascript
|
||||
// 原始
|
||||
if (!device && (!isControlUi || decision.kind !== "allow")) clearUnboundScopes();
|
||||
// 修改为
|
||||
if (!device && (!isControlUi || decision.kind !== "allow")) { clearUnboundScopes(); } else if (!device && decision.kind === "allow") { scopes = ["operator.read"]; connectParams.scopes = scopes; }
|
||||
```
|
||||
|
||||
### 验证
|
||||
|
||||
修复后 `openclaw gateway call status` 返回正常 JSON,`sessions_spawn` 成功:
|
||||
```
|
||||
15:49:43 status: "accepted", childSessionKey: "agent:invest-bull:subagent:ad2d265d..."
|
||||
15:50:06 [subagent task] bull-AMZN: completed successfully
|
||||
```
|
||||
|
||||
### 注意事项
|
||||
|
||||
- 这些 patch 在 `npm update openclaw` 后会被覆盖,需要重新打
|
||||
- 关注 [PR #47388](https://github.com/openclaw/openclaw/pull/47388) 和 [PR #48950](https://github.com/openclaw/openclaw/pull/48950) 的合并状态
|
||||
- 合并后升级即可去掉手动 patch
|
||||
|
||||
---
|
||||
|
||||
## 七、最终验证:AMZN 辩论流程
|
||||
|
||||
### 完整时间线
|
||||
|
||||
| 时间 (UTC) | 事件 | 状态 |
|
||||
|------------|------|------|
|
||||
| 15:48:20 | 读取 trade-analyze skill | ✅ |
|
||||
| 15:48:36 | 收集 AMZN 数据(curl API) | ✅ |
|
||||
| 15:49:13 | metrics + sentiment 数据返回 | ✅ |
|
||||
| 15:49:27 | technical + macro 返回 503 | ⚠️ K8s API pod 暂时不可用 |
|
||||
| 15:49:43 | `sessions_spawn` → invest-bull | ✅ accepted |
|
||||
| 15:50:06 | Bull 完成,结果返回 | ✅ |
|
||||
| 15:50:25 | `sessions_spawn` → invest-bear | ✅ accepted |
|
||||
| 15:50:53 | Bear 完成,结果返回 | ✅ |
|
||||
| 15:51:04 | `sessions_spawn` → invest-bull (final rebuttal) | ✅ accepted |
|
||||
| 15:51:08 | 等待 Bull Final + Hawk + Dove... | ⏳ |
|
||||
|
||||
### 关键确认
|
||||
|
||||
1. **`sessions_spawn` 成功调用了辩论 agent** ✅
|
||||
2. **辩论 agent 在后台执行,不在 Discord 输出** ✅(Discord 已禁用)
|
||||
3. **结果通过 subagent announce 自动返回给 invest-analyst** ✅
|
||||
4. **流程按顺序执行**:Bull → Bear → Bull Final → (Hawk → Dove) ✅
|
||||
5. **没有循环** ✅(sessions_spawn 是一次性的,不会互相触发)
|
||||
|
||||
---
|
||||
|
||||
## 八、sessions_send vs sessions_spawn 最终结论
|
||||
|
||||
| 工具 | 能否工作 | 原因 |
|
||||
|------|---------|------|
|
||||
| **@ mention** | ❌ | 导致无限循环 |
|
||||
| **sessions_send** | ❌ | Gateway 内部 WebSocket 死锁(同进程内自连) |
|
||||
| **sessions_spawn** | ✅ | 非阻塞,独立 lane 执行,announce 回传结果 |
|
||||
|
||||
**最终方案:sessions_spawn + announce 回传。**
|
||||
|
||||
---
|
||||
|
||||
## 九、Session 文件位置
|
||||
|
||||
| Agent | Session 路径 |
|
||||
|-------|-------------|
|
||||
|
||||
Reference in New Issue
Block a user