

























@@ -225,6 +225,76 @@ describe("subagent registry seam flow", () => {
225225vi.useRealTimers();
226226});
227227228+it("lists active and pending-delivery child sessions for maintenance preservation", () => {
229+const now = Date.now();
230+mod.addSubagentRunForTests({
231+runId: "run-active",
232+childSessionKey: "agent:main:subagent:active",
233+requesterSessionKey: "agent:main:main",
234+requesterDisplayKey: "main",
235+task: "active task",
236+cleanup: "delete",
237+expectsCompletionMessage: true,
238+createdAt: now,
239+});
240+mod.addSubagentRunForTests({
241+runId: "run-pending",
242+childSessionKey: "agent:main:subagent:pending",
243+requesterSessionKey: "agent:main:main",
244+requesterDisplayKey: "main",
245+task: "pending delivery task",
246+cleanup: "delete",
247+expectsCompletionMessage: true,
248+createdAt: now - 2,
249+endedAt: now - 1,
250+pendingFinalDelivery: true,
251+frozenResultText: "child output",
252+});
253+mod.addSubagentRunForTests({
254+runId: "run-complete",
255+childSessionKey: "agent:main:subagent:complete",
256+requesterSessionKey: "agent:main:main",
257+requesterDisplayKey: "main",
258+task: "already delivered task",
259+cleanup: "keep",
260+expectsCompletionMessage: true,
261+createdAt: now - 4,
262+endedAt: now - 3,
263+completionAnnouncedAt: now - 2,
264+cleanupCompletedAt: now - 1,
265+});
266+267+expect(mod.listSessionMaintenanceProtectedSubagentSessionKeys().toSorted()).toEqual([
268+"agent:main:subagent:active",
269+"agent:main:subagent:pending",
270+]);
271+});
272+273+it("uses the disk-aware run snapshot for maintenance preservation", () => {
274+const now = Date.now();
275+mocks.getSubagentRunsSnapshotForRead.mockReturnValueOnce(
276+new Map([
277+[
278+"run-restored",
279+{
280+runId: "run-restored",
281+childSessionKey: "agent:main:subagent:restored",
282+requesterSessionKey: "agent:main:main",
283+requesterDisplayKey: "main",
284+task: "restored pending task",
285+cleanup: "delete",
286+expectsCompletionMessage: true,
287+createdAt: now,
288+},
289+],
290+]),
291+);
292+293+expect(mod.listSessionMaintenanceProtectedSubagentSessionKeys()).toEqual([
294+"agent:main:subagent:restored",
295+]);
296+});
297+228298it("schedules orphan recovery instead of terminally failing on recoverable wait transport errors", async () => {
229299mocks.callGateway.mockImplementation(async (request: { method?: string }) => {
230300if (request.method === "agent.wait") {
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。