fix(agents): scope process/exec tools to sessionKey for isolation

This commit is contained in:
Keith the Silly Goose
2026-01-31 09:33:23 +13:00
committed by Tak Hoffman
parent 36e27ad561
commit 6d5b9b19a7

View File

@@ -212,7 +212,12 @@ export function createOpenClawCodingTools(options?: {
providerProfilePolicy,
providerProfileAlsoAllow,
);
const scopeKey = options?.exec?.scopeKey ?? (agentId ? `agent:${agentId}` : undefined);
// Prefer sessionKey for process isolation scope to prevent cross-session process visibility/killing.
// Fallback to agentId if no sessionKey is available (e.g. legacy or global contexts).
const scopeKey =
options?.exec?.scopeKey ??
options?.sessionKey ??
(agentId ? `agent:${agentId}` : undefined);
const subagentPolicy =
isSubagentSessionKey(options?.sessionKey) && options?.sessionKey
? resolveSubagentToolPolicy(options.config)