diff --git a/src/commands/agent-via-gateway.ts b/src/commands/agent-via-gateway.ts index d5afeac2ca5..3dfe89854f7 100644 --- a/src/commands/agent-via-gateway.ts +++ b/src/commands/agent-via-gateway.ts @@ -132,6 +132,8 @@ export async function agentViaGatewayCommand(opts: AgentCliOpts, runtime: Runtim const channel = normalizeMessageChannel(opts.channel) ?? DEFAULT_CHAT_CHANNEL; const idempotencyKey = opts.runId?.trim() || randomIdempotencyKey(); + const workspaceOverride = process.env.OPENCLAW_WORKSPACE?.trim() || undefined; + const response = await withProgress( { label: "Waiting for agent reply…", @@ -157,6 +159,7 @@ export async function agentViaGatewayCommand(opts: AgentCliOpts, runtime: Runtim lane: opts.lane, extraSystemPrompt: opts.extraSystemPrompt, idempotencyKey, + workspace: workspaceOverride, }, expectFinal: true, timeoutMs: gatewayTimeoutMs, @@ -240,6 +243,8 @@ async function agentViaGatewayStreamJson(opts: AgentCliOpts, _runtime: RuntimeEn process.on("SIGTERM", onSignal); process.on("SIGINT", onSignal); + const streamWorkspaceOverride = process.env.OPENCLAW_WORKSPACE?.trim() || undefined; + try { const response = await callGateway({ method: "agent", @@ -259,6 +264,7 @@ async function agentViaGatewayStreamJson(opts: AgentCliOpts, _runtime: RuntimeEn lane: opts.lane, extraSystemPrompt: opts.extraSystemPrompt, idempotencyKey, + workspace: streamWorkspaceOverride, }, expectFinal: true, timeoutMs: gatewayTimeoutMs,