mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-25 19:03:32 +00:00
fix(agents): land #39247 from @jasonQin6 (subagent workspace inheritance)
Propagate parent workspace directories into spawned subagent runs, keep workspace override internal-only, and add regression tests for forwarding boundaries. Co-authored-by: jasonQin6 <991262382@qq.com>
This commit is contained in:
@@ -85,6 +85,8 @@ export type SpawnSubagentContext = {
|
||||
agentGroupChannel?: string | null;
|
||||
agentGroupSpace?: string | null;
|
||||
requesterAgentIdOverride?: string;
|
||||
/** Explicit workspace directory for subagent to inherit (optional). */
|
||||
workspaceDir?: string;
|
||||
};
|
||||
|
||||
export const SUBAGENT_SPAWN_ACCEPTED_NOTE =
|
||||
@@ -697,6 +699,16 @@ export async function spawnSubagentDirect(
|
||||
.filter((line): line is string => Boolean(line))
|
||||
.join("\n\n");
|
||||
|
||||
// Resolve workspace directory for subagent to inherit from requester.
|
||||
const requesterWorkspaceAgentId = requesterInternalKey
|
||||
? parseAgentSessionKey(requesterInternalKey)?.agentId
|
||||
: undefined;
|
||||
const workspaceDir =
|
||||
ctx.workspaceDir?.trim() ??
|
||||
(requesterWorkspaceAgentId
|
||||
? resolveAgentWorkspaceDir(cfg, normalizeAgentId(requesterWorkspaceAgentId))
|
||||
: undefined);
|
||||
|
||||
const childIdem = crypto.randomUUID();
|
||||
let childRunId: string = childIdem;
|
||||
try {
|
||||
@@ -720,6 +732,7 @@ export async function spawnSubagentDirect(
|
||||
groupId: ctx.agentGroupId ?? undefined,
|
||||
groupChannel: ctx.agentGroupChannel ?? undefined,
|
||||
groupSpace: ctx.agentGroupSpace ?? undefined,
|
||||
workspaceDir,
|
||||
},
|
||||
timeoutMs: 10_000,
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user