Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions src/core/tool-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -516,13 +516,21 @@ export function createToolClient(config: ClawdbotConfig, accountIndex = 0): Tool
account = fallback;
}

// 2. 获取 SDK 实例(复用 LarkClient 的缓存)
// 2. 获取 senderOpenId — 优先级:
// 1. LarkTicket(来自 WebSocket 消息处理上下文)
// 2. 全局 openclaw.inboundMeta.sender_id(来自子代理调度场景)
let senderOpenId: string | undefined = ticket?.senderOpenId;
if (!senderOpenId && typeof global !== 'undefined' && (global as any).openclaw?.inboundMeta?.sender_id) {
senderOpenId = (global as any).openclaw.inboundMeta.sender_id;
}

// 3. 获取 SDK 实例(复用 LarkClient 的缓存)
const larkClient = LarkClient.fromAccount(account);

// 3. 组装 ToolClient
// 4. 组装 ToolClient
return new ToolClient({
account,
senderOpenId: ticket?.senderOpenId,
senderOpenId,
sdk: larkClient.sdk,
config,
});
Expand Down