fix: include status and timing in sessions_list tool

This commit is contained in:
Tyler Yust
2026-03-12 01:09:30 -07:00
parent 865bdf05fe
commit 5343de3bf6
2 changed files with 29 additions and 0 deletions

View File

@@ -120,6 +120,10 @@ describe("sessions tools", () => {
updatedAt: 11,
channel: "discord",
displayName: "discord:g-dev",
status: "running",
startedAt: 100,
runtimeMs: 42,
childSessions: ["agent:main:subagent:worker"],
},
{
key: "cron:job-1",
@@ -157,6 +161,10 @@ describe("sessions tools", () => {
sessions?: Array<{
key?: string;
channel?: string;
status?: string;
startedAt?: number;
runtimeMs?: number;
childSessions?: string[];
messages?: Array<{ role?: string }>;
}>;
};
@@ -166,6 +174,12 @@ describe("sessions tools", () => {
expect(main?.messages?.length).toBe(1);
expect(main?.messages?.[0]?.role).toBe("assistant");
const group = details.sessions?.find((s) => s.key === "discord:group:dev");
expect(group?.status).toBe("running");
expect(group?.startedAt).toBe(100);
expect(group?.runtimeMs).toBe(42);
expect(group?.childSessions).toEqual(["agent:main:subagent:worker"]);
const cronOnly = await tool.execute("call2", { kinds: ["cron"] });
const cronDetails = cronOnly.details as {
sessions?: Array<Record<string, unknown>>;

View File

@@ -203,6 +203,21 @@ export function createSessionsListTool(opts?: {
model: typeof entry.model === "string" ? entry.model : undefined,
contextTokens: typeof entry.contextTokens === "number" ? entry.contextTokens : undefined,
totalTokens: typeof entry.totalTokens === "number" ? entry.totalTokens : undefined,
status: typeof entry.status === "string" ? entry.status : undefined,
startedAt: typeof entry.startedAt === "number" ? entry.startedAt : undefined,
endedAt: typeof entry.endedAt === "number" ? entry.endedAt : undefined,
runtimeMs: typeof entry.runtimeMs === "number" ? entry.runtimeMs : undefined,
childSessions: Array.isArray(entry.childSessions)
? entry.childSessions
.filter((value): value is string => typeof value === "string")
.map((value) =>
resolveDisplaySessionKey({
key: value,
alias,
mainKey,
}),
)
: undefined,
thinkingLevel: typeof entry.thinkingLevel === "string" ? entry.thinkingLevel : undefined,
verboseLevel: typeof entry.verboseLevel === "string" ? entry.verboseLevel : undefined,
systemSent: typeof entry.systemSent === "boolean" ? entry.systemSent : undefined,