feat(pi): finish subagent runtime surfaces
This commit is contained in:
@@ -156,7 +156,7 @@ class RpcChildHandle implements ChildHandle {
|
||||
|
||||
export class SubprocessRpcRunner implements ChildRunner {
|
||||
async start(id: string, request: SpawnRequest, cwd: string, events: RunnerEvents): Promise<ChildHandle> {
|
||||
const args = [process.argv[1], "--mode", "rpc", "--no-extensions", "--name", `subagent ${id}`, ...toolArgs(request), ...modelArgs(request)];
|
||||
const args = [process.argv[1], "--mode", "rpc", "--no-extensions", "--name", `subagent ${id}`, ...contextArgs(request), ...toolArgs(request), ...modelArgs(request)];
|
||||
const child = spawn(process.execPath, args, {
|
||||
cwd,
|
||||
env: childEnvironment(),
|
||||
@@ -174,6 +174,11 @@ function delay(ms: number): Promise<void> {
|
||||
return new Promise((resolve) => setTimeout(resolve, ms));
|
||||
}
|
||||
|
||||
function contextArgs(request: SpawnRequest): string[] {
|
||||
if (request.context !== "fork" || !request.parentSessionFile) return [];
|
||||
return ["--fork", request.parentSessionFile];
|
||||
}
|
||||
|
||||
function toolArgs(request: SpawnRequest): string[] {
|
||||
const activeTools = request.toolProfile?.activeTools;
|
||||
if (activeTools === undefined || activeTools === null) return [];
|
||||
@@ -200,5 +205,8 @@ function childEnvironment(): NodeJS.ProcessEnv {
|
||||
|
||||
function independentPrompt(request: SpawnRequest): string {
|
||||
const base = request.agentBody ? `${request.agentBody}\n\n` : "";
|
||||
if (request.context === "fork") {
|
||||
return `${base}You are running as a delegated subagent in fork context.\nUse the inherited parent session context, then return a concise final answer for the parent agent.\n\nTask:\n${request.prompt}`;
|
||||
}
|
||||
return `${base}You are running as a delegated subagent in independent context.\nDo not assume access to the parent conversation transcript.\nReturn a concise final answer for the parent agent.\n\nTask:\n${request.prompt}`;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user