diff --git a/src/agents/tools/message-tool.ts b/src/agents/tools/message-tool.ts index 96b2702f065..d5a089416e0 100644 --- a/src/agents/tools/message-tool.ts +++ b/src/agents/tools/message-tool.ts @@ -488,6 +488,7 @@ const MessageToolSchema = buildMessageToolSchemaFromActions(AllMessageActions, { type MessageToolOptions = { agentAccountId?: string; agentSessionKey?: string; + agentId?: string; config?: OpenClawConfig; currentChannelId?: string; currentChannelProvider?: string; @@ -775,9 +776,9 @@ export function createMessageTool(options?: MessageToolOptions): AnyAgentTool { gateway, toolContext, sessionKey: options?.agentSessionKey, - agentId: options?.agentSessionKey - ? resolveSessionAgentId({ sessionKey: options.agentSessionKey, config: cfg }) - : undefined, + agentId: + options?.agentId?.trim() || + resolveSessionAgentId({ sessionKey: options?.agentSessionKey, config: cfg }), sandboxRoot: options?.sandboxRoot, abortSignal: signal, });