fix: keep session settings in sessions list

This commit is contained in:
Tak Hoffman
2026-03-26 22:46:06 -05:00
parent ef56d79a6a
commit 962cc740a0
3 changed files with 80 additions and 0 deletions

View File

@@ -73,7 +73,11 @@ export type SessionListRow = {
runtimeMs?: number;
childSessions?: string[];
thinkingLevel?: string;
fastMode?: boolean;
verboseLevel?: string;
reasoningLevel?: string;
elevatedLevel?: string;
responseUsage?: string;
systemSent?: boolean;
abortedLastRun?: boolean;
sendPolicy?: string;

View File

@@ -73,4 +73,75 @@ describe("sessions-list-tool", () => {
threadId: "thread-1",
});
});
it("keeps live session setting metadata in sessions_list results", async () => {
const gatewayCallMock = vi.fn(async (opts: unknown) => {
const request = opts as { method?: string };
if (request.method === "sessions.list") {
return {
path: "/tmp/sessions.json",
sessions: [
{
key: "main",
kind: "direct",
sessionId: "sess-main",
thinkingLevel: "high",
fastMode: true,
verboseLevel: "on",
reasoningLevel: "deep",
elevatedLevel: "on",
responseUsage: "full",
},
],
};
}
return {};
});
vi.doMock("../../gateway/call.js", () => ({
callGateway: gatewayCallMock,
}));
vi.doMock("./sessions-helpers.js", async () => {
const actual =
await vi.importActual<typeof import("./sessions-helpers.js")>("./sessions-helpers.js");
return {
...actual,
createAgentToAgentPolicy: () => ({}),
createSessionVisibilityGuard: async () => ({
check: () => ({ allowed: true }),
}),
resolveEffectiveSessionToolsVisibility: () => "all",
resolveSandboxedSessionToolContext: () => ({
mainKey: "main",
alias: "main",
requesterInternalKey: undefined,
restrictToSpawned: false,
}),
};
});
const { createSessionsListTool } = await import("./sessions-list-tool.js");
const tool = createSessionsListTool({ config: {} as never });
const result = await tool.execute("call-2", {});
const details = result.details as {
sessions?: Array<{
thinkingLevel?: string;
fastMode?: boolean;
verboseLevel?: string;
reasoningLevel?: string;
elevatedLevel?: string;
responseUsage?: string;
}>;
};
expect(details.sessions?.[0]).toMatchObject({
thinkingLevel: "high",
fastMode: true,
verboseLevel: "on",
reasoningLevel: "deep",
elevatedLevel: "on",
responseUsage: "full",
});
});
});

View File

@@ -251,7 +251,12 @@ export function createSessionsListTool(opts?: {
)
: undefined,
thinkingLevel: typeof entry.thinkingLevel === "string" ? entry.thinkingLevel : undefined,
fastMode: typeof entry.fastMode === "boolean" ? entry.fastMode : undefined,
verboseLevel: typeof entry.verboseLevel === "string" ? entry.verboseLevel : undefined,
reasoningLevel:
typeof entry.reasoningLevel === "string" ? entry.reasoningLevel : undefined,
elevatedLevel: typeof entry.elevatedLevel === "string" ? entry.elevatedLevel : undefined,
responseUsage: typeof entry.responseUsage === "string" ? entry.responseUsage : undefined,
systemSent: typeof entry.systemSent === "boolean" ? entry.systemSent : undefined,
abortedLastRun:
typeof entry.abortedLastRun === "boolean" ? entry.abortedLastRun : undefined,