fix: resolve target agent workspace for cross-agent subagent spawns (#40176)

Merged via squash.

Prepared head SHA: 2378e40383
Co-authored-by: moshehbenavraham <17122072+moshehbenavraham@users.noreply.github.com>
Co-authored-by: mcaxtr <7562095+mcaxtr@users.noreply.github.com>
Reviewed-by: @mcaxtr
This commit is contained in:
Max aka Mosheh
2026-03-13 17:09:51 +02:00
committed by GitHub
parent ca414735b9
commit 55e79adf69
5 changed files with 234 additions and 10 deletions

View File

@@ -58,6 +58,7 @@ export function mapToolContextToSpawnedRunMetadata(
export function resolveSpawnedWorkspaceInheritance(params: {
config: OpenClawConfig;
targetAgentId?: string;
requesterSessionKey?: string;
explicitWorkspaceDir?: string | null;
}): string | undefined {
@@ -65,12 +66,13 @@ export function resolveSpawnedWorkspaceInheritance(params: {
if (explicit) {
return explicit;
}
const requesterAgentId = params.requesterSessionKey
? parseAgentSessionKey(params.requesterSessionKey)?.agentId
: undefined;
return requesterAgentId
? resolveAgentWorkspaceDir(params.config, normalizeAgentId(requesterAgentId))
: undefined;
// For cross-agent spawns, use the target agent's workspace instead of the requester's.
const agentId =
params.targetAgentId ??
(params.requesterSessionKey
? parseAgentSessionKey(params.requesterSessionKey)?.agentId
: undefined);
return agentId ? resolveAgentWorkspaceDir(params.config, normalizeAgentId(agentId)) : undefined;
}
export function resolveIngressWorkspaceOverrideForSpawnedRun(