-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathchatLogLimits.js
More file actions
33 lines (28 loc) · 1012 Bytes
/
chatLogLimits.js
File metadata and controls
33 lines (28 loc) · 1012 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
'use strict';
/** Hard cap so “full log” mode cannot write multi‑GB lines to guide-main.log */
const ABS_MAX = 512000;
function parseBodyLimit(raw, fallback) {
if (raw === undefined || raw === '') return fallback;
const n = parseInt(String(raw).trim(), 10);
if (!Number.isFinite(n)) return fallback;
if (n <= 0) return ABS_MAX;
return Math.min(n, ABS_MAX);
}
/** User + assistant message previews in guide-main.log */
function chatLogBodyLimit() {
return parseBodyLimit(process.env.GUIDE_CHAT_LOG_MAX_CHARS, 32000);
}
/** Tool result previews (often JSON blobs) */
function chatLogToolLimit() {
const body = chatLogBodyLimit();
const raw = process.env.GUIDE_CHAT_LOG_TOOL_CHARS;
if (raw === undefined || raw === '') return Math.min(32000, body);
const n = parseInt(String(raw).trim(), 10);
if (!Number.isFinite(n) || n <= 0) return Math.min(32000, body);
return Math.min(n, ABS_MAX);
}
module.exports = {
chatLogBodyLimit,
chatLogToolLimit,
CHAT_LOG_ABS_MAX: ABS_MAX,
};