fix: preserve reset spawn depth

This commit is contained in:
Tak Hoffman
2026-03-26 10:38:23 -05:00
parent c4048aea41
commit 6bdf5e5634
2 changed files with 6 additions and 2 deletions

View File

@@ -1013,6 +1013,7 @@ describe("gateway server sessions", () => {
updatedAt: Date.now(),
spawnedBy: "agent:main:main",
parentSessionKey: "agent:main:main",
spawnDepth: 2,
label: "owned child",
},
},
@@ -1022,20 +1023,22 @@ describe("gateway server sessions", () => {
const reset = await rpcReq<{
ok: true;
key: string;
entry: { spawnedBy?: string; parentSessionKey?: string; label?: string };
entry: { spawnedBy?: string; parentSessionKey?: string; spawnDepth?: number; label?: string };
}>(ws, "sessions.reset", { key: "subagent:child" });
expect(reset.ok).toBe(true);
expect(reset.payload?.entry.spawnedBy).toBe("agent:main:main");
expect(reset.payload?.entry.parentSessionKey).toBe("agent:main:main");
expect(reset.payload?.entry.spawnDepth).toBe(2);
expect(reset.payload?.entry.label).toBe("owned child");
const store = JSON.parse(await fs.readFile(storePath, "utf-8")) as Record<
string,
{ spawnedBy?: string; parentSessionKey?: string; label?: string }
{ spawnedBy?: string; parentSessionKey?: string; spawnDepth?: number; label?: string }
>;
expect(store["agent:main:subagent:child"]?.spawnedBy).toBe("agent:main:main");
expect(store["agent:main:subagent:child"]?.parentSessionKey).toBe("agent:main:main");
expect(store["agent:main:subagent:child"]?.spawnDepth).toBe(2);
expect(store["agent:main:subagent:child"]?.label).toBe("owned child");
ws.close();

View File

@@ -322,6 +322,7 @@ export async function performGatewaySessionReset(params: {
sendPolicy: currentEntry?.sendPolicy,
spawnedBy: currentEntry?.spawnedBy,
parentSessionKey: currentEntry?.parentSessionKey,
spawnDepth: currentEntry?.spawnDepth,
label: currentEntry?.label,
origin: snapshotSessionOrigin(currentEntry),
lastChannel: currentEntry?.lastChannel,