From 16a2dc84bd567d9ad8d1198c85c19e9a4e608201 Mon Sep 17 00:00:00 2001 From: zhejian zhang <527284545@qq.com> Date: Thu, 5 Mar 2026 10:23:11 +0800 Subject: [PATCH 1/2] CLI: add --session-key flag to openclaw agent command --- src/cli/program/register.agent.ts | 1 + src/commands/agent-via-gateway.ts | 9 +++++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/cli/program/register.agent.ts b/src/cli/program/register.agent.ts index fdb45a0960a..d0e95d575f7 100644 --- a/src/cli/program/register.agent.ts +++ b/src/cli/program/register.agent.ts @@ -26,6 +26,7 @@ export function registerAgentCommands(program: Command, args: { agentChannelOpti .requiredOption("-m, --message ", "Message body for the agent") .option("-t, --to ", "Recipient number in E.164 used to derive the session key") .option("--session-id ", "Use an explicit session id") + .option("--session-key ", "Use an explicit session key") .option("--agent ", "Agent id (overrides routing bindings)") .option("--thinking ", "Thinking level: off | minimal | low | medium | high") .option("--verbose ", "Persist agent verbose level for the session") diff --git a/src/commands/agent-via-gateway.ts b/src/commands/agent-via-gateway.ts index a44caa3f3bf..38b964dbe3a 100644 --- a/src/commands/agent-via-gateway.ts +++ b/src/commands/agent-via-gateway.ts @@ -37,6 +37,7 @@ export type AgentCliOpts = { agent?: string; to?: string; sessionId?: string; + sessionKey?: string; thinking?: string; verbose?: string; json?: boolean; @@ -89,8 +90,10 @@ export async function agentViaGatewayCommand(opts: AgentCliOpts, runtime: Runtim if (!body) { throw new Error("Message (--message) is required"); } - if (!opts.to && !opts.sessionId && !opts.agent) { - throw new Error("Pass --to , --session-id, or --agent to choose a session"); + if (!opts.to && !opts.sessionId && !opts.sessionKey && !opts.agent) { + throw new Error( + "Pass --to , --session-id, --session-key, or --agent to choose a session", + ); } const cfg = loadConfig(); @@ -115,6 +118,7 @@ export async function agentViaGatewayCommand(opts: AgentCliOpts, runtime: Runtim agentId, to: opts.to, sessionId: opts.sessionId, + sessionKey: opts.sessionKey, }).sessionKey; const channel = normalizeMessageChannel(opts.channel); @@ -181,6 +185,7 @@ export async function agentCliCommand(opts: AgentCliOpts, runtime: RuntimeEnv, d const localOpts = { ...opts, agentId: opts.agent, + sessionKey: opts.sessionKey, replyAccountId: opts.replyAccount, }; if (opts.local === true) { From 4134d275ecbc1d6059295a078059e42a40f4fbb2 Mon Sep 17 00:00:00 2001 From: zhejian zhang <527284545@qq.com> Date: Fri, 6 Mar 2026 14:06:35 +0800 Subject: [PATCH 2/2] CLI: remove redundant sessionKey assignment in localOpts --- src/commands/agent-via-gateway.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/commands/agent-via-gateway.ts b/src/commands/agent-via-gateway.ts index 38b964dbe3a..05079f6b446 100644 --- a/src/commands/agent-via-gateway.ts +++ b/src/commands/agent-via-gateway.ts @@ -185,7 +185,6 @@ export async function agentCliCommand(opts: AgentCliOpts, runtime: RuntimeEnv, d const localOpts = { ...opts, agentId: opts.agent, - sessionKey: opts.sessionKey, replyAccountId: opts.replyAccount, }; if (opts.local === true) {