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

Merged via /review-pr -> /prepare-pr -> /merge-pr.

Prepared head SHA: 5d30672e75
Co-authored-by: mcinteerj <3613653+mcinteerj@users.noreply.github.com>
Co-authored-by: Takhoffman <781889+Takhoffman@users.noreply.github.com>
Reviewed-by: @Takhoffman
This commit is contained in:
Jake
2026-02-12 14:55:12 +13:00
committed by GitHub
parent 36e27ad561
commit 631102e714

View File

@@ -212,7 +212,10 @@ 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)