fix(gateway): cap chat.history to 1000 messages

This commit is contained in:
Peter Steinberger
2025-12-16 19:44:49 +01:00
parent 2a5f0d6063
commit d691e28675
3 changed files with 49 additions and 4 deletions

View File

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