fix(gateway): clamp chat.history to 1000 max

This commit is contained in:
Peter Steinberger
2025-12-16 19:55:17 +01:00
parent d691e28675
commit 74b19843ae
3 changed files with 13 additions and 12 deletions

View File

@@ -1824,7 +1824,8 @@ export async function startGatewayServer(
? readSessionMessages(sessionId, storePath)
: [];
const hardMax = 1000;
const requested = typeof limit === "number" ? limit : hardMax;
const defaultLimit = 200;
const requested = typeof limit === "number" ? limit : defaultLimit;
const max = Math.min(hardMax, requested);
const messages =
rawMessages.length > max ? rawMessages.slice(-max) : rawMessages;