




























@@ -1372,9 +1372,7 @@ describe("steerControlledSubagentRun", () => {
13721372});
1373137313741374setSubagentControlDepsForTest({
1375-callGateway: async <T = Record<string, unknown>>(
1376-request: CallGatewayOptions,
1377-) => {
1375+callGateway: async <T = Record<string, unknown>>(request: CallGatewayOptions) => {
13781376if (request.method === "agent.wait") {
13791377return {} as T;
13801378}
@@ -1419,4 +1417,67 @@ describe("steerControlledSubagentRun", () => {
14191417text: "steered yielded steer task.",
14201418});
14211419});
1420+1421+it("rotates the child session when restarting a previously active session", async () => {
1422+const childSessionKey = "agent:main:subagent:active-steer-worker";
1423+const storePath = writeSessionStoreFixture("steer-restart-session", {
1424+[childSessionKey]: {
1425+sessionId: "old-child-session",
1426+updatedAt: Date.now(),
1427+},
1428+});
1429+const agentCalls: CallGatewayOptions[] = [];
1430+addSubagentRunForTests({
1431+runId: "run-active-steer",
1432+ childSessionKey,
1433+controllerSessionKey: "agent:main:main",
1434+requesterSessionKey: "agent:main:main",
1435+requesterDisplayKey: "main",
1436+task: "active steer task",
1437+cleanup: "keep",
1438+createdAt: Date.now() - 5_000,
1439+startedAt: Date.now() - 4_000,
1440+});
1441+1442+setSubagentControlDepsForTest({
1443+callGateway: async <T = Record<string, unknown>>(request: CallGatewayOptions) => {
1444+if (request.method === "agent.wait") {
1445+return {} as T;
1446+}
1447+if (request.method === "agent") {
1448+agentCalls.push(request);
1449+return { runId: "run-active-steer-restarted" } as T;
1450+}
1451+throw new Error(`unexpected method: ${request.method}`);
1452+},
1453+});
1454+1455+const result = await steerControlledSubagentRun({
1456+cfg: cfgWithSessionStore(storePath),
1457+controller: {
1458+controllerSessionKey: "agent:main:main",
1459+callerSessionKey: "agent:main:main",
1460+callerIsSubagent: false,
1461+controlScope: "children",
1462+},
1463+entry: {
1464+runId: "run-active-steer",
1465+ childSessionKey,
1466+requesterSessionKey: "agent:main:main",
1467+requesterDisplayKey: "main",
1468+controllerSessionKey: "agent:main:main",
1469+task: "active steer task",
1470+cleanup: "keep",
1471+createdAt: Date.now() - 5_000,
1472+startedAt: Date.now() - 4_000,
1473+},
1474+message: "updated direction",
1475+});
1476+1477+expect(result.status).toBe("accepted");
1478+expect(result.sessionId).toBeTypeOf("string");
1479+expect(result.sessionId).not.toBe("old-child-session");
1480+const agentParams = agentCalls[0]?.params as { sessionId?: string } | undefined;
1481+expect(agentParams?.sessionId).toBe(result.sessionId);
1482+});
14221483});
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。