INNER CODE UNIT · TypeScript
safe
PentesterFlow/agent · src/cli/index.ts:1000
const safe = Math.floor(info.numCtx * 0.7);
const userConfigured =
cfg.auto_compact_threshold !== config.DEFAULT_AUTO_COMPACT_THRESHOLD;
if (safe < threshold) {
agent.setAutoCompactThreshold(safe);
const msg = `ℹ auto-compact threshold lowered to ${safe} tokens to fit ollama num_ctx ${info.numCtx} (source: ${info.source}); prevents silent context truncation.`;
process.stderr.write(`${msg}\n`);
noticeHolder.publish?.(msg);
} else if (safe > threshold && !userConfigured) {
agent.setAutoCompactThreshold(safe);
const msg = `ℹ auto-compact threshold raised to ${safe} tokens to use ollama num_ctx ${info.numCtx} (source: ${info.source}); default 16k was compacting this window early.`;
process.stderr.write(`${msg}\n`);
noticeHolder.publish?.(msg);
}
// Even after clamping, a tiny window can't hold a useful agent
// prompt (system + tools alone may exceed it), so context loss —
// and hallucination — is unavoidable until it's raised.
if (info.numCtx < 4096) {