fix(gateway): cap chat.history payload size

This commit is contained in:
Peter Steinberger
2025-12-16 19:34:36 +01:00
parent 66a0813e44
commit 2a5f0d6063
2 changed files with 86 additions and 2 deletions

View File

@@ -1813,13 +1813,19 @@ export async function startGatewayServer(
);
break;
}
const { sessionKey } = params as { sessionKey: string };
const { sessionKey, limit } = params as {
sessionKey: string;
limit?: number;
};
const { storePath, entry } = loadSessionEntry(sessionKey);
const sessionId = entry?.sessionId;
const messages =
const rawMessages =
sessionId && storePath
? readSessionMessages(sessionId, storePath)
: [];
const max = typeof limit === "number" ? limit : 200;
const messages =
rawMessages.length > max ? rawMessages.slice(-max) : rawMessages;
const thinkingLevel =
entry?.thinkingLevel ??
loadConfig().inbound?.reply?.thinkingDefault ??