fix(pi): give each task sub-session its own resource loader to prevent stale extension ctx

This commit is contained in:
ezl-keygraph committed 2026-09-01 01:45:46 +05:30
1 parent e9cf782081
commit 4e145a0f3f
2 files changed
+5 -4

No files matched your search

+2 -2
View File
@@ -299,7 +299,7 @@ export async function runPiPrompt(
childUsage.cacheReadTokens += usage.cacheReadTokens;
childUsage.cacheWriteTokens += usage.cacheWriteTokens;
},
resourceLoader,
createResourceLoader: () => buildResourceLoader(sourceDir, logger, agentName),
...(cancellationSignal && { cancellationSignal }),
}),
createTodoWriteTool(),
@@ -403,7 +403,6 @@ export async function runPiPrompt(
// 6. Run the agent to completion (resolves at agent_end).
await session.prompt(fullPrompt);
session.dispose();
// 7. Surface any error captured during the run.
if (pendingError) throw pendingError;
@@ -469,6 +468,7 @@ export async function runPiPrompt(
retryable,
};
} finally {
session?.dispose();
cancellationSignal?.removeEventListener('abort', onCancellation);
}
}