



























@@ -280,12 +280,14 @@ const resolveAgentOrder = (cfg: OpenClawConfig) => {
280280return { defaultAgentId, ordered };
281281};
282282283-const buildSessionSummary = async (storePath: string) => {
284-const { loadSessionStore } = await import("../config/sessions/store.js");
285-const store = loadSessionStore(storePath, { clone: false });
286-const sessions = Object.entries(store)
287-.filter(([key]) => key !== "global" && key !== "unknown")
288-.map(([key, entry]) => ({ key, updatedAt: entry?.updatedAt ?? 0 }))
283+const buildSessionSummary = async (storePath: string, agentId?: string) => {
284+const { listSessionEntries } = await import("../config/sessions/session-accessor.js");
285+const sessions = listSessionEntries({
286+ ...(agentId ? { agentId } : {}),
287+ storePath,
288+})
289+.filter(({ sessionKey }) => sessionKey !== "global" && sessionKey !== "unknown")
290+.map(({ sessionKey, entry }) => ({ key: sessionKey, updatedAt: entry?.updatedAt ?? 0 }))
289291.toSorted((a, b) => b.updatedAt - a.updatedAt);
290292const recent = sessions.slice(0, 5).map((s) => ({
291293key: s.key,
@@ -471,8 +473,10 @@ export async function getHealthSnapshot(params?: {
471473const agents: AgentHealthSummary[] = [];
472474for (const entry of ordered) {
473475const storePath = resolveStorePath(cfg.session?.store, { agentId: entry.id });
474-const sessions = sessionCache.get(storePath) ?? (await buildSessionSummary(storePath));
475-sessionCache.set(storePath, sessions);
476+const sessionCacheKey = `${storePath}\0${entry.id}`;
477+const sessions =
478+sessionCache.get(sessionCacheKey) ?? (await buildSessionSummary(storePath, entry.id));
479+sessionCache.set(sessionCacheKey, sessions);
476480agents.push({
477481agentId: entry.id,
478482name: entry.name,
@@ -487,7 +491,10 @@ export async function getHealthSnapshot(params?: {
487491 : 0;
488492const sessions =
489493defaultAgent?.sessions ??
490-(await buildSessionSummary(resolveStorePath(cfg.session?.store, { agentId: defaultAgentId })));
494+(await buildSessionSummary(
495+resolveStorePath(cfg.session?.store, { agentId: defaultAgentId }),
496+defaultAgentId,
497+));
491498492499const start = Date.now();
493500const cappedTimeout = resolveTimerTimeoutMs(timeoutMs, DEFAULT_TIMEOUT_MS, 50);
@@ -767,7 +774,7 @@ export async function healthCommand(
767774name: entry.name,
768775isDefault: entry.id === localAgents.defaultAgentId,
769776heartbeat: resolveHeartbeatSummary(cfg, entry.id),
770-sessions: await buildSessionSummary(storePath),
777+sessions: await buildSessionSummary(storePath, entry.id),
771778} satisfies AgentHealthSummary;
772779}),
773780);
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。