feat(FN-3961): propagate taskEnv into agent subprocess sessions
Propagates `taskEnv` (task-scoped environment variables) through the agent session creation pipeline, including executor sessions, spawned child agents, and workflow sessions. The engine's session factory (`agent-session-helpers.ts`), executor, PI agent creation (`pi.ts`), and step session executor Fusion-Task-Id: FN-3961
This commit is contained in:
@@ -1,10 +1,22 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { beforeEach, describe, expect, it, vi } from "vitest";
|
||||
import {
|
||||
extractRuntimeHint,
|
||||
resolveHeartbeatSessionModels,
|
||||
resolveMergerSessionModel,
|
||||
} from "../agent-session-helpers.js";
|
||||
|
||||
const { resolveRuntimeMock } = vi.hoisted(() => ({
|
||||
resolveRuntimeMock: vi.fn(),
|
||||
}));
|
||||
|
||||
vi.mock("../runtime-resolution.js", async () => {
|
||||
const actual = await vi.importActual<typeof import("../runtime-resolution.js")>("../runtime-resolution.js");
|
||||
return {
|
||||
...actual,
|
||||
resolveRuntime: resolveRuntimeMock,
|
||||
};
|
||||
});
|
||||
|
||||
describe("extractRuntimeHint", () => {
|
||||
it("returns undefined for undefined config", () => {
|
||||
expect(extractRuntimeHint(undefined)).toBeUndefined();
|
||||
@@ -74,6 +86,48 @@ describe("resolveHeartbeatSessionModels", () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe("createResolvedAgentSession", () => {
|
||||
beforeEach(() => {
|
||||
resolveRuntimeMock.mockReset();
|
||||
});
|
||||
|
||||
it("forwards taskEnv unchanged to runtime session factory", async () => {
|
||||
const mockSession = { prompt: vi.fn() } as any;
|
||||
const createSessionMock = vi.fn().mockResolvedValue({
|
||||
session: mockSession,
|
||||
sessionFile: "session.json",
|
||||
});
|
||||
resolveRuntimeMock.mockResolvedValue({
|
||||
runtime: {
|
||||
id: "pi",
|
||||
name: "Default PI Runtime",
|
||||
createSession: createSessionMock,
|
||||
promptWithFallback: vi.fn(),
|
||||
describeModel: vi.fn(() => "mock/model"),
|
||||
},
|
||||
runtimeId: "pi",
|
||||
wasConfigured: false,
|
||||
});
|
||||
|
||||
const { createResolvedAgentSession } = await import("../agent-session-helpers.js");
|
||||
|
||||
const taskEnv = { PATH: "/tmp/bin", FUSION_TEST_VAR: "value" };
|
||||
await createResolvedAgentSession({
|
||||
sessionPurpose: "executor",
|
||||
pluginRunner: undefined,
|
||||
cwd: "/tmp/project",
|
||||
systemPrompt: "system",
|
||||
taskEnv,
|
||||
});
|
||||
|
||||
expect(createSessionMock).toHaveBeenCalledWith(
|
||||
expect.objectContaining({
|
||||
taskEnv,
|
||||
}),
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
describe("resolveMergerSessionModel", () => {
|
||||
it("uses assigned agent runtime model when both provider and modelId are present", () => {
|
||||
expect(
|
||||
|
||||
Reference in New Issue
Block a user